rust-analyzer/crates/hir_expand/src
Aleksey Kladov 3e5b155716 fix: avoid pathological macro expansions
Today, rust-analyzer (and rustc, and bat, and IntelliJ) fail badly on
some kinds of maliciously constructed code, like a deep sequence of
nested parenthesis.

"Who writes 100k nested parenthesis" you'd ask?

Well, in a language with macros, a run-away macro expansion might do
that (see the added tests)! Such expansion can be broad, rather than
deep, so it bypasses recursion check at the macro-expansion layer, but
triggers deep recursion in parser.

In the ideal world, the parser would just handle deeply nested structs
gracefully. We'll get there some day, but at the moment, let's try to be
simple, and just avoid expanding macros with unbalanced parenthesis in
the first place.

closes #9358
2021-08-09 16:15:02 +03:00
..
ast_id_map.rs add more counts 2021-01-27 12:16:24 +03:00
builtin_attr.rs Resolve attribute paths in attribute highlighting 2021-06-28 21:53:17 +02:00
builtin_derive.rs clippy::useless_conversion 2021-06-13 09:25:55 +05:30
builtin_macro.rs internal: remove useless helpers 2021-08-09 15:58:21 +03:00
db.rs fix: avoid pathological macro expansions 2021-08-09 16:15:02 +03:00
eager.rs internal: remove useless helpers 2021-08-09 15:58:21 +03:00
hygiene.rs Nest all the or-patterns! 2021-06-17 17:37:14 +02:00
input.rs clippy::redudant_borrow 2021-06-13 09:24:16 +05:30
lib.rs Fix detection of macro file in inactive-code diag 2021-08-04 18:02:45 +02:00
name.rs Implement if_to_bool_then assist 2021-08-08 17:56:34 +02:00
proc_macro.rs clippy::clone_on_copy 2021-06-13 09:27:19 +05:30
quote.rs Escape characters in builtin macros correctly 2021-05-09 19:57:29 +08:00
test_db.rs Introduce anchored_path 2020-12-09 19:07:05 +03:00