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`
This commit is contained in:
commit
5f6cb2c552
6 changed files with 69 additions and 19 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue