rust-analyzer/crates/hir_def/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
..
body Add a coverage mark 2021-07-05 17:06:16 +02:00
item_tree Add workaround for #9562 2021-07-11 16:14:39 +02:00
nameres fix: avoid pathological macro expansions 2021-08-09 16:15:02 +03:00
path clippy::redudant_borrow 2021-06-13 09:24:16 +05:30
adt.rs Global TypeRef/TraitRef interning 2021-04-01 19:46:43 +02:00
attr.rs internal: remove useless helpers 2021-08-09 15:58:21 +03:00
body.rs Add Limit struct. 2021-07-19 13:26:11 +01:00
builtin_attr.rs Update list of built-in attributes 2021-06-03 18:09:21 +02:00
builtin_type.rs Introduce TypeCtor::Scalar 2021-02-28 01:20:04 +01:00
child_by_source.rs Handle attribute macros in descend_into_macros 2021-06-06 17:03:37 +02:00
data.rs Add TreeId to identify ItemTrees 2021-07-19 14:53:18 +02:00
db.rs Make it opt-in 2021-06-03 18:09:21 +02:00
dyn_map.rs Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00
expr.rs Add support for lengths in array repeats, if they are literals 2021-05-12 21:22:46 -07:00
find_path.rs Explicitly connect an ambiguous import path case logic with the test on it 2021-07-16 00:41:00 +03:00
generics.rs Apply some clippy suggestions 2021-06-21 16:40:21 +02:00
import_map.rs Reduce fst_path calls 2021-06-11 00:10:09 +03:00
intern.rs internal: intern AttrInput 2021-05-25 00:50:19 +02:00
item_scope.rs internal: remove potentially slow method 2021-07-20 17:19:58 +03:00
item_tree.rs Add TreeId to identify ItemTrees 2021-07-19 14:53:18 +02:00
keys.rs Handle attribute macros in descend_into_macros 2021-06-06 17:03:37 +02:00
lang_item.rs Look for enum variants and trait assoc functions when looking for lang items 2021-08-07 22:30:13 +02:00
lib.rs Fix visibility computation with modules from the same block 2021-07-05 16:06:50 +02:00
nameres.rs internal: get rid of a call to slow O(N) visibility_of function 2021-07-12 21:13:43 +03:00
path.rs Apply some clippy suggestions 2021-06-21 16:40:21 +02:00
per_ns.rs Add more profiling for flyimports 2021-06-10 23:43:46 +03:00
resolver.rs feat: filter out duplicate macro completions 2021-08-03 17:36:06 +03:00
src.rs Make ItemTreeId its own type 2021-03-18 01:53:22 +01:00
test_db.rs fix: Typos 2021-07-27 18:31:21 -04:00
trace.rs Use ‘index’ terminology for arena consistently 2021-01-17 18:38:08 +11:00
type_ref.rs Implement TypeRef::ForLifetime 2021-06-30 01:34:54 +02:00
visibility.rs Add a coverage mark 2021-07-05 17:06:16 +02:00