@@ -1771,6 +1771,38 @@ macro_rules! make_ast_visitor {
1771
1771
}
1772
1772
return_result!( V )
1773
1773
}
1774
+
1775
+ macro_if!{ $( $mut) ? {
1776
+ macro_rules! make_walk_flat_map {
1777
+ (
1778
+ $ty: ty
1779
+ $$( , $arg: ident : $arg_ty: ty) * ;
1780
+ $walk_flat_map: ident,
1781
+ $visit: ident
1782
+ ) => {
1783
+ pub fn $walk_flat_map(
1784
+ vis: & mut impl $trait$( <$lt>) ?,
1785
+ mut arg: $ty
1786
+ $$( , $arg: $arg_ty) *
1787
+ ) -> SmallVec <[ $ty; 1 ] > {
1788
+ vis. $visit( & mut arg $$( , $arg) * ) ;
1789
+ smallvec![ arg]
1790
+ }
1791
+ }
1792
+ }
1793
+
1794
+ make_walk_flat_map!{ Arm ; walk_flat_map_arm, visit_arm}
1795
+ make_walk_flat_map!{ ExprField ; walk_flat_map_expr_field, visit_expr_field}
1796
+ make_walk_flat_map!{ FieldDef ; walk_flat_map_field_def, visit_field_def}
1797
+ make_walk_flat_map!{ GenericParam ; walk_flat_map_generic_param, visit_generic_param}
1798
+ make_walk_flat_map!{ Param ; walk_flat_map_param, visit_param}
1799
+ make_walk_flat_map!{ PatField ; walk_flat_map_pat_field, visit_pat_field}
1800
+ make_walk_flat_map!{ Variant ; walk_flat_map_variant, visit_variant}
1801
+
1802
+ make_walk_flat_map!{ P <Item >; walk_flat_map_item, visit_item}
1803
+ make_walk_flat_map!{ P <AssocItem >, ctxt: AssocCtxt ; walk_flat_map_assoc_item, visit_assoc_item}
1804
+ make_walk_flat_map!{ P <ForeignItem >; walk_flat_map_foreign_item, visit_foreign_item}
1805
+ } }
1774
1806
}
1775
1807
}
1776
1808
@@ -1979,27 +2011,6 @@ pub mod mut_visit {
1979
2011
vis. visit_span ( close) ;
1980
2012
}
1981
2013
1982
- pub fn walk_flat_map_pat_field < T : MutVisitor > (
1983
- vis : & mut T ,
1984
- mut fp : PatField ,
1985
- ) -> SmallVec < [ PatField ; 1 ] > {
1986
- vis. visit_pat_field ( & mut fp) ;
1987
- smallvec ! [ fp]
1988
- }
1989
-
1990
- pub fn walk_flat_map_arm < T : MutVisitor > ( vis : & mut T , mut arm : Arm ) -> SmallVec < [ Arm ; 1 ] > {
1991
- vis. visit_arm ( & mut arm) ;
1992
- smallvec ! [ arm]
1993
- }
1994
-
1995
- pub fn walk_flat_map_variant < T : MutVisitor > (
1996
- visitor : & mut T ,
1997
- mut variant : Variant ,
1998
- ) -> SmallVec < [ Variant ; 1 ] > {
1999
- visitor. visit_variant ( & mut variant) ;
2000
- smallvec ! [ variant]
2001
- }
2002
-
2003
2014
fn walk_meta_list_item < T : MutVisitor > ( vis : & mut T , li : & mut MetaItemInner ) {
2004
2015
match li {
2005
2016
MetaItemInner :: MetaItem ( mi) => vis. visit_meta_item ( mi) ,
@@ -2017,14 +2028,6 @@ pub mod mut_visit {
2017
2028
vis. visit_span ( span) ;
2018
2029
}
2019
2030
2020
- pub fn walk_flat_map_param < T : MutVisitor > (
2021
- vis : & mut T ,
2022
- mut param : Param ,
2023
- ) -> SmallVec < [ Param ; 1 ] > {
2024
- vis. visit_param ( & mut param) ;
2025
- smallvec ! [ param]
2026
- }
2027
-
2028
2031
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
2029
2032
fn visit_attr_tt < T : MutVisitor > ( vis : & mut T , tt : & mut AttrTokenTree ) {
2030
2033
match tt {
@@ -2171,61 +2174,10 @@ pub mod mut_visit {
2171
2174
}
2172
2175
}
2173
2176
2174
- pub fn walk_flat_map_generic_param < T : MutVisitor > (
2175
- vis : & mut T ,
2176
- mut param : GenericParam ,
2177
- ) -> SmallVec < [ GenericParam ; 1 ] > {
2178
- vis. visit_generic_param ( & mut param) ;
2179
- smallvec ! [ param]
2180
- }
2181
-
2182
- pub fn walk_flat_map_field_def < T : MutVisitor > (
2183
- visitor : & mut T ,
2184
- mut fd : FieldDef ,
2185
- ) -> SmallVec < [ FieldDef ; 1 ] > {
2186
- visitor. visit_field_def ( & mut fd) ;
2187
- smallvec ! [ fd]
2188
- }
2189
-
2190
- pub fn walk_flat_map_expr_field < T : MutVisitor > (
2191
- vis : & mut T ,
2192
- mut f : ExprField ,
2193
- ) -> SmallVec < [ ExprField ; 1 ] > {
2194
- vis. visit_expr_field ( & mut f) ;
2195
- smallvec ! [ f]
2196
- }
2197
-
2198
2177
pub fn walk_item_kind ( item : & mut Item < impl WalkItemKind > , vis : & mut impl MutVisitor ) {
2199
2178
item. kind . walk ( item. id , item. span , & mut item. vis , & mut item. ident , vis)
2200
2179
}
2201
2180
2202
- /// Mutates one item, returning the item again.
2203
- pub fn walk_flat_map_item (
2204
- vis : & mut impl MutVisitor ,
2205
- mut item : P < Item > ,
2206
- ) -> SmallVec < [ P < Item > ; 1 ] > {
2207
- vis. visit_item ( & mut item) ;
2208
- smallvec ! [ item]
2209
- }
2210
-
2211
- pub fn walk_flat_map_foreign_item (
2212
- vis : & mut impl MutVisitor ,
2213
- mut item : P < ForeignItem > ,
2214
- ) -> SmallVec < [ P < ForeignItem > ; 1 ] > {
2215
- vis. visit_foreign_item ( & mut item) ;
2216
- smallvec ! [ item]
2217
- }
2218
-
2219
- /// Mutates one item, returning the item again.
2220
- pub fn walk_flat_map_assoc_item (
2221
- vis : & mut impl MutVisitor ,
2222
- mut item : P < AssocItem > ,
2223
- ctxt : AssocCtxt ,
2224
- ) -> SmallVec < [ P < AssocItem > ; 1 ] > {
2225
- vis. visit_assoc_item ( & mut item, ctxt) ;
2226
- smallvec ! [ item]
2227
- }
2228
-
2229
2181
pub fn noop_filter_map_expr < T : MutVisitor > ( vis : & mut T , mut e : P < Expr > ) -> Option < P < Expr > > {
2230
2182
Some ( {
2231
2183
vis. visit_expr ( & mut e) ;
0 commit comments