Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c82fafa

Browse files
committedJul 9, 2024
Sync mut_visit function names with immut visit ones
1 parent e968d08 commit c82fafa

File tree

9 files changed

+232
-258
lines changed

9 files changed

+232
-258
lines changed
 

‎compiler/rustc_ast/src/mut_visit.rs

Lines changed: 126 additions & 146 deletions
Large diffs are not rendered by default.

‎compiler/rustc_builtin_macros/src/cfg_eval.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -212,72 +212,72 @@ impl MutVisitor for CfgEval<'_> {
212212
#[instrument(level = "trace", skip(self))]
213213
fn visit_expr(&mut self, expr: &mut P<ast::Expr>) {
214214
self.0.configure_expr(expr, false);
215-
mut_visit::noop_visit_expr(expr, self);
215+
mut_visit::walk_expr(expr, self);
216216
}
217217

218218
#[instrument(level = "trace", skip(self))]
219219
fn visit_method_receiver_expr(&mut self, expr: &mut P<ast::Expr>) {
220220
self.0.configure_expr(expr, true);
221-
mut_visit::noop_visit_expr(expr, self);
221+
mut_visit::walk_expr(expr, self);
222222
}
223223

224224
fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
225225
let mut expr = configure!(self, expr);
226-
mut_visit::noop_visit_expr(&mut expr, self);
226+
mut_visit::walk_expr(&mut expr, self);
227227
Some(expr)
228228
}
229229

230230
fn flat_map_generic_param(
231231
&mut self,
232232
param: ast::GenericParam,
233233
) -> SmallVec<[ast::GenericParam; 1]> {
234-
mut_visit::noop_flat_map_generic_param(configure!(self, param), self)
234+
mut_visit::walk_generic_param(configure!(self, param), self)
235235
}
236236

237237
fn flat_map_stmt(&mut self, stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> {
238-
mut_visit::noop_flat_map_stmt(configure!(self, stmt), self)
238+
mut_visit::walk_stmt(configure!(self, stmt), self)
239239
}
240240

241241
fn flat_map_item(&mut self, item: P<ast::Item>) -> SmallVec<[P<ast::Item>; 1]> {
242-
mut_visit::noop_flat_map_item(configure!(self, item), None, self)
242+
mut_visit::walk_item(configure!(self, item), None, self)
243243
}
244244

245245
fn flat_map_assoc_item(
246246
&mut self,
247247
item: P<ast::AssocItem>,
248248
ctxt: AssocCtxt,
249249
) -> SmallVec<[P<ast::AssocItem>; 1]> {
250-
mut_visit::noop_flat_map_item(configure!(self, item), Some(ctxt), self)
250+
mut_visit::walk_item(configure!(self, item), Some(ctxt), self)
251251
}
252252

253253
fn flat_map_foreign_item(
254254
&mut self,
255255
foreign_item: P<ast::ForeignItem>,
256256
) -> SmallVec<[P<ast::ForeignItem>; 1]> {
257-
mut_visit::noop_flat_map_item(configure!(self, foreign_item), None, self)
257+
mut_visit::walk_item(configure!(self, foreign_item), None, self)
258258
}
259259

260260
fn flat_map_arm(&mut self, arm: ast::Arm) -> SmallVec<[ast::Arm; 1]> {
261-
mut_visit::noop_flat_map_arm(configure!(self, arm), self)
261+
mut_visit::walk_arm(configure!(self, arm), self)
262262
}
263263

264264
fn flat_map_expr_field(&mut self, field: ast::ExprField) -> SmallVec<[ast::ExprField; 1]> {
265-
mut_visit::noop_flat_map_expr_field(configure!(self, field), self)
265+
mut_visit::walk_expr_field(configure!(self, field), self)
266266
}
267267

268268
fn flat_map_pat_field(&mut self, fp: ast::PatField) -> SmallVec<[ast::PatField; 1]> {
269-
mut_visit::noop_flat_map_pat_field(configure!(self, fp), self)
269+
mut_visit::walk_pat_field(configure!(self, fp), self)
270270
}
271271

272272
fn flat_map_param(&mut self, p: ast::Param) -> SmallVec<[ast::Param; 1]> {
273-
mut_visit::noop_flat_map_param(configure!(self, p), self)
273+
mut_visit::walk_param(configure!(self, p), self)
274274
}
275275

276276
fn flat_map_field_def(&mut self, sf: ast::FieldDef) -> SmallVec<[ast::FieldDef; 1]> {
277-
mut_visit::noop_flat_map_field_def(configure!(self, sf), self)
277+
mut_visit::walk_field_def(configure!(self, sf), self)
278278
}
279279

280280
fn flat_map_variant(&mut self, variant: ast::Variant) -> SmallVec<[ast::Variant; 1]> {
281-
mut_visit::noop_flat_map_variant(configure!(self, variant), self)
281+
mut_visit::walk_variant(configure!(self, variant), self)
282282
}
283283
}

