@@ -11,7 +11,7 @@ use crate::ast::*;
11
11
use crate :: ptr:: P ;
12
12
use crate :: token:: { self , Token } ;
13
13
use crate :: tokenstream:: * ;
14
- use crate :: visit:: { AssocCtxt , BoundKind , FnCtxt } ;
14
+ use crate :: visit:: { AssocCtxt , BoundKind } ;
15
15
16
16
use rustc_data_structures:: flat_map_in_place:: FlatMapInPlace ;
17
17
use rustc_data_structures:: stack:: ensure_sufficient_stack;
@@ -36,14 +36,7 @@ impl<A: Array> ExpectOne<A> for SmallVec<A> {
36
36
}
37
37
38
38
pub trait WalkItemKind {
39
- fn walk (
40
- & mut self ,
41
- ctxt : Option < AssocCtxt > ,
42
- ident : Ident ,
43
- span : Span ,
44
- id : NodeId ,
45
- visitor : & mut impl MutVisitor ,
46
- ) ;
39
+ fn walk ( & mut self , span : Span , id : NodeId , visitor : & mut impl MutVisitor ) ;
47
40
}
48
41
49
42
pub trait MutVisitor : Sized {
@@ -102,11 +95,11 @@ pub trait MutVisitor: Sized {
102
95
}
103
96
104
97
fn flat_map_foreign_item ( & mut self , ni : P < ForeignItem > ) -> SmallVec < [ P < ForeignItem > ; 1 ] > {
105
- walk_flat_map_item ( self , ni, None )
98
+ walk_flat_map_item ( self , ni)
106
99
}
107
100
108
101
fn flat_map_item ( & mut self , i : P < Item > ) -> SmallVec < [ P < Item > ; 1 ] > {
109
- walk_flat_map_item ( self , i, None )
102
+ walk_flat_map_item ( self , i)
110
103
}
111
104
112
105
fn visit_fn_header ( & mut self , header : & mut FnHeader ) {
@@ -120,9 +113,9 @@ pub trait MutVisitor: Sized {
120
113
fn flat_map_assoc_item (
121
114
& mut self ,
122
115
i : P < AssocItem > ,
123
- ctxt : AssocCtxt ,
116
+ _ctxt : AssocCtxt ,
124
117
) -> SmallVec < [ P < AssocItem > ; 1 ] > {
125
- walk_flat_map_item ( self , i, Some ( ctxt ) )
118
+ walk_flat_map_item ( self , i)
126
119
}
127
120
128
121
fn visit_fn_decl ( & mut self , d : & mut P < FnDecl > ) {
@@ -890,7 +883,7 @@ fn walk_coroutine_kind<T: MutVisitor>(vis: &mut T, coroutine_kind: &mut Coroutin
890
883
891
884
fn walk_fn < T : MutVisitor > ( vis : & mut T , kind : FnKind < ' _ > ) {
892
885
match kind {
893
- FnKind :: Fn ( _ctxt , _ident , FnSig { header, decl, span } , generics, body) => {
886
+ FnKind :: Fn ( FnSig { header, decl, span } , generics, body) => {
894
887
// Identifier and visibility are visited as a part of the item.
895
888
vis. visit_fn_header ( header) ;
896
889
vis. visit_generics ( generics) ;
@@ -1091,24 +1084,15 @@ pub fn walk_block<T: MutVisitor>(vis: &mut T, block: &mut P<Block>) {
1091
1084
1092
1085
pub fn walk_item_kind (
1093
1086
kind : & mut impl WalkItemKind ,
1094
- ident : Ident ,
1095
1087
span : Span ,
1096
1088
id : NodeId ,
1097
1089
vis : & mut impl MutVisitor ,
1098
1090
) {
1099
- kind. walk ( None , ident , span, id, vis)
1091
+ kind. walk ( span, id, vis)
1100
1092
}
1101
1093
1102
1094
impl WalkItemKind for ItemKind {
1103
- fn walk (
1104
- & mut self ,
1105
- ctxt : Option < AssocCtxt > ,
1106
- ident : Ident ,
1107
- span : Span ,
1108
- id : NodeId ,
1109
- vis : & mut impl MutVisitor ,
1110
- ) {
1111
- assert_eq ! ( ctxt, None ) ;
1095
+ fn walk ( & mut self , span : Span , id : NodeId , vis : & mut impl MutVisitor ) {
1112
1096
match self {
1113
1097
ItemKind :: ExternCrate ( _orig_name) => { }
1114
1098
ItemKind :: Use ( use_tree) => vis. visit_use_tree ( use_tree) ,
@@ -1121,7 +1105,7 @@ impl WalkItemKind for ItemKind {
1121
1105
}
1122
1106
ItemKind :: Fn ( box Fn { defaultness, generics, sig, body } ) => {
1123
1107
visit_defaultness ( vis, defaultness) ;
1124
- vis. visit_fn ( FnKind :: Fn ( FnCtxt :: Free , ident , sig, generics, body) , span, id) ;
1108
+ vis. visit_fn ( FnKind :: Fn ( sig, generics, body) , span, id) ;
1125
1109
}
1126
1110
ItemKind :: Mod ( safety, mod_kind) => {
1127
1111
visit_safety ( vis, safety) ;
@@ -1220,26 +1204,14 @@ impl WalkItemKind for ItemKind {
1220
1204
}
1221
1205
1222
1206
impl WalkItemKind for AssocItemKind {
1223
- fn walk (
1224
- & mut self ,
1225
- ctxt : Option < AssocCtxt > ,
1226
- ident : Ident ,
1227
- span : Span ,
1228
- id : NodeId ,
1229
- visitor : & mut impl MutVisitor ,
1230
- ) {
1231
- let ctxt = ctxt. unwrap ( ) ;
1207
+ fn walk ( & mut self , span : Span , id : NodeId , visitor : & mut impl MutVisitor ) {
1232
1208
match self {
1233
1209
AssocItemKind :: Const ( item) => {
1234
1210
visit_const_item ( item, visitor) ;
1235
1211
}
1236
1212
AssocItemKind :: Fn ( box Fn { defaultness, generics, sig, body } ) => {
1237
1213
visit_defaultness ( visitor, defaultness) ;
1238
- visitor. visit_fn (
1239
- FnKind :: Fn ( FnCtxt :: Assoc ( ctxt) , ident, sig, generics, body) ,
1240
- span,
1241
- id,
1242
- ) ;
1214
+ visitor. visit_fn ( FnKind :: Fn ( sig, generics, body) , span, id) ;
1243
1215
}
1244
1216
AssocItemKind :: Type ( box TyAlias {
1245
1217
defaultness,
@@ -1323,37 +1295,28 @@ pub fn walk_crate<T: MutVisitor>(vis: &mut T, krate: &mut Crate) {
1323
1295
pub fn walk_flat_map_item < K : WalkItemKind > (
1324
1296
visitor : & mut impl MutVisitor ,
1325
1297
mut item : P < Item < K > > ,
1326
- ctxt : Option < AssocCtxt > ,
1327
1298
) -> SmallVec < [ P < Item < K > > ; 1 ] > {
1328
1299
let Item { ident, attrs, id, kind, vis, span, tokens } = item. deref_mut ( ) ;
1329
1300
visitor. visit_id ( id) ;
1330
1301
visit_attrs ( visitor, attrs) ;
1331
1302
visitor. visit_vis ( vis) ;
1332
1303
visitor. visit_ident ( ident) ;
1333
- kind. walk ( ctxt , * ident , * span, * id, visitor) ;
1304
+ kind. walk ( * span, * id, visitor) ;
1334
1305
visit_lazy_tts ( visitor, tokens) ;
1335
1306
visitor. visit_span ( span) ;
1336
1307
smallvec ! [ item]
1337
1308
}
1338
1309
1339
1310
impl WalkItemKind for ForeignItemKind {
1340
- fn walk (
1341
- & mut self ,
1342
- ctxt : Option < AssocCtxt > ,
1343
- ident : Ident ,
1344
- span : Span ,
1345
- id : NodeId ,
1346
- visitor : & mut impl MutVisitor ,
1347
- ) {
1348
- assert_eq ! ( ctxt, None ) ;
1311
+ fn walk ( & mut self , span : Span , id : NodeId , visitor : & mut impl MutVisitor ) {
1349
1312
match self {
1350
1313
ForeignItemKind :: Static ( box StaticItem { ty, mutability : _, expr, safety : _ } ) => {
1351
1314
visitor. visit_ty ( ty) ;
1352
1315
visit_opt ( expr, |expr| visitor. visit_expr ( expr) ) ;
1353
1316
}
1354
1317
ForeignItemKind :: Fn ( box Fn { defaultness, generics, sig, body } ) => {
1355
1318
visit_defaultness ( visitor, defaultness) ;
1356
- visitor. visit_fn ( FnKind :: Fn ( FnCtxt :: Foreign , ident , sig, generics, body) , span, id) ;
1319
+ visitor. visit_fn ( FnKind :: Fn ( sig, generics, body) , span, id) ;
1357
1320
}
1358
1321
ForeignItemKind :: TyAlias ( box TyAlias {
1359
1322
defaultness,
@@ -1824,7 +1787,7 @@ impl<N: DummyAstNode, T: DummyAstNode> DummyAstNode for crate::ast_traits::AstNo
1824
1787
#[ derive( Debug ) ]
1825
1788
pub enum FnKind < ' a > {
1826
1789
/// E.g., `fn foo()`, `fn foo(&self)`, or `extern "Abi" fn foo()`.
1827
- Fn ( FnCtxt , Ident , & ' a mut FnSig , & ' a mut Generics , & ' a mut Option < P < Block > > ) ,
1790
+ Fn ( & ' a mut FnSig , & ' a mut Generics , & ' a mut Option < P < Block > > ) ,
1828
1791
1829
1792
/// E.g., `|x, y| body`.
1830
1793
Closure ( & ' a mut ClosureBinder , & ' a mut P < FnDecl > , & ' a mut P < Expr > ) ,
0 commit comments