@@ -52,12 +52,6 @@ pub trait MutVisitor: Sized {
52
52
// fn flat_map_t(&mut self, t: T) -> SmallVec<[T; 1]>; // rare
53
53
// fn filter_map_t(&mut self, t: T) -> Option<T>; // rarest
54
54
//
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
- //
61
55
// When writing these methods, it is better to use destructuring like this:
62
56
//
63
57
// fn visit_abc(&mut self, ABC { a, b, c: _ }: &mut ABC) {
@@ -191,7 +185,7 @@ pub trait MutVisitor: Sized {
191
185
}
192
186
193
187
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)
195
189
}
196
190
197
191
fn visit_generic_arg ( & mut self , arg : & mut GenericArg ) {
@@ -393,14 +387,11 @@ super::common_visitor_and_walkers!((mut) MutVisitor);
393
387
/// Use a map-style function (`FnOnce(T) -> T`) to overwrite a `&mut T`. Useful
394
388
/// when using a `flat_map_*` or `filter_map_*` method within a `visit_`
395
389
/// method.
396
- //
397
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
398
390
pub fn visit_clobber < T : DummyAstNode > ( t : & mut T , f : impl FnOnce ( T ) -> T ) {
399
391
let old_t = std:: mem:: replace ( t, T :: dummy ( ) ) ;
400
392
* t = f ( old_t) ;
401
393
}
402
394
403
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
404
395
#[ inline]
405
396
fn visit_vec < T , F > ( elems : & mut Vec < T > , mut visit_elem : F )
406
397
where
@@ -411,7 +402,6 @@ where
411
402
}
412
403
}
413
404
414
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
415
405
#[ inline]
416
406
fn visit_thin_vec < T , F > ( elems : & mut ThinVec < T > , mut visit_elem : F )
417
407
where
@@ -422,7 +412,6 @@ where
422
412
}
423
413
}
424
414
425
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
426
415
#[ inline]
427
416
fn visit_opt < T , F > ( opt : & mut Option < T > , mut visit_elem : F )
428
417
where
@@ -433,30 +422,25 @@ where
433
422
}
434
423
}
435
424
436
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
437
425
fn visit_attrs < T : MutVisitor > ( vis : & mut T , attrs : & mut AttrVec ) {
438
426
for attr in attrs. iter_mut ( ) {
439
427
vis. visit_attribute ( attr) ;
440
428
}
441
429
}
442
430
443
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
444
431
#[ allow( unused) ]
445
432
fn visit_exprs < T : MutVisitor > ( vis : & mut T , exprs : & mut Vec < P < Expr > > ) {
446
433
exprs. flat_map_in_place ( |expr| vis. filter_map_expr ( expr) )
447
434
}
448
435
449
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
450
436
fn visit_thin_exprs < T : MutVisitor > ( vis : & mut T , exprs : & mut ThinVec < P < Expr > > ) {
451
437
exprs. flat_map_in_place ( |expr| vis. filter_map_expr ( expr) )
452
438
}
453
439
454
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
455
440
fn visit_bounds < T : MutVisitor > ( vis : & mut T , bounds : & mut GenericBounds , ctxt : BoundKind ) {
456
441
visit_vec ( bounds, |bound| vis. visit_param_bound ( bound, ctxt) ) ;
457
442
}
458
443
459
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
460
444
fn visit_attr_args < T : MutVisitor > ( vis : & mut T , args : & mut AttrArgs ) {
461
445
match args {
462
446
AttrArgs :: Empty => { }
@@ -468,7 +452,6 @@ fn visit_attr_args<T: MutVisitor>(vis: &mut T, args: &mut AttrArgs) {
468
452
}
469
453
}
470
454
471
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
472
455
fn visit_delim_args < T : MutVisitor > ( vis : & mut T , args : & mut DelimArgs ) {
473
456
let DelimArgs { dspan, delim : _, tokens : _ } = args;
474
457
let DelimSpan { open, close } = dspan;
@@ -771,15 +754,13 @@ pub fn walk_flat_map_param<T: MutVisitor>(vis: &mut T, mut param: Param) -> Smal
771
754
smallvec ! [ param]
772
755
}
773
756
774
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
775
757
fn visit_defaultness < T : MutVisitor > ( vis : & mut T , defaultness : & mut Defaultness ) {
776
758
match defaultness {
777
759
Defaultness :: Default ( span) => vis. visit_span ( span) ,
778
760
Defaultness :: Final => { }
779
761
}
780
762
}
781
763
782
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
783
764
fn visit_polarity < T : MutVisitor > ( vis : & mut T , polarity : & mut ImplPolarity ) {
784
765
match polarity {
785
766
ImplPolarity :: Positive => { }
@@ -1716,11 +1697,9 @@ pub fn walk_expr<T: MutVisitor>(vis: &mut T, Expr { kind, id, span, attrs, token
1716
1697
vis. visit_span ( span) ;
1717
1698
}
1718
1699
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)
1724
1703
}
1725
1704
1726
1705
pub fn walk_flat_map_stmt < T : MutVisitor > (
0 commit comments