1
Fork 0

Do not visit attributes in LateResolutionVisitor.

This commit is contained in:
Camille GILLOT 2021-11-24 23:07:13 +01:00
parent ae126ad282
commit 7f5d3fff4f
5 changed files with 32 additions and 22 deletions

View file

@ -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.