@@ -52,12 +52,6 @@ pub trait MutVisitor: Sized {
52
52
// fn filter_map_t(&mut self, t: T) -> Option<T>;
53
53
// fn flat_map_t(&mut self, t: T) -> SmallVec<[T; 1]>;
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,8 +387,6 @@ 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) ;
@@ -405,7 +397,6 @@ pub fn visit_clobber_opt<T>(t: &mut Option<T>, f: impl FnOnce(T) -> Option<T>) {
405
397
* t = old_t. and_then ( |new_t| f ( new_t) ) ;
406
398
}
407
399
408
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
409
400
#[ inline]
410
401
fn visit_vec < T , F > ( elems : & mut Vec < T > , mut visit_elem : F )
411
402
where
@@ -416,7 +407,6 @@ where
416
407
}
417
408
}
418
409
419
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
420
410
#[ inline]
421
411
fn visit_thin_vec < T , F > ( elems : & mut ThinVec < T > , mut visit_elem : F )
422
412
where
@@ -427,7 +417,6 @@ where
427
417
}
428
418
}
429
419
430
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
431
420
#[ inline]
432
421
fn visit_opt < T , F > ( opt : & mut Option < T > , mut visit_elem : F )
433
422
where
@@ -438,30 +427,25 @@ where
438
427
}
439
428
}
440
429
441
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
442
430
fn visit_attrs < T : MutVisitor > ( vis : & mut T , attrs : & mut AttrVec ) {
443
431
for attr in attrs. iter_mut ( ) {
444
432
vis. visit_attribute ( attr) ;
445
433
}
446
434
}
447
435
448
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
449
436
#[ allow( unused) ]
450
437
fn visit_exprs < T : MutVisitor > ( vis : & mut T , exprs : & mut Vec < P < Expr > > ) {
451
438
exprs. flat_map_in_place ( |expr| vis. filter_map_expr ( expr) )
452
439
}
453
440
454
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
455
441
fn visit_thin_exprs < T : MutVisitor > ( vis : & mut T , exprs : & mut ThinVec < P < Expr > > ) {
456
442
exprs. flat_map_in_place ( |expr| vis. filter_map_expr ( expr) )
457
443
}
458
444
459
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
460
445
fn visit_bounds < T : MutVisitor > ( vis : & mut T , bounds : & mut GenericBounds , ctxt : BoundKind ) {
461
446
visit_vec ( bounds, |bound| vis. visit_param_bound ( bound, ctxt) ) ;
462
447
}
463
448
464
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
465
449
fn visit_attr_args < T : MutVisitor > ( vis : & mut T , args : & mut AttrArgs ) {
466
450
match args {
467
451
AttrArgs :: Empty => { }
@@ -473,7 +457,6 @@ fn visit_attr_args<T: MutVisitor>(vis: &mut T, args: &mut AttrArgs) {
473
457
}
474
458
}
475
459
476
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
477
460
fn visit_delim_args < T : MutVisitor > ( vis : & mut T , args : & mut DelimArgs ) {
478
461
let DelimArgs { dspan, delim : _, tokens : _ } = args;
479
462
let DelimSpan { open, close } = dspan;
@@ -773,15 +756,13 @@ pub fn walk_filter_map_param<T: MutVisitor>(vis: &mut T, mut param: Param) -> Op
773
756
Some ( param)
774
757
}
775
758
776
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
777
759
fn visit_defaultness < T : MutVisitor > ( vis : & mut T , defaultness : & mut Defaultness ) {
778
760
match defaultness {
779
761
Defaultness :: Default ( span) => vis. visit_span ( span) ,
780
762
Defaultness :: Final => { }
781
763
}
782
764
}
783
765
784
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
785
766
fn visit_polarity < T : MutVisitor > ( vis : & mut T , polarity : & mut ImplPolarity ) {
786
767
match polarity {
787
768
ImplPolarity :: Positive => { }
@@ -1715,7 +1696,7 @@ pub fn walk_expr<T: MutVisitor>(vis: &mut T, Expr { kind, id, span, attrs, token
1715
1696
vis. visit_span ( span) ;
1716
1697
}
1717
1698
1718
- pub fn noop_filter_map_expr < T : MutVisitor > ( vis : & mut T , mut e : P < Expr > ) -> Option < P < Expr > > {
1699
+ pub fn walk_filter_map_expr < T : MutVisitor > ( vis : & mut T , mut e : P < Expr > ) -> Option < P < Expr > > {
1719
1700
vis. visit_expr ( & mut e) ;
1720
1701
Some ( e)
1721
1702
}
0 commit comments