@@ -213,7 +213,6 @@ macro_rules! make_ast_visitor {
213
213
make_visit!{ MetaItemInner ; visit_meta_list_item, walk_meta_list_item}
214
214
make_visit!{ Path ; visit_path, walk_path}
215
215
make_visit!{ PreciseCapturingArg ; visit_precise_capturing_arg, walk_precise_capturing_arg}
216
- make_visit!{ UseTree ; visit_use_tree, walk_use_tree}
217
216
218
217
fn flat_map_foreign_item( & mut self , ni: P <ForeignItem >) -> SmallVec <[ P <ForeignItem >; 1 ] > {
219
218
walk_flat_map_item( self , ni)
@@ -296,7 +295,6 @@ macro_rules! make_ast_visitor {
296
295
make_visit!{ Item ; visit_item, walk_item}
297
296
make_visit!{ Path , _ id: NodeId ; visit_path, walk_path}
298
297
make_visit!{ Stmt ; visit_stmt, walk_stmt}
299
- make_visit!{ UseTree , id: NodeId , _ nested: bool ; visit_use_tree, walk_use_tree}
300
298
301
299
/// This method is a hack to workaround unstable of `stmt_expr_attributes`.
302
300
/// It can be removed once that feature is stabilized.
@@ -353,6 +351,7 @@ macro_rules! make_ast_visitor {
353
351
make_visit!{ PathSegment ; visit_path_segment, walk_path_segment}
354
352
make_visit!{ PolyTraitRef ; visit_poly_trait_ref, walk_poly_trait_ref}
355
353
make_visit!{ TraitRef ; visit_trait_ref, walk_trait_ref}
354
+ make_visit!{ UseTree , id: NodeId , _ nested: bool ; visit_use_tree, walk_use_tree}
356
355
make_visit!{ Variant ; visit_variant, walk_variant}
357
356
make_visit!{ VariantData ; visit_variant_data, walk_variant_data}
358
357
make_visit!{ Visibility ; visit_vis, walk_vis}
@@ -721,6 +720,37 @@ macro_rules! make_ast_visitor {
721
720
return_result!( V )
722
721
}
723
722
723
+ pub fn walk_use_tree<$( $lt, ) ? V : $trait$( <$lt>) ?>(
724
+ vis: & mut V ,
725
+ use_tree: ref_t!( UseTree ) ,
726
+ id: NodeId ,
727
+ ) -> result!( V ) {
728
+ let UseTree { prefix, kind, span } = use_tree;
729
+ // TODO: Remove this after unifying visit_path
730
+ try_v!( macro_if!{ $( $mut) ? { {
731
+ let _ = id;
732
+ vis. visit_path( prefix)
733
+ } } else {
734
+ vis. visit_path( prefix, id)
735
+ } } ) ;
736
+ match kind {
737
+ UseTreeKind :: Simple ( rename) => {
738
+ // The extra IDs are handled during AST lowering.
739
+ visit_o!( rename, |rename: ref_t!( Ident ) | vis. visit_ident( rename) ) ;
740
+ }
741
+ UseTreeKind :: Nested { items, span } => {
742
+ for ( tree, id) in items {
743
+ try_v!( visit_id!( vis, id) ) ;
744
+ vis. visit_use_tree( tree, * id, true ) ;
745
+ }
746
+ try_v!( visit_span!( vis, span) ) ;
747
+ }
748
+ UseTreeKind :: Glob => { }
749
+ }
750
+ try_v!( visit_span!( vis, span) ) ;
751
+ return_result!( V )
752
+ }
753
+
724
754
pub fn walk_variant<$( $lt, ) ? V : $trait$( <$lt>) ?>(
725
755
visitor: & mut V ,
726
756
variant: ref_t!( Variant )
@@ -1102,28 +1132,6 @@ pub mod visit {
1102
1132
V :: Result :: output ( )
1103
1133
}
1104
1134
1105
- pub fn walk_use_tree < ' a , V : Visitor < ' a > > (
1106
- visitor : & mut V ,
1107
- use_tree : & ' a UseTree ,
1108
- id : NodeId ,
1109
- ) -> V :: Result {
1110
- let UseTree { prefix, kind, span : _ } = use_tree;
1111
- try_visit ! ( visitor. visit_path( prefix, id) ) ;
1112
- match kind {
1113
- UseTreeKind :: Simple ( rename) => {
1114
- // The extra IDs are handled during AST lowering.
1115
- visit_opt ! ( visitor, visit_ident, rename) ;
1116
- }
1117
- UseTreeKind :: Glob => { }
1118
- UseTreeKind :: Nested { ref items, span : _ } => {
1119
- for & ( ref nested_tree, nested_id) in items {
1120
- try_visit ! ( visitor. visit_use_tree( nested_tree, nested_id, true ) ) ;
1121
- }
1122
- }
1123
- }
1124
- V :: Result :: output ( )
1125
- }
1126
-
1127
1135
pub fn walk_generic_arg < ' a , V > ( visitor : & mut V , generic_arg : & ' a GenericArg ) -> V :: Result
1128
1136
where
1129
1137
V : Visitor < ' a > ,
@@ -1749,23 +1757,6 @@ pub mod mut_visit {
1749
1757
smallvec ! [ fp]
1750
1758
}
1751
1759
1752
- fn walk_use_tree < T : MutVisitor > ( vis : & mut T , use_tree : & mut UseTree ) {
1753
- let UseTree { prefix, kind, span } = use_tree;
1754
- vis. visit_path ( prefix) ;
1755
- match kind {
1756
- UseTreeKind :: Simple ( rename) => visit_opt ( rename, |rename| vis. visit_ident ( rename) ) ,
1757
- UseTreeKind :: Nested { items, span } => {
1758
- for ( tree, id) in items {
1759
- vis. visit_id ( id) ;
1760
- vis. visit_use_tree ( tree) ;
1761
- }
1762
- vis. visit_span ( span) ;
1763
- }
1764
- UseTreeKind :: Glob => { }
1765
- }
1766
- vis. visit_span ( span) ;
1767
- }
1768
-
1769
1760
pub fn walk_flat_map_arm < T : MutVisitor > ( vis : & mut T , mut arm : Arm ) -> SmallVec < [ Arm ; 1 ] > {
1770
1761
vis. visit_arm ( & mut arm) ;
1771
1762
smallvec ! [ arm]
@@ -2240,7 +2231,7 @@ pub mod mut_visit {
2240
2231
fn walk ( & mut self , span : Span , id : NodeId , vis : & mut impl MutVisitor ) {
2241
2232
match self {
2242
2233
ItemKind :: ExternCrate ( _orig_name) => { }
2243
- ItemKind :: Use ( use_tree) => vis. visit_use_tree ( use_tree) ,
2234
+ ItemKind :: Use ( use_tree) => vis. visit_use_tree ( use_tree, id , false ) ,
2244
2235
ItemKind :: Static ( box StaticItem { ty, safety : _, mutability : _, expr } ) => {
2245
2236
vis. visit_ty ( ty) ;
2246
2237
visit_opt ( expr, |expr| vis. visit_expr ( expr) ) ;
0 commit comments