@@ -40,12 +40,6 @@ pub trait MutVisitor: Sized {
40
40
// fn flat_map_t(&mut self, t: T) -> SmallVec<[T; 1]>; // rare
41
41
// fn filter_map_t(&mut self, t: T) -> Option<T>; // rarest
42
42
//
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
- //
49
43
// When writing these methods, it is better to use destructuring like this:
50
44
//
51
45
// fn visit_abc(&mut self, ABC { a, b, c: _ }: &mut ABC) {
@@ -179,7 +173,7 @@ pub trait MutVisitor: Sized {
179
173
}
180
174
181
175
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)
183
177
}
184
178
185
179
fn visit_generic_arg ( & mut self , arg : & mut GenericArg ) {
@@ -381,14 +375,11 @@ super::common_visitor_and_walkers!((mut) MutVisitor);
381
375
/// Use a map-style function (`FnOnce(T) -> T`) to overwrite a `&mut T`. Useful
382
376
/// when using a `flat_map_*` or `filter_map_*` method within a `visit_`
383
377
/// method.
384
- //
385
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
386
378
pub fn visit_clobber < T : DummyAstNode > ( t : & mut T , f : impl FnOnce ( T ) -> T ) {
387
379
let old_t = std:: mem:: replace ( t, T :: dummy ( ) ) ;
388
380
* t = f ( old_t) ;
389
381
}
390
382
391
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
392
383
#[ inline]
393
384
fn visit_vec < T , F > ( elems : & mut Vec < T > , mut visit_elem : F )
394
385
where
@@ -399,7 +390,6 @@ where
399
390
}
400
391
}
401
392
402
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
403
393
#[ inline]
404
394
fn visit_thin_vec < T , F > ( elems : & mut ThinVec < T > , mut visit_elem : F )
405
395
where
@@ -410,7 +400,6 @@ where
410
400
}
411
401
}
412
402
413
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
414
403
#[ inline]
415
404
fn visit_opt < T , F > ( opt : & mut Option < T > , mut visit_elem : F )
416
405
where
@@ -421,25 +410,21 @@ where
421
410
}
422
411
}
423
412
424
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
425
413
fn visit_attrs < T : MutVisitor > ( vis : & mut T , attrs : & mut AttrVec ) {
426
414
for attr in attrs. iter_mut ( ) {
427
415
vis. visit_attribute ( attr) ;
428
416
}
429
417
}
430
418
431
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
432
419
#[ allow( unused) ]
433
420
fn visit_exprs < T : MutVisitor > ( vis : & mut T , exprs : & mut Vec < P < Expr > > ) {
434
421
exprs. flat_map_in_place ( |expr| vis. filter_map_expr ( expr) )
435
422
}
436
423
437
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
438
424
fn visit_thin_exprs < T : MutVisitor > ( vis : & mut T , exprs : & mut ThinVec < P < Expr > > ) {
439
425
exprs. flat_map_in_place ( |expr| vis. filter_map_expr ( expr) )
440
426
}
441
427
442
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
443
428
fn visit_attr_args < T : MutVisitor > ( vis : & mut T , args : & mut AttrArgs ) {
444
429
match args {
445
430
AttrArgs :: Empty => { }
@@ -451,7 +436,6 @@ fn visit_attr_args<T: MutVisitor>(vis: &mut T, args: &mut AttrArgs) {
451
436
}
452
437
}
453
438
454
- // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
455
439
fn visit_delim_args < T : MutVisitor > ( vis : & mut T , args : & mut DelimArgs ) {
456
440
let DelimArgs { dspan, delim : _, tokens : _ } = args;
457
441
let DelimSpan { open, close } = dspan;
@@ -1500,11 +1484,9 @@ pub fn walk_expr<T: MutVisitor>(vis: &mut T, Expr { kind, id, span, attrs, token
1500
1484
vis. visit_span ( span) ;
1501
1485
}
1502
1486
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)
1508
1490
}
1509
1491
1510
1492
pub fn walk_flat_map_stmt < T : MutVisitor > (
0 commit comments