Skip to content

Commit 1a29427

Browse files
committed
Remove out-of-date noop_* names.
`mut_visit.rs` has a single function 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 283db70 commit 1a29427

File tree

2 files changed

+5
-26
lines changed

2 files changed

+5
-26
lines changed

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ pub trait MutVisitor: Sized {
5252
// fn flat_map_t(&mut self, t: T) -> SmallVec<[T; 1]>; // rare
5353
// fn filter_map_t(&mut self, t: T) -> Option<T>; // rarest
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,14 +387,11 @@ 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);
401393
}
402394

403-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
404395
#[inline]
405396
fn visit_vec<T, F>(elems: &mut Vec<T>, mut visit_elem: F)
406397
where
@@ -411,7 +402,6 @@ where
411402
}
412403
}
413404

414-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
415405
#[inline]
416406
fn visit_thin_vec<T, F>(elems: &mut ThinVec<T>, mut visit_elem: F)
417407
where
@@ -422,7 +412,6 @@ where
422412
}
423413
}
424414

425-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
426415
#[inline]
427416
fn visit_opt<T, F>(opt: &mut Option<T>, mut visit_elem: F)
428417
where
@@ -433,30 +422,25 @@ where
433422
}
434423
}
435424

436-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
437425
fn visit_attrs<T: MutVisitor>(vis: &mut T, attrs: &mut AttrVec) {
438426
for attr in attrs.iter_mut() {
439427
vis.visit_attribute(attr);
440428
}
441429
}
442430

443-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
444431
#[allow(unused)]
445432
fn visit_exprs<T: MutVisitor>(vis: &mut T, exprs: &mut Vec<P<Expr>>) {
446433
exprs.flat_map_in_place(|expr| vis.filter_map_expr(expr))
447434
}
448435

449-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
450436
fn visit_thin_exprs<T: MutVisitor>(vis: &mut T, exprs: &mut ThinVec<P<Expr>>) {
451437
exprs.flat_map_in_place(|expr| vis.filter_map_expr(expr))
452438
}
453439

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

459-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
460444
fn visit_attr_args<T: MutVisitor>(vis: &mut T, args: &mut AttrArgs) {
461445
match args {
462446
AttrArgs::Empty => {}
@@ -468,7 +452,6 @@ fn visit_attr_args<T: MutVisitor>(vis: &mut T, args: &mut AttrArgs) {
468452
}
469453
}
470454

471-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
472455
fn visit_delim_args<T: MutVisitor>(vis: &mut T, args: &mut DelimArgs) {
473456
let DelimArgs { dspan, delim: _, tokens: _ } = args;
474457
let DelimSpan { open, close } = dspan;
@@ -771,15 +754,13 @@ pub fn walk_flat_map_param<T: MutVisitor>(vis: &mut T, mut param: Param) -> Smal
771754
smallvec![param]
772755
}
773756

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

782-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
783764
fn visit_polarity<T: MutVisitor>(vis: &mut T, polarity: &mut ImplPolarity) {
784765
match polarity {
785766
ImplPolarity::Positive => {}
@@ -1716,11 +1697,9 @@ pub fn walk_expr<T: MutVisitor>(vis: &mut T, Expr { kind, id, span, attrs, token
17161697
vis.visit_span(span);
17171698
}
17181699

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)
17241703
}
17251704

17261705
pub fn walk_flat_map_stmt<T: MutVisitor>(

compiler/rustc_expand/src/placeholders.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ impl MutVisitor for PlaceholderExpander {
349349
fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
350350
match expr.kind {
351351
ast::ExprKind::MacCall(_) => self.remove(expr.id).make_opt_expr(),
352-
_ => noop_filter_map_expr(self, expr),
352+
_ => walk_filter_map_expr(self, expr),
353353
}
354354
}
355355

0 commit comments

Comments
 (0)