Skip to content

Commit 4360fac

Browse files
committed
Remove out-of-date noop_* names.
`mut_visit.rs` has a single mfunction with a `noop_` prefix: `noop_filter_map_expr`. This commit renames as `walk_filter_map_expr` which is consistent with other functions in this file. The commit also removes out-of-date comments that refer to `noop_*` methods.
1 parent b8c6b0f commit 4360fac

File tree

2 files changed

+3
-22
lines changed

2 files changed

+3
-22
lines changed

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ pub trait MutVisitor: Sized {
5252
// fn filter_map_t(&mut self, t: T) -> Option<T>;
5353
// fn flat_map_t(&mut self, t: T) -> SmallVec<[T; 1]>;
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,8 +387,6 @@ 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`.
398390
pub 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);
@@ -405,7 +397,6 @@ pub fn visit_clobber_opt<T>(t: &mut Option<T>, f: impl FnOnce(T) -> Option<T>) {
405397
*t = old_t.and_then(|new_t| f(new_t));
406398
}
407399

408-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
409400
#[inline]
410401
fn visit_vec<T, F>(elems: &mut Vec<T>, mut visit_elem: F)
411402
where
@@ -416,7 +407,6 @@ where
416407
}
417408
}
418409

419-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
420410
#[inline]
421411
fn visit_thin_vec<T, F>(elems: &mut ThinVec<T>, mut visit_elem: F)
422412
where
@@ -427,7 +417,6 @@ where
427417
}
428418
}
429419

430-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
431420
#[inline]
432421
fn visit_opt<T, F>(opt: &mut Option<T>, mut visit_elem: F)
433422
where
@@ -438,30 +427,25 @@ where
438427
}
439428
}
440429

441-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
442430
fn visit_attrs<T: MutVisitor>(vis: &mut T, attrs: &mut AttrVec) {
443431
for attr in attrs.iter_mut() {
444432
vis.visit_attribute(attr);
445433
}
446434
}
447435

448-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
449436
#[allow(unused)]
450437
fn visit_exprs<T: MutVisitor>(vis: &mut T, exprs: &mut Vec<P<Expr>>) {
451438
exprs.flat_map_in_place(|expr| vis.filter_map_expr(expr))
452439
}
453440

454-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
455441
fn visit_thin_exprs<T: MutVisitor>(vis: &mut T, exprs: &mut ThinVec<P<Expr>>) {
456442
exprs.flat_map_in_place(|expr| vis.filter_map_expr(expr))
457443
}
458444

459-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
460445
fn visit_bounds<T: MutVisitor>(vis: &mut T, bounds: &mut GenericBounds, ctxt: BoundKind) {
461446
visit_vec(bounds, |bound| vis.visit_param_bound(bound, ctxt));
462447
}
463448

464-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
465449
fn visit_attr_args<T: MutVisitor>(vis: &mut T, args: &mut AttrArgs) {
466450
match args {
467451
AttrArgs::Empty => {}
@@ -473,7 +457,6 @@ fn visit_attr_args<T: MutVisitor>(vis: &mut T, args: &mut AttrArgs) {
473457
}
474458
}
475459

476-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
477460
fn visit_delim_args<T: MutVisitor>(vis: &mut T, args: &mut DelimArgs) {
478461
let DelimArgs { dspan, delim: _, tokens: _ } = args;
479462
let DelimSpan { open, close } = dspan;
@@ -773,15 +756,13 @@ pub fn walk_filter_map_param<T: MutVisitor>(vis: &mut T, mut param: Param) -> Op
773756
Some(param)
774757
}
775758

776-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
777759
fn visit_defaultness<T: MutVisitor>(vis: &mut T, defaultness: &mut Defaultness) {
778760
match defaultness {
779761
Defaultness::Default(span) => vis.visit_span(span),
780762
Defaultness::Final => {}
781763
}
782764
}
783765

784-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
785766
fn visit_polarity<T: MutVisitor>(vis: &mut T, polarity: &mut ImplPolarity) {
786767
match polarity {
787768
ImplPolarity::Positive => {}
@@ -1715,7 +1696,7 @@ pub fn walk_expr<T: MutVisitor>(vis: &mut T, Expr { kind, id, span, attrs, token
17151696
vis.visit_span(span);
17161697
}
17171698

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>> {
17191700
vis.visit_expr(&mut e);
17201701
Some(e)
17211702
}

compiler/rustc_expand/src/placeholders.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ impl MutVisitor for PlaceholderExpander {
342342
fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
343343
match expr.kind {
344344
ast::ExprKind::MacCall(_) => self.remove(expr.id).make_opt_expr(),
345-
_ => noop_filter_map_expr(self, expr),
345+
_ => walk_filter_map_expr(self, expr),
346346
}
347347
}
348348

0 commit comments

Comments
 (0)