@@ -207,7 +207,6 @@ macro_rules! make_ast_visitor {
207
207
make_visit!{ MetaItemInner ; visit_meta_list_item, walk_meta_list_item}
208
208
make_visit!{ Path ; visit_path, walk_path}
209
209
make_visit!{ PreciseCapturingArg ; visit_precise_capturing_arg, walk_precise_capturing_arg}
210
- make_visit!{ UseTree ; visit_use_tree, walk_use_tree}
211
210
212
211
fn flat_map_foreign_item( & mut self , ni: P <ForeignItem >) -> SmallVec <[ P <ForeignItem >; 1 ] > {
213
212
walk_flat_map_item( self , ni)
@@ -290,7 +289,6 @@ macro_rules! make_ast_visitor {
290
289
make_visit!{ Item ; visit_item, walk_item}
291
290
make_visit!{ Path , _ id: NodeId ; visit_path, walk_path}
292
291
make_visit!{ Stmt ; visit_stmt, walk_stmt}
293
- make_visit!{ UseTree , id: NodeId , _ nested: bool ; visit_use_tree, walk_use_tree}
294
292
295
293
/// This method is a hack to workaround unstable of `stmt_expr_attributes`.
296
294
/// It can be removed once that feature is stabilized.
@@ -347,6 +345,7 @@ macro_rules! make_ast_visitor {
347
345
make_visit!{ PathSegment ; visit_path_segment, walk_path_segment}
348
346
make_visit!{ PolyTraitRef ; visit_poly_trait_ref, walk_poly_trait_ref}
349
347
make_visit!{ TraitRef ; visit_trait_ref, walk_trait_ref}
348
+ make_visit!{ UseTree , id: NodeId , _ nested: bool ; visit_use_tree, walk_use_tree}
350
349
make_visit!{ Variant ; visit_variant, walk_variant}
351
350
make_visit!{ VariantData ; visit_variant_data, walk_variant_data}
352
351
make_visit!{ Visibility ; visit_vis, walk_vis}
@@ -715,6 +714,37 @@ macro_rules! make_ast_visitor {
715
714
return_result!( V )
716
715
}
717
716
717
+ pub fn walk_use_tree<$( $lt, ) ? V : $trait$( <$lt>) ?>(
718
+ vis: & mut V ,
719
+ use_tree: ref_t!( UseTree ) ,
720
+ id: NodeId ,
721
+ ) -> result!( V ) {
722
+ let UseTree { prefix, kind, span } = use_tree;
723
+ // TODO: Remove this after unifying visit_path
724
+ try_v!( macro_if!{ $( $mut) ? { {
725
+ let _ = id;
726
+ vis. visit_path( prefix)
727
+ } } else {
728
+ vis. visit_path( prefix, id)
729
+ } } ) ;
730
+ match kind {
731
+ UseTreeKind :: Simple ( rename) => {
732
+ // The extra IDs are handled during AST lowering.
733
+ visit_o!( rename, |rename: ref_t!( Ident ) | vis. visit_ident( rename) ) ;
734
+ }
735
+ UseTreeKind :: Nested { items, span } => {
736
+ for ( tree, id) in items {
737
+ try_v!( visit_id!( vis, id) ) ;
738
+ vis. visit_use_tree( tree, * id, true ) ;
739
+ }
740
+ try_v!( visit_span!( vis, span) ) ;
741
+ }
742
+ UseTreeKind :: Glob => { }
743
+ }
744
+ try_v!( visit_span!( vis, span) ) ;
745
+ return_result!( V )
746
+ }
747
+
718
748
pub fn walk_variant<$( $lt, ) ? V : $trait$( <$lt>) ?>(
719
749
visitor: & mut V ,
720
750
variant: ref_t!( Variant )
@@ -1096,28 +1126,6 @@ pub mod visit {
1096
1126
V :: Result :: output ( )
1097
1127
}
1098
1128
1099
- pub fn walk_use_tree < ' a , V : Visitor < ' a > > (
1100
- visitor : & mut V ,
1101
- use_tree : & ' a UseTree ,
1102
- id : NodeId ,
1103
- ) -> V :: Result {
1104
- let UseTree { prefix, kind, span : _ } = use_tree;
1105
- try_visit ! ( visitor. visit_path( prefix, id) ) ;
1106
- match kind {
1107
- UseTreeKind :: Simple ( rename) => {
1108
- // The extra IDs are handled during AST lowering.
1109
- visit_opt ! ( visitor, visit_ident, rename) ;
1110
- }
1111
- UseTreeKind :: Glob => { }
1112
- UseTreeKind :: Nested { ref items, span : _ } => {
1113
- for & ( ref nested_tree, nested_id) in items {
1114
- try_visit ! ( visitor. visit_use_tree( nested_tree, nested_id, true ) ) ;
1115
- }
1116
- }
1117
- }
1118
- V :: Result :: output ( )
1119
- }
1120
-
1121
1129
pub fn walk_generic_arg < ' a , V > ( visitor : & mut V , generic_arg : & ' a GenericArg ) -> V :: Result
1122
1130
where
1123
1131
V : Visitor < ' a > ,
@@ -1743,23 +1751,6 @@ pub mod mut_visit {
1743
1751
smallvec ! [ fp]
1744
1752
}
1745
1753
1746
- fn walk_use_tree < T : MutVisitor > ( vis : & mut T , use_tree : & mut UseTree ) {
1747
- let UseTree { prefix, kind, span } = use_tree;
1748
- vis. visit_path ( prefix) ;
1749
- match kind {
1750
- UseTreeKind :: Simple ( rename) => visit_opt ( rename, |rename| vis. visit_ident ( rename) ) ,
1751
- UseTreeKind :: Nested { items, span } => {
1752
- for ( tree, id) in items {
1753
- vis. visit_id ( id) ;
1754
- vis. visit_use_tree ( tree) ;
1755
- }
1756
- vis. visit_span ( span) ;
1757
- }
1758
- UseTreeKind :: Glob => { }
1759
- }
1760
- vis. visit_span ( span) ;
1761
- }
1762
-
1763
1754
pub fn walk_flat_map_arm < T : MutVisitor > ( vis : & mut T , mut arm : Arm ) -> SmallVec < [ Arm ; 1 ] > {
1764
1755
vis. visit_arm ( & mut arm) ;
1765
1756
smallvec ! [ arm]
@@ -2234,7 +2225,7 @@ pub mod mut_visit {
2234
2225
fn walk ( & mut self , span : Span , id : NodeId , vis : & mut impl MutVisitor ) {
2235
2226
match self {
2236
2227
ItemKind :: ExternCrate ( _orig_name) => { }
2237
- ItemKind :: Use ( use_tree) => vis. visit_use_tree ( use_tree) ,
2228
+ ItemKind :: Use ( use_tree) => vis. visit_use_tree ( use_tree, id , false ) ,
2238
2229
ItemKind :: Static ( box StaticItem { ty, safety : _, mutability : _, expr } ) => {
2239
2230
vis. visit_ty ( ty) ;
2240
2231
visit_opt ( expr, |expr| vis. visit_expr ( expr) ) ;
0 commit comments