Skip to content

Commit 981bbe7

Browse files
committed
Unify visit_walk_use_tree
1 parent 07b49f7 commit 981bbe7

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

compiler/rustc_ast/src/visitors.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@ macro_rules! mutability_dependent {
2626
fn visit_path(&mut self, path: &'ast Path, _id: NodeId) -> Self::Result {
2727
walk_path(self, path)
2828
}
29-
// FIXME: inconsistent
30-
fn visit_use_tree(
31-
&mut self,
32-
use_tree: &'ast UseTree,
33-
id: NodeId,
34-
_nested: bool,
35-
) -> Self::Result {
36-
walk_use_tree(self, use_tree, id)
37-
}
3829
};
3930
(mut $($lf: lifetime)?) => {
4031
/// Mutable token visiting only exists for the `macro_rules` token marker and should not be
@@ -83,10 +74,6 @@ macro_rules! mutability_dependent {
8374
walk_meta_item(self, meta_item);
8475
}
8576

86-
fn visit_use_tree(&mut self, use_tree: &mut UseTree) {
87-
walk_use_tree(self, use_tree);
88-
}
89-
9077
fn flat_map_foreign_item(&mut self, ni: P<ForeignItem>) -> SmallVec<[P<ForeignItem>; 1]> {
9178
walk_flat_map_item(self, ni)
9279
}
@@ -365,6 +352,14 @@ macro_rules! make_ast_visitor {
365352
self.visit_expr(ex)
366353
}
367354

355+
fn visit_use_tree(
356+
&mut self,
357+
use_tree: ref_t!(UseTree),
358+
id: NodeId,
359+
_nested: bool,
360+
) -> result!() {
361+
walk_use_tree(self, use_tree, id)
362+
}
368363
}
369364

370365
macro_rules! visit_span {
@@ -1855,15 +1850,15 @@ pub mod mut_visit {
18551850
vis.visit_span(close);
18561851
}
18571852

1858-
fn walk_use_tree<T: MutVisitor>(vis: &mut T, use_tree: &mut UseTree) {
1853+
fn walk_use_tree<T: MutVisitor>(vis: &mut T, use_tree: &mut UseTree, _id: NodeId) {
18591854
let UseTree { prefix, kind, span } = use_tree;
18601855
vis.visit_path(prefix);
18611856
match kind {
18621857
UseTreeKind::Simple(rename) => visit_opt(rename, |rename| vis.visit_ident(rename)),
18631858
UseTreeKind::Nested { items, span } => {
18641859
for (tree, id) in items {
18651860
vis.visit_id(id);
1866-
vis.visit_use_tree(tree);
1861+
vis.visit_use_tree(tree, *id, true);
18671862
}
18681863
vis.visit_span(span);
18691864
}
@@ -2332,7 +2327,7 @@ pub mod mut_visit {
23322327
fn walk(&mut self, span: Span, id: NodeId, vis: &mut impl MutVisitor) {
23332328
match self {
23342329
ItemKind::ExternCrate(_orig_name) => {}
2335-
ItemKind::Use(use_tree) => vis.visit_use_tree(use_tree),
2330+
ItemKind::Use(use_tree) => vis.visit_use_tree(use_tree, id, false),
23362331
ItemKind::Static(box StaticItem { ty, safety: _, mutability: _, expr }) => {
23372332
vis.visit_ty(ty);
23382333
visit_opt(expr, |expr| vis.visit_expr(expr));

0 commit comments

Comments
 (0)