diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-11-25 15:05:38 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-25 15:05:38 +0100 |
| commit | 5f6cb2c552a723c41ae31794c7f2f3a61704df69 (patch) | |
| tree | 84cc5ed12c4bc1d03f75758c48b1e9d05aba19bd /compiler/rustc_resolve/src | |
| parent | 6970cf5a23b4b9a3fbe474684e6bec9f0e13ddd4 (diff) | |
| parent | 7f5d3fff4f138cd5aaeea2a3ec4be44da6e8c308 (diff) | |
| download | rust-5f6cb2c552a723c41ae31794c7f2f3a61704df69.tar.gz rust-5f6cb2c552a723c41ae31794c7f2f3a61704df69.zip | |
Rollup merge of #91111 - cjgillot:hir-no-lower-attrs, r=michaelwoerister
Do not visit attributes in `ItemLowerer`. By default, AST visitors visit expressions that appear in key-value attributes. Those expressions should not be lowered to HIR, as they do not correspond to actually compiled code. Since an attribute cannot produce meaningful HIR, just skip them altogether. Fixes https://github.com/rust-lang/rust/issues/81886 Fixes https://github.com/rust-lang/rust/issues/90873 r? `@michaelwoerister`
Diffstat (limited to 'compiler/rustc_resolve/src')
| -rw-r--r-- | compiler/rustc_resolve/src/late.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index e67f7f03516..12123c946cc 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -431,6 +431,10 @@ struct LateResolutionVisitor<'a, 'b, 'ast> { /// Walks the whole crate in DFS order, visiting each item, resolving names as it goes. impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> { + fn visit_attribute(&mut self, _: &'ast Attribute) { + // We do not want to resolve expressions that appear in attributes, + // as they do not correspond to actual code. + } fn visit_item(&mut self, item: &'ast Item) { let prev = replace(&mut self.diagnostic_metadata.current_item, Some(item)); // Always report errors in items we just entered. |
