Rollup merge of #124382 - petrochenkov:itemvisit, r=lcnr
ast: Generalize item kind visiting And avoid duplicating logic for visiting `Item`s with different kinds (regular, associated, foreign). The diff is better viewed with whitespace ignored.
This commit is contained in:
commit
cf07246ae9
18 changed files with 413 additions and 385 deletions
|
@ -1335,7 +1335,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
|||
}
|
||||
|
||||
self.build_reduced_graph_for_foreign_item(foreign_item);
|
||||
visit::walk_foreign_item(self, foreign_item);
|
||||
visit::walk_item(self, foreign_item);
|
||||
}
|
||||
|
||||
fn visit_block(&mut self, block: &'b Block) {
|
||||
|
|
|
@ -219,7 +219,7 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
|
|||
|
||||
let def = self.create_def(fi.id, fi.ident.name, def_kind, fi.span);
|
||||
|
||||
self.with_parent(def, |this| visit::walk_foreign_item(this, fi));
|
||||
self.with_parent(def, |this| visit::walk_item(this, fi));
|
||||
}
|
||||
|
||||
fn visit_variant(&mut self, v: &'a Variant) {
|
||||
|
|
|
@ -886,7 +886,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
|
|||
kind: LifetimeBinderKind::Item,
|
||||
span: generics.span,
|
||||
},
|
||||
|this| visit::walk_foreign_item(this, foreign_item),
|
||||
|this| visit::walk_item(this, foreign_item),
|
||||
);
|
||||
}
|
||||
ForeignItemKind::Fn(box Fn { ref generics, .. }) => {
|
||||
|
@ -898,13 +898,11 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
|
|||
kind: LifetimeBinderKind::Function,
|
||||
span: generics.span,
|
||||
},
|
||||
|this| visit::walk_foreign_item(this, foreign_item),
|
||||
|this| visit::walk_item(this, foreign_item),
|
||||
);
|
||||
}
|
||||
ForeignItemKind::Static(..) => {
|
||||
self.with_static_rib(def_kind, |this| {
|
||||
visit::walk_foreign_item(this, foreign_item);
|
||||
});
|
||||
self.with_static_rib(def_kind, |this| visit::walk_item(this, foreign_item))
|
||||
}
|
||||
ForeignItemKind::MacCall(..) => {
|
||||
panic!("unexpanded macro in resolve!")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue