@@ -9,12 +9,12 @@ use crate::mbe::diagnostics::annotate_err_with_kind;
9
9
use crate :: module:: { mod_dir_path, parse_external_mod, DirOwnership , ParsedExternalMod } ;
10
10
use crate :: placeholders:: { placeholder, PlaceholderExpander } ;
11
11
12
- use rustc_ast as ast;
13
12
use rustc_ast:: mut_visit:: * ;
14
13
use rustc_ast:: ptr:: P ;
15
14
use rustc_ast:: token:: { self , Delimiter } ;
16
15
use rustc_ast:: tokenstream:: TokenStream ;
17
16
use rustc_ast:: visit:: { self , try_visit, walk_list, AssocCtxt , Visitor , VisitorResult } ;
17
+ use rustc_ast:: { self as ast, mut_visit} ;
18
18
use rustc_ast:: { AssocItemKind , AstNodeWrapper , AttrArgs , AttrStyle , AttrVec , ExprKind } ;
19
19
use rustc_ast:: { ForeignItemKind , HasAttrs , HasNodeId } ;
20
20
use rustc_ast:: { Inline , ItemKind , MacStmtStyle , MetaItemKind , ModKind } ;
@@ -1036,7 +1036,7 @@ pub(crate) fn ensure_complete_parse<'a>(
1036
1036
}
1037
1037
}
1038
1038
1039
- /// Wraps a call to `noop_visit_ *` / `noop_flat_map_ *`
1039
+ /// Wraps a call to `walk_ *` / `walk_ *`
1040
1040
/// for an AST node that supports attributes
1041
1041
/// (see the `Annotatable` enum)
1042
1042
/// This method assigns a `NodeId`, and sets that `NodeId`
@@ -1056,7 +1056,7 @@ pub(crate) fn ensure_complete_parse<'a>(
1056
1056
/// * `id` is a mutable reference to the `NodeId` field
1057
1057
/// of the current AST node.
1058
1058
/// * `closure` is a closure that executes the
1059
- /// `noop_visit_ *` / `noop_flat_map_ *` method
1059
+ /// `walk_ *` / `walk_ *` method
1060
1060
/// for the current AST node.
1061
1061
macro_rules! assign_id {
1062
1062
( $self: ident, $id: expr, $closure: expr) => { {
@@ -1090,10 +1090,10 @@ trait InvocationCollectorNode: HasAttrs + HasNodeId + Sized {
1090
1090
fn descr ( ) -> & ' static str {
1091
1091
unreachable ! ( )
1092
1092
}
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 {
1094
1094
unreachable ! ( )
1095
1095
}
1096
- fn noop_visit < V : MutVisitor > ( & mut self , _visitor : & mut V ) {
1096
+ fn walk < V : MutVisitor > ( & mut self , _visitor : & mut V ) {
1097
1097
unreachable ! ( )
1098
1098
}
1099
1099
fn is_mac_call ( & self ) -> bool {
@@ -1117,12 +1117,12 @@ trait InvocationCollectorNode: HasAttrs + HasNodeId + Sized {
1117
1117
fn pre_flat_map_node_collect_attr ( _cfg : & StripUnconfigured < ' _ > , _attr : & ast:: Attribute ) { }
1118
1118
fn post_flat_map_node_collect_bang ( _output : & mut Self :: OutputTy , _add_semicolon : AddSemicolon ) {
1119
1119
}
1120
- fn wrap_flat_map_node_noop_flat_map (
1120
+ fn wrap_flat_map_node_walk (
1121
1121
node : Self ,
1122
1122
collector : & mut InvocationCollector < ' _ , ' _ > ,
1123
- noop_flat_map : impl FnOnce ( Self , & mut InvocationCollector < ' _ , ' _ > ) -> Self :: OutputTy ,
1123
+ walk : impl FnOnce ( Self , & mut InvocationCollector < ' _ , ' _ > ) -> Self :: OutputTy ,
1124
1124
) -> Result < Self :: OutputTy , Self > {
1125
- Ok ( noop_flat_map ( node, collector) )
1125
+ Ok ( walk ( node, collector) )
1126
1126
}
1127
1127
fn expand_cfg_false (
1128
1128
& mut self ,
@@ -1148,8 +1148,8 @@ impl InvocationCollectorNode for P<ast::Item> {
1148
1148
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1149
1149
fragment. make_items ( )
1150
1150
}
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)
1153
1153
}
1154
1154
fn is_mac_call ( & self ) -> bool {
1155
1155
matches ! ( self . kind, ItemKind :: MacCall ( ..) )
@@ -1176,13 +1176,13 @@ impl InvocationCollectorNode for P<ast::Item> {
1176
1176
fn flatten_outputs ( items : impl Iterator < Item = Self :: OutputTy > ) -> Self :: OutputTy {
1177
1177
items. flatten ( ) . collect ( )
1178
1178
}
1179
- fn wrap_flat_map_node_noop_flat_map (
1179
+ fn wrap_flat_map_node_walk (
1180
1180
mut node : Self ,
1181
1181
collector : & mut InvocationCollector < ' _ , ' _ > ,
1182
- noop_flat_map : impl FnOnce ( Self , & mut InvocationCollector < ' _ , ' _ > ) -> Self :: OutputTy ,
1182
+ walk : impl FnOnce ( Self , & mut InvocationCollector < ' _ , ' _ > ) -> Self :: OutputTy ,
1183
1183
) -> Result < Self :: OutputTy , Self > {
1184
1184
if !matches ! ( node. kind, ItemKind :: Mod ( ..) ) {
1185
- return Ok ( noop_flat_map ( node, collector) ) ;
1185
+ return Ok ( walk ( node, collector) ) ;
1186
1186
}
1187
1187
1188
1188
// Work around borrow checker not seeing through `P`'s deref.
@@ -1252,7 +1252,7 @@ impl InvocationCollectorNode for P<ast::Item> {
1252
1252
let orig_dir_ownership =
1253
1253
mem:: replace ( & mut ecx. current_expansion . dir_ownership , dir_ownership) ;
1254
1254
1255
- let res = Ok ( noop_flat_map ( node, collector) ) ;
1255
+ let res = Ok ( walk ( node, collector) ) ;
1256
1256
1257
1257
collector. cx . current_expansion . dir_ownership = orig_dir_ownership;
1258
1258
collector. cx . current_expansion . module = orig_module;
@@ -1292,8 +1292,8 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, TraitItemTag>
1292
1292
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1293
1293
fragment. make_trait_items ( )
1294
1294
}
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)
1297
1297
}
1298
1298
fn is_mac_call ( & self ) -> bool {
1299
1299
matches ! ( self . wrapped. kind, AssocItemKind :: MacCall ( ..) )
@@ -1333,8 +1333,8 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, ImplItemTag>
1333
1333
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1334
1334
fragment. make_impl_items ( )
1335
1335
}
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)
1338
1338
}
1339
1339
fn is_mac_call ( & self ) -> bool {
1340
1340
matches ! ( self . wrapped. kind, AssocItemKind :: MacCall ( ..) )
@@ -1371,8 +1371,8 @@ impl InvocationCollectorNode for P<ast::ForeignItem> {
1371
1371
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1372
1372
fragment. make_foreign_items ( )
1373
1373
}
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)
1376
1376
}
1377
1377
fn is_mac_call ( & self ) -> bool {
1378
1378
matches ! ( self . kind, ForeignItemKind :: MacCall ( ..) )
@@ -1394,8 +1394,8 @@ impl InvocationCollectorNode for ast::Variant {
1394
1394
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1395
1395
fragment. make_variants ( )
1396
1396
}
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)
1399
1399
}
1400
1400
}
1401
1401
@@ -1407,8 +1407,8 @@ impl InvocationCollectorNode for ast::FieldDef {
1407
1407
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1408
1408
fragment. make_field_defs ( )
1409
1409
}
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)
1412
1412
}
1413
1413
}
1414
1414
@@ -1420,8 +1420,8 @@ impl InvocationCollectorNode for ast::PatField {
1420
1420
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1421
1421
fragment. make_pat_fields ( )
1422
1422
}
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)
1425
1425
}
1426
1426
}
1427
1427
@@ -1433,8 +1433,8 @@ impl InvocationCollectorNode for ast::ExprField {
1433
1433
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1434
1434
fragment. make_expr_fields ( )
1435
1435
}
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)
1438
1438
}
1439
1439
}
1440
1440
@@ -1446,8 +1446,8 @@ impl InvocationCollectorNode for ast::Param {
1446
1446
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1447
1447
fragment. make_params ( )
1448
1448
}
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)
1451
1451
}
1452
1452
}
1453
1453
@@ -1459,8 +1459,8 @@ impl InvocationCollectorNode for ast::GenericParam {
1459
1459
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1460
1460
fragment. make_generic_params ( )
1461
1461
}
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)
1464
1464
}
1465
1465
}
1466
1466
@@ -1472,8 +1472,8 @@ impl InvocationCollectorNode for ast::Arm {
1472
1472
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1473
1473
fragment. make_arms ( )
1474
1474
}
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)
1477
1477
}
1478
1478
}
1479
1479
@@ -1486,8 +1486,8 @@ impl InvocationCollectorNode for ast::Stmt {
1486
1486
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1487
1487
fragment. make_stmts ( )
1488
1488
}
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)
1491
1491
}
1492
1492
fn is_mac_call ( & self ) -> bool {
1493
1493
match & self . kind {
@@ -1560,8 +1560,8 @@ impl InvocationCollectorNode for ast::Crate {
1560
1560
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1561
1561
fragment. make_crate ( )
1562
1562
}
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)
1565
1565
}
1566
1566
fn expand_cfg_false (
1567
1567
& mut self ,
@@ -1586,8 +1586,8 @@ impl InvocationCollectorNode for P<ast::Ty> {
1586
1586
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1587
1587
fragment. make_ty ( )
1588
1588
}
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)
1591
1591
}
1592
1592
fn is_mac_call ( & self ) -> bool {
1593
1593
matches ! ( self . kind, ast:: TyKind :: MacCall ( ..) )
@@ -1610,8 +1610,8 @@ impl InvocationCollectorNode for P<ast::Pat> {
1610
1610
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1611
1611
fragment. make_pat ( )
1612
1612
}
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)
1615
1615
}
1616
1616
fn is_mac_call ( & self ) -> bool {
1617
1617
matches ! ( self . kind, PatKind :: MacCall ( ..) )
@@ -1638,8 +1638,8 @@ impl InvocationCollectorNode for P<ast::Expr> {
1638
1638
fn descr ( ) -> & ' static str {
1639
1639
"an expression"
1640
1640
}
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)
1643
1643
}
1644
1644
fn is_mac_call ( & self ) -> bool {
1645
1645
matches ! ( self . kind, ExprKind :: MacCall ( ..) )
@@ -1664,8 +1664,8 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::Expr>, OptExprTag> {
1664
1664
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1665
1665
fragment. make_opt_expr ( )
1666
1666
}
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) ;
1669
1669
Some ( self . wrapped )
1670
1670
}
1671
1671
fn is_mac_call ( & self ) -> bool {
@@ -1704,8 +1704,8 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::Expr>, MethodReceiverTag>
1704
1704
fn fragment_to_output ( fragment : AstFragment ) -> Self :: OutputTy {
1705
1705
AstNodeWrapper :: new ( fragment. make_method_receiver_expr ( ) , MethodReceiverTag )
1706
1706
}
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)
1709
1709
}
1710
1710
fn is_mac_call ( & self ) -> bool {
1711
1711
matches ! ( self . wrapped. kind, ast:: ExprKind :: MacCall ( ..) )
@@ -2015,12 +2015,12 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
2015
2015
) ;
2016
2016
Node :: flatten_outputs ( single_delegations. map ( |item| {
2017
2017
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 ) )
2019
2019
} ) )
2020
2020
}
2021
2021
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) )
2024
2024
} ) {
2025
2025
Ok ( output) => output,
2026
2026
Err ( returned_node) => {
@@ -2068,7 +2068,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
2068
2068
}
2069
2069
None if node. delegation ( ) . is_some ( ) => unreachable ! ( ) ,
2070
2070
None => {
2071
- assign_id ! ( self , node. node_id_mut( ) , || node. noop_visit ( self ) )
2071
+ assign_id ! ( self , node. node_id_mut( ) , || node. walk ( self ) )
2072
2072
}
2073
2073
} ;
2074
2074
}
@@ -2147,11 +2147,11 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
2147
2147
self . cx . current_expansion . is_trailing_mac = true ;
2148
2148
// Don't use `assign_id` for this statement - it may get removed
2149
2149
// 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 ) ;
2151
2151
self . cx . current_expansion . is_trailing_mac = false ;
2152
2152
res
2153
2153
}
2154
- _ => noop_flat_map_stmt ( node, self ) ,
2154
+ _ => walk_stmt ( node, self ) ,
2155
2155
} ;
2156
2156
}
2157
2157
@@ -2195,7 +2195,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
2195
2195
& mut self . cx . current_expansion . dir_ownership ,
2196
2196
DirOwnership :: UnownedViaBlock ,
2197
2197
) ;
2198
- noop_visit_block ( node, self ) ;
2198
+ walk_block ( node, self ) ;
2199
2199
self . cx . current_expansion . dir_ownership = orig_dir_ownership;
2200
2200
}
2201
2201
0 commit comments