@@ -52,12 +52,6 @@ pub trait MutVisitor: Sized {
5252 // fn flat_map_t(&mut self, t: T) -> SmallVec<[T; 1]>; // rare
5353 // fn filter_map_t(&mut self, t: T) -> Option<T>; // rarest
5454 //
55- // Any additions to this trait should happen in form of a call to a public
56- // `noop_*` function that only calls out to the visitor again, not other
57- // `noop_*` functions. This is a necessary API workaround to the problem of
58- // not being able to call out to the super default method in an overridden
59- // default method.
60- //
6155 // When writing these methods, it is better to use destructuring like this:
6256 //
6357 // fn visit_abc(&mut self, ABC { a, b, c: _ }: &mut ABC) {
@@ -191,7 +185,7 @@ pub trait MutVisitor: Sized {
191185 }
192186
193187 fn filter_map_expr ( & mut self , e : P < Expr > ) -> Option < P < Expr > > {
194- noop_filter_map_expr ( self , e)
188+ walk_filter_map_expr ( self , e)
195189 }
196190
197191 fn visit_generic_arg ( & mut self , arg : & mut GenericArg ) {
@@ -393,14 +387,11 @@ super::common_visitor_and_walkers!((mut) MutVisitor);
393387/// Use a map-style function (`FnOnce(T) -> T`) to overwrite a `&mut T`. Useful
394388/// when using a `flat_map_*` or `filter_map_*` method within a `visit_`
395389/// method.
396- //
397- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
398390pub fn visit_clobber < T : DummyAstNode > ( t : & mut T , f : impl FnOnce ( T ) -> T ) {
399391 let old_t = std:: mem:: replace ( t, T :: dummy ( ) ) ;
400392 * t = f ( old_t) ;
401393}
402394
403- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
404395#[ inline]
405396fn visit_vec < T , F > ( elems : & mut Vec < T > , mut visit_elem : F )
406397where
@@ -411,7 +402,6 @@ where
411402 }
412403}
413404
414- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
415405#[ inline]
416406fn visit_thin_vec < T , F > ( elems : & mut ThinVec < T > , mut visit_elem : F )
417407where
@@ -422,7 +412,6 @@ where
422412 }
423413}
424414
425- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
426415#[ inline]
427416fn visit_opt < T , F > ( opt : & mut Option < T > , mut visit_elem : F )
428417where
@@ -433,30 +422,25 @@ where
433422 }
434423}
435424
436- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
437425fn visit_attrs < T : MutVisitor > ( vis : & mut T , attrs : & mut AttrVec ) {
438426 for attr in attrs. iter_mut ( ) {
439427 vis. visit_attribute ( attr) ;
440428 }
441429}
442430
443- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
444431#[ allow( unused) ]
445432fn visit_exprs < T : MutVisitor > ( vis : & mut T , exprs : & mut Vec < P < Expr > > ) {
446433 exprs. flat_map_in_place ( |expr| vis. filter_map_expr ( expr) )
447434}
448435
449- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
450436fn visit_thin_exprs < T : MutVisitor > ( vis : & mut T , exprs : & mut ThinVec < P < Expr > > ) {
451437 exprs. flat_map_in_place ( |expr| vis. filter_map_expr ( expr) )
452438}
453439
454- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
455440fn visit_bounds < T : MutVisitor > ( vis : & mut T , bounds : & mut GenericBounds , ctxt : BoundKind ) {
456441 visit_vec ( bounds, |bound| vis. visit_param_bound ( bound, ctxt) ) ;
457442}
458443
459- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
460444fn visit_attr_args < T : MutVisitor > ( vis : & mut T , args : & mut AttrArgs ) {
461445 match args {
462446 AttrArgs :: Empty => { }
@@ -468,7 +452,6 @@ fn visit_attr_args<T: MutVisitor>(vis: &mut T, args: &mut AttrArgs) {
468452 }
469453}
470454
471- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
472455fn visit_delim_args < T : MutVisitor > ( vis : & mut T , args : & mut DelimArgs ) {
473456 let DelimArgs { dspan, delim : _, tokens : _ } = args;
474457 let DelimSpan { open, close } = dspan;
@@ -771,15 +754,13 @@ pub fn walk_flat_map_param<T: MutVisitor>(vis: &mut T, mut param: Param) -> Smal
771754 smallvec ! [ param]
772755}
773756
774- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
775757fn visit_defaultness < T : MutVisitor > ( vis : & mut T , defaultness : & mut Defaultness ) {
776758 match defaultness {
777759 Defaultness :: Default ( span) => vis. visit_span ( span) ,
778760 Defaultness :: Final => { }
779761 }
780762}
781763
782- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
783764fn visit_polarity < T : MutVisitor > ( vis : & mut T , polarity : & mut ImplPolarity ) {
784765 match polarity {
785766 ImplPolarity :: Positive => { }
@@ -1716,11 +1697,9 @@ pub fn walk_expr<T: MutVisitor>(vis: &mut T, Expr { kind, id, span, attrs, token
17161697 vis. visit_span ( span) ;
17171698}
17181699
1719- pub fn noop_filter_map_expr < T : MutVisitor > ( vis : & mut T , mut e : P < Expr > ) -> Option < P < Expr > > {
1720- Some ( {
1721- vis. visit_expr ( & mut e) ;
1722- e
1723- } )
1700+ pub fn walk_filter_map_expr < T : MutVisitor > ( vis : & mut T , mut e : P < Expr > ) -> Option < P < Expr > > {
1701+ vis. visit_expr ( & mut e) ;
1702+ Some ( e)
17241703}
17251704
17261705pub fn walk_flat_map_stmt < T : MutVisitor > (
0 commit comments