@@ -40,12 +40,6 @@ pub trait MutVisitor: Sized {
4040 // fn flat_map_t(&mut self, t: T) -> SmallVec<[T; 1]>; // rare
4141 // fn filter_map_t(&mut self, t: T) -> Option<T>; // rarest
4242 //
43- // Any additions to this trait should happen in form of a call to a public
44- // `noop_*` function that only calls out to the visitor again, not other
45- // `noop_*` functions. This is a necessary API workaround to the problem of
46- // not being able to call out to the super default method in an overridden
47- // default method.
48- //
4943 // When writing these methods, it is better to use destructuring like this:
5044 //
5145 // fn visit_abc(&mut self, ABC { a, b, c: _ }: &mut ABC) {
@@ -179,7 +173,7 @@ pub trait MutVisitor: Sized {
179173 }
180174
181175 fn filter_map_expr ( & mut self , e : P < Expr > ) -> Option < P < Expr > > {
182- noop_filter_map_expr ( self , e)
176+ walk_filter_map_expr ( self , e)
183177 }
184178
185179 fn visit_generic_arg ( & mut self , arg : & mut GenericArg ) {
@@ -381,14 +375,11 @@ super::common_visitor_and_walkers!((mut) MutVisitor);
381375/// Use a map-style function (`FnOnce(T) -> T`) to overwrite a `&mut T`. Useful
382376/// when using a `flat_map_*` or `filter_map_*` method within a `visit_`
383377/// method.
384- //
385- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
386378pub fn visit_clobber < T : DummyAstNode > ( t : & mut T , f : impl FnOnce ( T ) -> T ) {
387379 let old_t = std:: mem:: replace ( t, T :: dummy ( ) ) ;
388380 * t = f ( old_t) ;
389381}
390382
391- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
392383#[ inline]
393384fn visit_vec < T , F > ( elems : & mut Vec < T > , mut visit_elem : F )
394385where
@@ -399,7 +390,6 @@ where
399390 }
400391}
401392
402- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
403393#[ inline]
404394fn visit_thin_vec < T , F > ( elems : & mut ThinVec < T > , mut visit_elem : F )
405395where
@@ -410,7 +400,6 @@ where
410400 }
411401}
412402
413- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
414403#[ inline]
415404fn visit_opt < T , F > ( opt : & mut Option < T > , mut visit_elem : F )
416405where
@@ -421,25 +410,21 @@ where
421410 }
422411}
423412
424- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
425413fn visit_attrs < T : MutVisitor > ( vis : & mut T , attrs : & mut AttrVec ) {
426414 for attr in attrs. iter_mut ( ) {
427415 vis. visit_attribute ( attr) ;
428416 }
429417}
430418
431- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
432419#[ allow( unused) ]
433420fn visit_exprs < T : MutVisitor > ( vis : & mut T , exprs : & mut Vec < P < Expr > > ) {
434421 exprs. flat_map_in_place ( |expr| vis. filter_map_expr ( expr) )
435422}
436423
437- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
438424fn visit_thin_exprs < T : MutVisitor > ( vis : & mut T , exprs : & mut ThinVec < P < Expr > > ) {
439425 exprs. flat_map_in_place ( |expr| vis. filter_map_expr ( expr) )
440426}
441427
442- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
443428fn visit_attr_args < T : MutVisitor > ( vis : & mut T , args : & mut AttrArgs ) {
444429 match args {
445430 AttrArgs :: Empty => { }
@@ -451,7 +436,6 @@ fn visit_attr_args<T: MutVisitor>(vis: &mut T, args: &mut AttrArgs) {
451436 }
452437}
453438
454- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
455439fn visit_delim_args < T : MutVisitor > ( vis : & mut T , args : & mut DelimArgs ) {
456440 let DelimArgs { dspan, delim : _, tokens : _ } = args;
457441 let DelimSpan { open, close } = dspan;
@@ -1500,11 +1484,9 @@ pub fn walk_expr<T: MutVisitor>(vis: &mut T, Expr { kind, id, span, attrs, token
15001484 vis. visit_span ( span) ;
15011485}
15021486
1503- pub fn noop_filter_map_expr < T : MutVisitor > ( vis : & mut T , mut e : P < Expr > ) -> Option < P < Expr > > {
1504- Some ( {
1505- vis. visit_expr ( & mut e) ;
1506- e
1507- } )
1487+ pub fn walk_filter_map_expr < T : MutVisitor > ( vis : & mut T , mut e : P < Expr > ) -> Option < P < Expr > > {
1488+ vis. visit_expr ( & mut e) ;
1489+ Some ( e)
15081490}
15091491
15101492pub fn walk_flat_map_stmt < T : MutVisitor > (
0 commit comments