‎compiler/rustc_builtin_macros/src/test_harness.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Code that generates a test runner to run all the tests in a crate
22

3-
use rustc_ast as ast;
43
use rustc_ast::entry::EntryPointType;
54
use rustc_ast::mut_visit::*;
65
use rustc_ast::ptr::P;
76
use rustc_ast::visit::{walk_item, Visitor};
7+
use rustc_ast::{self as ast, mut_visit};
88
use rustc_ast::{attr, ModKind};
99
use rustc_errors::DiagCtxtHandle;
1010
use rustc_expand::base::{ExtCtxt, ResolverExpand};
@@ -122,7 +122,7 @@ impl TestHarnessGenerator<'_> {
122122
impl<'a> MutVisitor for TestHarnessGenerator<'a> {
123123
fn visit_crate(&mut self, c: &mut ast::Crate) {
124124
let prev_tests = mem::take(&mut self.tests);
125-
noop_visit_crate(c, self);
125+
mut_visit::walk_crate(c, self);
126126
self.add_test_cases(ast::CRATE_NODE_ID, c.spans.inner_span, prev_tests);
127127

128128
// Create a main function to run our tests
@@ -144,7 +144,7 @@ impl<'a> MutVisitor for TestHarnessGenerator<'a> {
144144
item.kind
145145
{
146146
let prev_tests = mem::take(&mut self.tests);
147-
noop_visit_item_kind(&mut item.kind, item.ident, item.span, item.id, self);
147+
mut_visit::walk_item_kind(&mut item.kind, item.ident, item.span, item.id, self);
148148
self.add_test_cases(item.id, span, prev_tests);
149149
} else {
150150
// But in those cases, we emit a lint to warn the user of these missing tests.
@@ -192,7 +192,7 @@ struct EntryPointCleaner<'a> {
192192
impl<'a> MutVisitor for EntryPointCleaner<'a> {
193193
fn flat_map_item(&mut self, i: P<ast::Item>) -> SmallVec<[P<ast::Item>; 1]> {
194194
self.depth += 1;
195-
let item = noop_flat_map_item(i, None, self).expect_one("noop did something");
195+
let item = mut_visit::walk_item(i, None, self).expect_one("noop did something");
196196
self.depth -= 1;
197197

198198
// Remove any #[rustc_main] or #[start] from the AST so it doesn't

‎compiler/rustc_expand/src/expand.rs

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ use crate::mbe::diagnostics::annotate_err_with_kind;
99
use crate::module::{mod_dir_path, parse_external_mod, DirOwnership, ParsedExternalMod};
1010
use crate::placeholders::{placeholder, PlaceholderExpander};
1111

12-
use rustc_ast as ast;
1312
use rustc_ast::mut_visit::*;
1413
use rustc_ast::ptr::P;
1514
use rustc_ast::token::{self, Delimiter};
1615
use rustc_ast::tokenstream::TokenStream;
1716
use rustc_ast::visit::{self, try_visit, walk_list, AssocCtxt, Visitor, VisitorResult};
17+
use rustc_ast::{self as ast, mut_visit};
1818
use rustc_ast::{AssocItemKind, AstNodeWrapper, AttrArgs, AttrStyle, AttrVec, ExprKind};
1919
use rustc_ast::{ForeignItemKind, HasAttrs, HasNodeId};
2020
use rustc_ast::{Inline, ItemKind, MacStmtStyle, MetaItemKind, ModKind};
@@ -1036,7 +1036,7 @@ pub(crate) fn ensure_complete_parse<'a>(
10361036
}
10371037
}
10381038

1039-
/// Wraps a call to `noop_visit_*` / `noop_flat_map_*`
1039+
/// Wraps a call to `walk_*` / `walk_*`
10401040
/// for an AST node that supports attributes
10411041
/// (see the `Annotatable` enum)
10421042
/// This method assigns a `NodeId`, and sets that `NodeId`
@@ -1056,7 +1056,7 @@ pub(crate) fn ensure_complete_parse<'a>(
10561056
/// * `id` is a mutable reference to the `NodeId` field
10571057
/// of the current AST node.
10581058
/// * `closure` is a closure that executes the
1059-
/// `noop_visit_*` / `noop_flat_map_*` method
1059+
/// `walk_*` / `walk_*` method
10601060
/// for the current AST node.
10611061
macro_rules! assign_id {
10621062
($self:ident, $id:expr, $closure:expr) => {{
@@ -1090,10 +1090,10 @@ trait InvocationCollectorNode: HasAttrs + HasNodeId + Sized {
10901090
fn descr() -> &'static str {
10911091
unreachable!()
10921092
}
1093-
fn noop_flat_map<V: MutVisitor>(self, _visitor: &mut V) -> Self::OutputTy {
1093+
fn walk_map<V: MutVisitor>(self, _visitor: &mut V) -> Self::OutputTy {
10941094
unreachable!()
10951095
}
1096-
fn noop_visit<V: MutVisitor>(&mut self, _visitor: &mut V) {
1096+
fn walk<V: MutVisitor>(&mut self, _visitor: &mut V) {
10971097
unreachable!()
10981098
}
10991099
fn is_mac_call(&self) -> bool {
@@ -1117,12 +1117,12 @@ trait InvocationCollectorNode: HasAttrs + HasNodeId + Sized {
11171117
fn pre_flat_map_node_collect_attr(_cfg: &StripUnconfigured<'_>, _attr: &ast::Attribute) {}
11181118
fn post_flat_map_node_collect_bang(_output: &mut Self::OutputTy, _add_semicolon: AddSemicolon) {
11191119
}
1120-
fn wrap_flat_map_node_noop_flat_map(
1120+
fn wrap_flat_map_node_walk(
11211121
node: Self,
11221122
collector: &mut InvocationCollector<'_, '_>,
1123-
noop_flat_map: impl FnOnce(Self, &mut InvocationCollector<'_, '_>) -> Self::OutputTy,
1123+
walk: impl FnOnce(Self, &mut InvocationCollector<'_, '_>) -> Self::OutputTy,
11241124
) -> Result<Self::OutputTy, Self> {
1125-
Ok(noop_flat_map(node, collector))
1125+
Ok(walk(node, collector))
11261126
}
11271127
fn expand_cfg_false(
11281128
&mut self,
@@ -1148,8 +1148,8 @@ impl InvocationCollectorNode for P<ast::Item> {
11481148
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
11491149
fragment.make_items()
11501150
}
1151-
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1152-
noop_flat_map_item(self, None, visitor)
1151+
fn walk_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1152+
walk_item(self, None, visitor)
11531153
}
11541154
fn is_mac_call(&self) -> bool {
11551155
matches!(self.kind, ItemKind::MacCall(..))
@@ -1176,13 +1176,13 @@ impl InvocationCollectorNode for P<ast::Item> {
11761176
fn flatten_outputs(items: impl Iterator<Item = Self::OutputTy>) -> Self::OutputTy {
11771177
items.flatten().collect()
11781178
}
1179-
fn wrap_flat_map_node_noop_flat_map(
1179+
fn wrap_flat_map_node_walk(
11801180
mut node: Self,
11811181
collector: &mut InvocationCollector<'_, '_>,
1182-
noop_flat_map: impl FnOnce(Self, &mut InvocationCollector<'_, '_>) -> Self::OutputTy,
1182+
walk: impl FnOnce(Self, &mut InvocationCollector<'_, '_>) -> Self::OutputTy,
11831183
) -> Result<Self::OutputTy, Self> {
11841184
if !matches!(node.kind, ItemKind::Mod(..)) {
1185-
return Ok(noop_flat_map(node, collector));
1185+
return Ok(walk(node, collector));
11861186
}
11871187

11881188
// Work around borrow checker not seeing through `P`'s deref.
@@ -1252,7 +1252,7 @@ impl InvocationCollectorNode for P<ast::Item> {
12521252
let orig_dir_ownership =
12531253
mem::replace(&mut ecx.current_expansion.dir_ownership, dir_ownership);
12541254

1255-
let res = Ok(noop_flat_map(node, collector));
1255+
let res = Ok(walk(node, collector));
12561256

12571257
collector.cx.current_expansion.dir_ownership = orig_dir_ownership;
12581258
collector.cx.current_expansion.module = orig_module;
@@ -1292,8 +1292,8 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, TraitItemTag>
12921292
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
12931293
fragment.make_trait_items()
12941294
}
1295-
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1296-
noop_flat_map_item(self.wrapped, Some(AssocCtxt::Trait), visitor)
1295+
fn walk_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1296+
walk_item(self.wrapped, Some(AssocCtxt::Trait), visitor)
12971297
}
12981298
fn is_mac_call(&self) -> bool {
12991299
matches!(self.wrapped.kind, AssocItemKind::MacCall(..))
@@ -1333,8 +1333,8 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, ImplItemTag>
13331333
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
13341334
fragment.make_impl_items()
13351335
}
1336-
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1337-
noop_flat_map_item(self.wrapped, Some(AssocCtxt::Impl), visitor)
1336+
fn walk_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1337+
walk_item(self.wrapped, Some(AssocCtxt::Impl), visitor)
13381338
}
13391339
fn is_mac_call(&self) -> bool {
13401340
matches!(self.wrapped.kind, AssocItemKind::MacCall(..))
@@ -1371,8 +1371,8 @@ impl InvocationCollectorNode for P<ast::ForeignItem> {
13711371
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
13721372
fragment.make_foreign_items()
13731373
}
1374-
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1375-
noop_flat_map_item(self, None, visitor)
1374+
fn walk_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1375+
walk_item(self, None, visitor)
13761376
}
13771377
fn is_mac_call(&self) -> bool {
13781378
matches!(self.kind, ForeignItemKind::MacCall(..))
@@ -1394,8 +1394,8 @@ impl InvocationCollectorNode for ast::Variant {
13941394
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
13951395
fragment.make_variants()
13961396
}
1397-
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1398-
noop_flat_map_variant(self, visitor)
1397+
fn walk_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1398+
walk_variant(self, visitor)
13991399
}
14001400
}
14011401

@@ -1407,8 +1407,8 @@ impl InvocationCollectorNode for ast::FieldDef {
14071407
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
14081408
fragment.make_field_defs()
14091409
}
1410-
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1411-
noop_flat_map_field_def(self, visitor)
1410+
fn walk_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1411+
walk_field_def(self, visitor)
14121412
}
14131413
}
14141414

@@ -1420,8 +1420,8 @@ impl InvocationCollectorNode for ast::PatField {
14201420
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
14211421
fragment.make_pat_fields()
14221422
}
1423-
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1424-
noop_flat_map_pat_field(self, visitor)
1423+
fn walk_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1424+
walk_pat_field(self, visitor)
14251425
}
14261426
}
14271427

@@ -1433,8 +1433,8 @@ impl InvocationCollectorNode for ast::ExprField {
14331433
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
14341434
fragment.make_expr_fields()
14351435
}
1436-
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1437-
noop_flat_map_expr_field(self, visitor)
1436+
fn walk_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1437+
walk_expr_field(self, visitor)
14381438
}
14391439
}
14401440

@@ -1446,8 +1446,8 @@ impl InvocationCollectorNode for ast::Param {
14461446
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
14471447
fragment.make_params()
14481448
}
1449-
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1450-
noop_flat_map_param(self, visitor)
1449+
fn walk_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1450+
walk_param(self, visitor)
14511451
}
14521452
}
14531453

@@ -1459,8 +1459,8 @@ impl InvocationCollectorNode for ast::GenericParam {
14591459
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
14601460
fragment.make_generic_params()
14611461
}
1462-
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1463-
noop_flat_map_generic_param(self, visitor)
1462+
fn walk_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1463+
walk_generic_param(self, visitor)
14641464
}
14651465
}
14661466

@@ -1472,8 +1472,8 @@ impl InvocationCollectorNode for ast::Arm {
14721472
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
14731473
fragment.make_arms()
14741474
}
1475-
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1476-
noop_flat_map_arm(self, visitor)
1475+
fn walk_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1476+
walk_arm(self, visitor)
14771477
}
14781478
}
14791479

@@ -1486,8 +1486,8 @@ impl InvocationCollectorNode for ast::Stmt {
14861486
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
14871487
fragment.make_stmts()
14881488
}
1489-
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1490-
noop_flat_map_stmt(self, visitor)
1489+
fn walk_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1490+
walk_stmt(self, visitor)
14911491
}
14921492
fn is_mac_call(&self) -> bool {
14931493
match &self.kind {
@@ -1560,8 +1560,8 @@ impl InvocationCollectorNode for ast::Crate {
15601560
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
15611561
fragment.make_crate()
15621562
}
1563-
fn noop_visit<V: MutVisitor>(&mut self, visitor: &mut V) {
1564-
noop_visit_crate(self, visitor)
1563+
fn walk<V: MutVisitor>(&mut self, visitor: &mut V) {
1564+
walk_crate(self, visitor)
15651565
}
15661566
fn expand_cfg_false(
15671567
&mut self,
@@ -1586,8 +1586,8 @@ impl InvocationCollectorNode for P<ast::Ty> {
15861586
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
15871587
fragment.make_ty()
15881588
}
1589-
fn noop_visit<V: MutVisitor>(&mut self, visitor: &mut V) {
1590-
noop_visit_ty(self, visitor)
1589+
fn walk<V: MutVisitor>(&mut self, visitor: &mut V) {
1590+
walk_ty(self, visitor)
15911591
}
15921592
fn is_mac_call(&self) -> bool {
15931593
matches!(self.kind, ast::TyKind::MacCall(..))
@@ -1610,8 +1610,8 @@ impl InvocationCollectorNode for P<ast::Pat> {
16101610
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
16111611
fragment.make_pat()
16121612
}
1613-
fn noop_visit<V: MutVisitor>(&mut self, visitor: &mut V) {
1614-
noop_visit_pat(self, visitor)
1613+
fn walk<V: MutVisitor>(&mut self, visitor: &mut V) {
1614+
walk_pat(self, visitor)
16151615
}
16161616
fn is_mac_call(&self) -> bool {
16171617
matches!(self.kind, PatKind::MacCall(..))
@@ -1638,8 +1638,8 @@ impl InvocationCollectorNode for P<ast::Expr> {
16381638
fn descr() -> &'static str {
16391639
"an expression"
16401640
}
1641-
fn noop_visit<V: MutVisitor>(&mut self, visitor: &mut V) {
1642-
noop_visit_expr(self, visitor)
1641+
fn walk<V: MutVisitor>(&mut self, visitor: &mut V) {
1642+
walk_expr(self, visitor)
16431643
}
16441644
fn is_mac_call(&self) -> bool {
16451645
matches!(self.kind, ExprKind::MacCall(..))
@@ -1664,8 +1664,8 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::Expr>, OptExprTag> {
16641664
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
16651665
fragment.make_opt_expr()
16661666
}
1667-
fn noop_flat_map<V: MutVisitor>(mut self, visitor: &mut V) -> Self::OutputTy {
1668-
noop_visit_expr(&mut self.wrapped, visitor);
1667+
fn walk_map<V: MutVisitor>(mut self, visitor: &mut V) -> Self::OutputTy {
1668+
walk_expr(&mut self.wrapped, visitor);
16691669
Some(self.wrapped)
16701670
}
16711671
fn is_mac_call(&self) -> bool {
@@ -1704,8 +1704,8 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::Expr>, MethodReceiverTag>
17041704
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
17051705
AstNodeWrapper::new(fragment.make_method_receiver_expr(), MethodReceiverTag)
17061706
}
1707-
fn noop_visit<V: MutVisitor>(&mut self, visitor: &mut V) {
1708-
noop_visit_expr(&mut self.wrapped, visitor)
1707+
fn walk<V: MutVisitor>(&mut self, visitor: &mut V) {
1708+
mut_visit::walk_expr(&mut self.wrapped, visitor)
17091709
}
17101710
fn is_mac_call(&self) -> bool {
17111711
matches!(self.wrapped.kind, ast::ExprKind::MacCall(..))
@@ -2015,12 +2015,12 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
20152015
);
20162016
Node::flatten_outputs(single_delegations.map(|item| {
20172017
let mut item = Node::from_item(item);
2018-
assign_id!(self, item.node_id_mut(), || item.noop_flat_map(self))
2018+
assign_id!(self, item.node_id_mut(), || item.walk_map(self))
20192019
}))
20202020
}
20212021
None => {
2022-
match Node::wrap_flat_map_node_noop_flat_map(node, self, |mut node, this| {
2023-
assign_id!(this, node.node_id_mut(), || node.noop_flat_map(this))
2022+
match Node::wrap_flat_map_node_walk(node, self, |mut node, this| {
2023+
assign_id!(this, node.node_id_mut(), || node.walk_map(this))
20242024
}) {
20252025
Ok(output) => output,
20262026
Err(returned_node) => {
@@ -2068,7 +2068,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
20682068
}
20692069
None if node.delegation().is_some() => unreachable!(),
20702070
None => {
2071-
assign_id!(self, node.node_id_mut(), || node.noop_visit(self))
2071+
assign_id!(self, node.node_id_mut(), || node.walk(self))
20722072
}
20732073
};
20742074
}
@@ -2147,11 +2147,11 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
21472147
self.cx.current_expansion.is_trailing_mac = true;
21482148
// Don't use `assign_id` for this statement - it may get removed
21492149
// entirely due to a `#[cfg]` on the contained expression
2150-
let res = noop_flat_map_stmt(node, self);
2150+
let res = walk_stmt(node, self);
21512151
self.cx.current_expansion.is_trailing_mac = false;
21522152
res
21532153
}
2154-
_ => noop_flat_map_stmt(node, self),
2154+
_ => walk_stmt(node, self),
21552155
};
21562156
}
21572157

@@ -2195,7 +2195,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
21952195
&mut self.cx.current_expansion.dir_ownership,
21962196
DirOwnership::UnownedViaBlock,
21972197
);
2198-
noop_visit_block(node, self);
2198+
walk_block(node, self);
21992199
self.cx.current_expansion.dir_ownership = orig_dir_ownership;
22002200
}
22012201

‎compiler/rustc_expand/src/placeholders.rs

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -206,26 +206,22 @@ impl PlaceholderExpander {
206206

207207
impl MutVisitor for PlaceholderExpander {
208208
fn flat_map_arm(&mut self, arm: ast::Arm) -> SmallVec<[ast::Arm; 1]> {
209-
if arm.is_placeholder {
210-
self.remove(arm.id).make_arms()
211-
} else {
212-
noop_flat_map_arm(arm, self)
213-
}
209+
if arm.is_placeholder { self.remove(arm.id).make_arms() } else { walk_arm(arm, self) }
214210
}
215211

216212
fn flat_map_expr_field(&mut self, field: ast::ExprField) -> SmallVec<[ast::ExprField; 1]> {
217213
if field.is_placeholder {
218214
self.remove(field.id).make_expr_fields()
219215
} else {
220-
noop_flat_map_expr_field(field, self)
216+
walk_expr_field(field, self)
221217
}
222218
}
223219

224220
fn flat_map_pat_field(&mut self, fp: ast::PatField) -> SmallVec<[ast::PatField; 1]> {
225221
if fp.is_placeholder {
226222
self.remove(fp.id).make_pat_fields()
227223
} else {
228-
noop_flat_map_pat_field(fp, self)
224+
walk_pat_field(fp, self)
229225
}
230226
}
231227

@@ -236,38 +232,34 @@ impl MutVisitor for PlaceholderExpander {
236232
if param.is_placeholder {
237233
self.remove(param.id).make_generic_params()
238234
} else {
239-
noop_flat_map_generic_param(param, self)
235+
walk_generic_param(param, self)
240236
}
241237
}
242238

243239
fn flat_map_param(&mut self, p: ast::Param) -> SmallVec<[ast::Param; 1]> {
244-
if p.is_placeholder {
245-
self.remove(p.id).make_params()
246-
} else {
247-
noop_flat_map_param(p, self)
248-
}
240+
if p.is_placeholder { self.remove(p.id).make_params() } else { walk_param(p, self) }
249241
}
250242

251243
fn flat_map_field_def(&mut self, sf: ast::FieldDef) -> SmallVec<[ast::FieldDef; 1]> {
252244
if sf.is_placeholder {
253245
self.remove(sf.id).make_field_defs()
254246
} else {
255-
noop_flat_map_field_def(sf, self)
247+
walk_field_def(sf, self)
256248
}
257249
}
258250

259251
fn flat_map_variant(&mut self, variant: ast::Variant) -> SmallVec<[ast::Variant; 1]> {
260252
if variant.is_placeholder {
261253
self.remove(variant.id).make_variants()
262254
} else {
263-
noop_flat_map_variant(variant, self)
255+
walk_variant(variant, self)
264256
}
265257
}
266258

267259
fn flat_map_item(&mut self, item: P<ast::Item>) -> SmallVec<[P<ast::Item>; 1]> {
268260
match item.kind {
269261
ast::ItemKind::MacCall(_) => self.remove(item.id).make_items(),
270-
_ => noop_flat_map_item(item, None, self),
262+
_ => walk_item(item, None, self),
271263
}
272264
}
273265

@@ -284,7 +276,7 @@ impl MutVisitor for PlaceholderExpander {
284276
AssocCtxt::Impl => it.make_impl_items(),
285277
}
286278
}
287-
_ => noop_flat_map_item(item, Some(ctxt), self),
279+
_ => walk_item(item, Some(ctxt), self),
288280
}
289281
}
290282

@@ -294,21 +286,21 @@ impl MutVisitor for PlaceholderExpander {
294286
) -> SmallVec<[P<ast::ForeignItem>; 1]> {
295287
match item.kind {
296288
ast::ForeignItemKind::MacCall(_) => self.remove(item.id).make_foreign_items(),
297-
_ => noop_flat_map_item(item, None, self),
289+
_ => walk_item(item, None, self),
298290
}
299291
}
300292

301293
fn visit_expr(&mut self, expr: &mut P<ast::Expr>) {
302294
match expr.kind {
303295
ast::ExprKind::MacCall(_) => *expr = self.remove(expr.id).make_expr(),
304-
_ => noop_visit_expr(expr, self),
296+
_ => walk_expr(expr, self),
305297
}
306298
}
307299

308300
fn visit_method_receiver_expr(&mut self, expr: &mut P<ast::Expr>) {
309301
match expr.kind {
310302
ast::ExprKind::MacCall(_) => *expr = self.remove(expr.id).make_method_receiver_expr(),
311-
_ => noop_visit_expr(expr, self),
303+
_ => walk_expr(expr, self),
312304
}
313305
}
314306

@@ -322,7 +314,7 @@ impl MutVisitor for PlaceholderExpander {
322314
fn flat_map_stmt(&mut self, stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> {
323315
let (style, mut stmts) = match stmt.kind {
324316
ast::StmtKind::MacCall(mac) => (mac.style, self.remove(stmt.id).make_stmts()),
325-
_ => return noop_flat_map_stmt(stmt, self),
317+
_ => return walk_stmt(stmt, self),
326318
};
327319

328320
if style == ast::MacStmtStyle::Semicolon {
@@ -368,22 +360,22 @@ impl MutVisitor for PlaceholderExpander {
368360
fn visit_pat(&mut self, pat: &mut P<ast::Pat>) {
369361
match pat.kind {
370362
ast::PatKind::MacCall(_) => *pat = self.remove(pat.id).make_pat(),
371-
_ => noop_visit_pat(pat, self),
363+
_ => walk_pat(pat, self),
372364
}
373365
}
374366

375367
fn visit_ty(&mut self, ty: &mut P<ast::Ty>) {
376368
match ty.kind {
377369
ast::TyKind::MacCall(_) => *ty = self.remove(ty.id).make_ty(),
378-
_ => noop_visit_ty(ty, self),
370+
_ => walk_ty(ty, self),
379371
}
380372
}
381373

382374
fn visit_crate(&mut self, krate: &mut ast::Crate) {
383375
if krate.is_placeholder {
384376
*krate = self.remove(krate.id).make_crate();
385377
} else {
386-
noop_visit_crate(krate, self)
378+
walk_crate(krate, self)
387379
}
388380
}
389381
}

‎compiler/rustc_parse/src/parser/expr.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use super::{
1010

1111
use crate::errors;
1212
use crate::maybe_recover_from_interpolated_ty_qpath;
13-
use ast::mut_visit::{noop_visit_expr, MutVisitor};
13+
use ast::mut_visit::MutVisitor;
1414
use ast::token::IdentIsRaw;
1515
use ast::{CoroutineKind, ForLoopKind, GenBlockKind, MatchKind, Pat, Path, PathSegment, Recovered};
1616
use core::mem;
@@ -21,7 +21,9 @@ use rustc_ast::util::case::Case;
2121
use rustc_ast::util::classify;
2222
use rustc_ast::util::parser::{prec_let_scrutinee_needs_par, AssocOp, Fixity};
2323
use rustc_ast::visit::{walk_expr, Visitor};
24-
use rustc_ast::{self as ast, AttrStyle, AttrVec, CaptureBy, ExprField, UnOp, DUMMY_NODE_ID};
24+
use rustc_ast::{
25+
self as ast, mut_visit, AttrStyle, AttrVec, CaptureBy, ExprField, UnOp, DUMMY_NODE_ID,
26+
};
2527
use rustc_ast::{AnonConst, BinOp, BinOpKind, FnDecl, FnRetTy, MacCall, Param, Ty, TyKind};
2628
use rustc_ast::{Arm, BlockCheckMode, Expr, ExprKind, Label, Movability, RangeLimits};
2729
use rustc_ast::{ClosureBinder, MetaItemLit, StmtKind};
@@ -3950,22 +3952,22 @@ impl MutVisitor for CondChecker<'_> {
39503952
}
39513953
}
39523954
ExprKind::Binary(Spanned { node: BinOpKind::And, .. }, _, _) => {
3953-
noop_visit_expr(e, self);
3955+
mut_visit::walk_expr(e, self);
39543956
}
39553957
ExprKind::Binary(Spanned { node: BinOpKind::Or, span: or_span }, _, _)
39563958
if let None | Some(NotSupportedOr(_)) = self.forbid_let_reason =>
39573959
{
39583960
let forbid_let_reason = self.forbid_let_reason;
39593961
self.forbid_let_reason = Some(NotSupportedOr(or_span));
3960-
noop_visit_expr(e, self);
3962+
mut_visit::walk_expr(e, self);
39613963
self.forbid_let_reason = forbid_let_reason;
39623964
}
39633965
ExprKind::Paren(ref inner)
39643966
if let None | Some(NotSupportedParentheses(_)) = self.forbid_let_reason =>
39653967
{
39663968
let forbid_let_reason = self.forbid_let_reason;
39673969
self.forbid_let_reason = Some(NotSupportedParentheses(inner.span));
3968-
noop_visit_expr(e, self);
3970+
mut_visit::walk_expr(e, self);
39693971
self.forbid_let_reason = forbid_let_reason;
39703972
}
39713973
ExprKind::Assign(ref lhs, _, span) => {
@@ -3983,7 +3985,7 @@ impl MutVisitor for CondChecker<'_> {
39833985
}
39843986
let comparison = self.comparison;
39853987
self.comparison = Some(errors::MaybeComparison { span: span.shrink_to_hi() });
3986-
noop_visit_expr(e, self);
3988+
mut_visit::walk_expr(e, self);
39873989
self.forbid_let_reason = forbid_let_reason;
39883990
self.missing_let = missing_let;
39893991
self.comparison = comparison;
@@ -4003,7 +4005,7 @@ impl MutVisitor for CondChecker<'_> {
40034005
| ExprKind::Paren(_) => {
40044006
let forbid_let_reason = self.forbid_let_reason;
40054007
self.forbid_let_reason = Some(OtherForbidden);
4006-
noop_visit_expr(e, self);
4008+
mut_visit::walk_expr(e, self);
40074009
self.forbid_let_reason = forbid_let_reason;
40084010
}
40094011
ExprKind::Cast(ref mut op, _) | ExprKind::Type(ref mut op, _) => {

‎compiler/rustc_parse/src/parser/pat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::errors::{
1212
};
1313
use crate::parser::expr::{could_be_unclosed_char_literal, LhsExpr};
1414
use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
15-
use rustc_ast::mut_visit::{noop_visit_pat, MutVisitor};
15+
use rustc_ast::mut_visit::{walk_pat, MutVisitor};
1616
use rustc_ast::ptr::P;
1717
use rustc_ast::token::{self, BinOpToken, Delimiter, Token};
1818
use rustc_ast::{
@@ -795,7 +795,7 @@ impl<'a> Parser<'a> {
795795
self.0 = true;
796796
*m = Mutability::Mut;
797797
}
798-
noop_visit_pat(pat, self);
798+
walk_pat(pat, self);
799799
}
800800
}
801801

‎src/tools/clippy/clippy_lints/src/unnested_or_patterns.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ fn remove_all_parens(pat: &mut P<Pat>) {
121121
struct Visitor;
122122
impl MutVisitor for Visitor {
123123
fn visit_pat(&mut self, pat: &mut P<Pat>) {
124-
noop_visit_pat(pat, self);
124+
walk_pat(pat, self);
125125
let inner = match &mut pat.kind {
126126
Paren(i) => mem::replace(&mut i.kind, Wild),
127127
_ => return,
@@ -138,7 +138,7 @@ fn insert_necessary_parens(pat: &mut P<Pat>) {
138138
impl MutVisitor for Visitor {
139139
fn visit_pat(&mut self, pat: &mut P<Pat>) {
140140
use ast::BindingMode;
141-
noop_visit_pat(pat, self);
141+
walk_pat(pat, self);
142142
let target = match &mut pat.kind {
143143
// `i @ a | b`, `box a | b`, and `& mut? a | b`.
144144
Ident(.., Some(p)) | Box(p) | Ref(p, _) if matches!(&p.kind, Or(ps) if ps.len() > 1) => p,
@@ -160,7 +160,7 @@ fn unnest_or_patterns(pat: &mut P<Pat>) -> bool {
160160
impl MutVisitor for Visitor {
161161
fn visit_pat(&mut self, p: &mut P<Pat>) {
162162
// This is a bottom up transformation, so recurse first.
163-
noop_visit_pat(p, self);
163+
walk_pat(p, self);
164164

165165
// Don't have an or-pattern? Just quit early on.
166166
let Or(alternatives) = &mut p.kind else { return };
@@ -189,7 +189,7 @@ fn unnest_or_patterns(pat: &mut P<Pat>) -> bool {
189189

190190
// Deal with `Some(Some(0)) | Some(Some(1))`.
191191
if this_level_changed {
192-
noop_visit_pat(p, self);
192+
walk_pat(p, self);
193193
}
194194
}
195195
}

‎tests/ui-fulldeps/pprust-expr-roundtrip.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl MutVisitor for RemoveParens {
202202
ExprKind::Paren(inner) => *e = inner,
203203
_ => {}
204204
};
205-
mut_visit::noop_visit_expr(e, self);
205+
mut_visit::walk_expr(e, self);
206206
}
207207
}
208208

@@ -211,7 +211,7 @@ struct AddParens;
211211

212212
impl MutVisitor for AddParens {
213213
fn visit_expr(&mut self, e: &mut P<Expr>) {
214-
mut_visit::noop_visit_expr(e, self);
214+
mut_visit::walk_expr(e, self);
215215
visit_clobber(e, |e| {
216216
P(Expr {
217217
id: DUMMY_NODE_ID,

0 commit comments

Comments
 (0)
Please sign in to comment.