@@ -39,10 +39,10 @@ use crate::{
39
39
40
40
type Res = def:: Res < NodeId > ;
41
41
42
- impl < ' a , Id : Into < DefId > > ToNameBinding < ' a >
43
- for ( Module < ' a > , ty:: Visibility < Id > , Span , LocalExpnId )
42
+ impl < ' ra , Id : Into < DefId > > ToNameBinding < ' ra >
43
+ for ( Module < ' ra > , ty:: Visibility < Id > , Span , LocalExpnId )
44
44
{
45
- fn to_name_binding ( self , arenas : & ' a ResolverArenas < ' a > ) -> NameBinding < ' a > {
45
+ fn to_name_binding ( self , arenas : & ' ra ResolverArenas < ' ra > ) -> NameBinding < ' ra > {
46
46
arenas. alloc_name_binding ( NameBindingData {
47
47
kind : NameBindingKind :: Module ( self . 0 ) ,
48
48
ambiguity : None ,
@@ -54,8 +54,8 @@ impl<'a, Id: Into<DefId>> ToNameBinding<'a>
54
54
}
55
55
}
56
56
57
- impl < ' a , Id : Into < DefId > > ToNameBinding < ' a > for ( Res , ty:: Visibility < Id > , Span , LocalExpnId ) {
58
- fn to_name_binding ( self , arenas : & ' a ResolverArenas < ' a > ) -> NameBinding < ' a > {
57
+ impl < ' ra , Id : Into < DefId > > ToNameBinding < ' ra > for ( Res , ty:: Visibility < Id > , Span , LocalExpnId ) {
58
+ fn to_name_binding ( self , arenas : & ' ra ResolverArenas < ' ra > ) -> NameBinding < ' ra > {
59
59
arenas. alloc_name_binding ( NameBindingData {
60
60
kind : NameBindingKind :: Res ( self . 0 ) ,
61
61
ambiguity : None ,
@@ -67,12 +67,12 @@ impl<'a, Id: Into<DefId>> ToNameBinding<'a> for (Res, ty::Visibility<Id>, Span,
67
67
}
68
68
}
69
69
70
- impl < ' a , ' tcx > Resolver < ' a , ' tcx > {
70
+ impl < ' ra , ' tcx > Resolver < ' ra , ' tcx > {
71
71
/// Defines `name` in namespace `ns` of module `parent` to be `def` if it is not yet defined;
72
72
/// otherwise, reports an error.
73
- pub ( crate ) fn define < T > ( & mut self , parent : Module < ' a > , ident : Ident , ns : Namespace , def : T )
73
+ pub ( crate ) fn define < T > ( & mut self , parent : Module < ' ra > , ident : Ident , ns : Namespace , def : T )
74
74
where
75
- T : ToNameBinding < ' a > ,
75
+ T : ToNameBinding < ' ra > ,
76
76
{
77
77
let binding = def. to_name_binding ( self . arenas ) ;
78
78
let key = self . new_disambiguated_key ( ident, ns) ;
@@ -97,7 +97,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
97
97
/// Reachable macros with block module parents exist due to `#[macro_export] macro_rules!`,
98
98
/// but they cannot use def-site hygiene, so the assumption holds
99
99
/// (<https://github.com/rust-lang/rust/pull/77984#issuecomment-712445508>).
100
- pub ( crate ) fn get_nearest_non_block_module ( & mut self , mut def_id : DefId ) -> Module < ' a > {
100
+ pub ( crate ) fn get_nearest_non_block_module ( & mut self , mut def_id : DefId ) -> Module < ' ra > {
101
101
loop {
102
102
match self . get_module ( def_id) {
103
103
Some ( module) => return module,
@@ -106,14 +106,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
106
106
}
107
107
}
108
108
109
- pub ( crate ) fn expect_module ( & mut self , def_id : DefId ) -> Module < ' a > {
109
+ pub ( crate ) fn expect_module ( & mut self , def_id : DefId ) -> Module < ' ra > {
110
110
self . get_module ( def_id) . expect ( "argument `DefId` is not a module" )
111
111
}
112
112
113
113
/// If `def_id` refers to a module (in resolver's sense, i.e. a module item, crate root, enum,
114
114
/// or trait), then this function returns that module's resolver representation, otherwise it
115
115
/// returns `None`.
116
- pub ( crate ) fn get_module ( & mut self , def_id : DefId ) -> Option < Module < ' a > > {
116
+ pub ( crate ) fn get_module ( & mut self , def_id : DefId ) -> Option < Module < ' ra > > {
117
117
if let module @ Some ( ..) = self . module_map . get ( & def_id) {
118
118
return module. copied ( ) ;
119
119
}
@@ -143,7 +143,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
143
143
None
144
144
}
145
145
146
- pub ( crate ) fn expn_def_scope ( & mut self , expn_id : ExpnId ) -> Module < ' a > {
146
+ pub ( crate ) fn expn_def_scope ( & mut self , expn_id : ExpnId ) -> Module < ' ra > {
147
147
match expn_id. expn_data ( ) . macro_def_id {
148
148
Some ( def_id) => self . macro_def_scope ( def_id) ,
149
149
None => expn_id
@@ -153,7 +153,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
153
153
}
154
154
}
155
155
156
- pub ( crate ) fn macro_def_scope ( & mut self , def_id : DefId ) -> Module < ' a > {
156
+ pub ( crate ) fn macro_def_scope ( & mut self , def_id : DefId ) -> Module < ' ra > {
157
157
if let Some ( id) = def_id. as_local ( ) {
158
158
self . local_macro_def_scopes [ & id]
159
159
} else {
@@ -186,15 +186,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
186
186
pub ( crate ) fn build_reduced_graph (
187
187
& mut self ,
188
188
fragment : & AstFragment ,
189
- parent_scope : ParentScope < ' a > ,
190
- ) -> MacroRulesScopeRef < ' a > {
189
+ parent_scope : ParentScope < ' ra > ,
190
+ ) -> MacroRulesScopeRef < ' ra > {
191
191
collect_definitions ( self , fragment, parent_scope. expansion ) ;
192
192
let mut visitor = BuildReducedGraphVisitor { r : self , parent_scope } ;
193
193
fragment. visit_with ( & mut visitor) ;
194
194
visitor. parent_scope . macro_rules
195
195
}
196
196
197
- pub ( crate ) fn build_reduced_graph_external ( & mut self , module : Module < ' a > ) {
197
+ pub ( crate ) fn build_reduced_graph_external ( & mut self , module : Module < ' ra > ) {
198
198
for child in self . tcx . module_children ( module. def_id ( ) ) {
199
199
let parent_scope = ParentScope :: module ( module, self ) ;
200
200
self . build_reduced_graph_for_external_crate_res ( child, parent_scope)
@@ -205,7 +205,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
205
205
fn build_reduced_graph_for_external_crate_res (
206
206
& mut self ,
207
207
child : & ModChild ,
208
- parent_scope : ParentScope < ' a > ,
208
+ parent_scope : ParentScope < ' ra > ,
209
209
) {
210
210
let parent = parent_scope. module ;
211
211
let ModChild { ident, res, vis, ref reexport_chain } = * child;
@@ -273,18 +273,18 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
273
273
}
274
274
}
275
275
276
- struct BuildReducedGraphVisitor < ' a , ' b , ' tcx > {
277
- r : & ' b mut Resolver < ' a , ' tcx > ,
278
- parent_scope : ParentScope < ' a > ,
276
+ struct BuildReducedGraphVisitor < ' a , ' ra , ' tcx > {
277
+ r : & ' a mut Resolver < ' ra , ' tcx > ,
278
+ parent_scope : ParentScope < ' ra > ,
279
279
}
280
280
281
- impl < ' a , ' tcx > AsMut < Resolver < ' a , ' tcx > > for BuildReducedGraphVisitor < ' a , ' _ , ' tcx > {
282
- fn as_mut ( & mut self ) -> & mut Resolver < ' a , ' tcx > {
281
+ impl < ' ra , ' tcx > AsMut < Resolver < ' ra , ' tcx > > for BuildReducedGraphVisitor < ' _ , ' ra , ' tcx > {
282
+ fn as_mut ( & mut self ) -> & mut Resolver < ' ra , ' tcx > {
283
283
self . r
284
284
}
285
285
}
286
286
287
- impl < ' a , ' b , ' tcx > BuildReducedGraphVisitor < ' a , ' b , ' tcx > {
287
+ impl < ' a , ' ra , ' tcx > BuildReducedGraphVisitor < ' a , ' ra , ' tcx > {
288
288
fn res ( & self , def_id : impl Into < DefId > ) -> Res {
289
289
let def_id = def_id. into ( ) ;
290
290
Res :: Def ( self . r . tcx . def_kind ( def_id) , def_id)
@@ -424,7 +424,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
424
424
fn add_import (
425
425
& mut self ,
426
426
module_path : Vec < Segment > ,
427
- kind : ImportKind < ' a > ,
427
+ kind : ImportKind < ' ra > ,
428
428
span : Span ,
429
429
item : & ast:: Item ,
430
430
root_span : Span ,
@@ -752,7 +752,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
752
752
}
753
753
754
754
/// Constructs the reduced graph for one item.
755
- fn build_reduced_graph_for_item ( & mut self , item : & ' b Item ) {
755
+ fn build_reduced_graph_for_item ( & mut self , item : & ' a Item ) {
756
756
let parent_scope = & self . parent_scope ;
757
757
let parent = parent_scope. module ;
758
758
let expansion = parent_scope. expansion ;
@@ -918,7 +918,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
918
918
item : & Item ,
919
919
local_def_id : LocalDefId ,
920
920
vis : ty:: Visibility ,
921
- parent : Module < ' a > ,
921
+ parent : Module < ' ra > ,
922
922
) {
923
923
let ident = item. ident ;
924
924
let sp = item. span ;
@@ -1040,7 +1040,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1040
1040
fn add_macro_use_binding (
1041
1041
& mut self ,
1042
1042
name : Symbol ,
1043
- binding : NameBinding < ' a > ,
1043
+ binding : NameBinding < ' ra > ,
1044
1044
span : Span ,
1045
1045
allow_shadowing : bool ,
1046
1046
) {
@@ -1050,7 +1050,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1050
1050
}
1051
1051
1052
1052
/// Returns `true` if we should consider the underlying `extern crate` to be used.
1053
- fn process_macro_use_imports ( & mut self , item : & Item , module : Module < ' a > ) -> bool {
1053
+ fn process_macro_use_imports ( & mut self , item : & Item , module : Module < ' ra > ) -> bool {
1054
1054
let mut import_all = None ;
1055
1055
let mut single_imports = Vec :: new ( ) ;
1056
1056
for attr in & item. attrs {
@@ -1188,7 +1188,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1188
1188
1189
1189
/// Visit invocation in context in which it can emit a named item (possibly `macro_rules`)
1190
1190
/// directly into its parent scope's module.
1191
- fn visit_invoc_in_module ( & mut self , id : NodeId ) -> MacroRulesScopeRef < ' a > {
1191
+ fn visit_invoc_in_module ( & mut self , id : NodeId ) -> MacroRulesScopeRef < ' ra > {
1192
1192
let invoc_id = self . visit_invoc ( id) ;
1193
1193
self . parent_scope . module . unexpanded_invocations . borrow_mut ( ) . insert ( invoc_id) ;
1194
1194
self . r . arenas . alloc_macro_rules_scope ( MacroRulesScope :: Invocation ( invoc_id) )
@@ -1221,7 +1221,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1221
1221
}
1222
1222
}
1223
1223
1224
- fn define_macro ( & mut self , item : & ast:: Item ) -> MacroRulesScopeRef < ' a > {
1224
+ fn define_macro ( & mut self , item : & ast:: Item ) -> MacroRulesScopeRef < ' ra > {
1225
1225
let parent_scope = self . parent_scope ;
1226
1226
let expansion = parent_scope. expansion ;
1227
1227
let feed = self . r . feed ( item. id ) ;
@@ -1308,7 +1308,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1308
1308
1309
1309
macro_rules! method {
1310
1310
( $visit: ident: $ty: ty, $invoc: path, $walk: ident) => {
1311
- fn $visit( & mut self , node: & ' b $ty) {
1311
+ fn $visit( & mut self , node: & ' a $ty) {
1312
1312
if let $invoc( ..) = node. kind {
1313
1313
self . visit_invoc( node. id) ;
1314
1314
} else {
@@ -1318,12 +1318,12 @@ macro_rules! method {
1318
1318
} ;
1319
1319
}
1320
1320
1321
- impl < ' a , ' b , ' tcx > Visitor < ' b > for BuildReducedGraphVisitor < ' a , ' b , ' tcx > {
1321
+ impl < ' a , ' ra , ' tcx > Visitor < ' a > for BuildReducedGraphVisitor < ' a , ' ra , ' tcx > {
1322
1322
method ! ( visit_expr: ast:: Expr , ast:: ExprKind :: MacCall , walk_expr) ;
1323
1323
method ! ( visit_pat: ast:: Pat , ast:: PatKind :: MacCall , walk_pat) ;
1324
1324
method ! ( visit_ty: ast:: Ty , ast:: TyKind :: MacCall , walk_ty) ;
1325
1325
1326
- fn visit_item ( & mut self , item : & ' b Item ) {
1326
+ fn visit_item ( & mut self , item : & ' a Item ) {
1327
1327
let orig_module_scope = self . parent_scope . module ;
1328
1328
self . parent_scope . macro_rules = match item. kind {
1329
1329
ItemKind :: MacroDef ( ..) => {
@@ -1357,15 +1357,15 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1357
1357
self . parent_scope . module = orig_module_scope;
1358
1358
}
1359
1359
1360
- fn visit_stmt ( & mut self , stmt : & ' b ast:: Stmt ) {
1360
+ fn visit_stmt ( & mut self , stmt : & ' a ast:: Stmt ) {
1361
1361
if let ast:: StmtKind :: MacCall ( ..) = stmt. kind {
1362
1362
self . parent_scope . macro_rules = self . visit_invoc_in_module ( stmt. id ) ;
1363
1363
} else {
1364
1364
visit:: walk_stmt ( self , stmt) ;
1365
1365
}
1366
1366
}
1367
1367
1368
- fn visit_foreign_item ( & mut self , foreign_item : & ' b ForeignItem ) {
1368
+ fn visit_foreign_item ( & mut self , foreign_item : & ' a ForeignItem ) {
1369
1369
if let ForeignItemKind :: MacCall ( _) = foreign_item. kind {
1370
1370
self . visit_invoc_in_module ( foreign_item. id ) ;
1371
1371
return ;
@@ -1375,7 +1375,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1375
1375
visit:: walk_item ( self , foreign_item) ;
1376
1376
}
1377
1377
1378
- fn visit_block ( & mut self , block : & ' b Block ) {
1378
+ fn visit_block ( & mut self , block : & ' a Block ) {
1379
1379
let orig_current_module = self . parent_scope . module ;
1380
1380
let orig_current_macro_rules_scope = self . parent_scope . macro_rules ;
1381
1381
self . build_reduced_graph_for_block ( block) ;
@@ -1384,7 +1384,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1384
1384
self . parent_scope . macro_rules = orig_current_macro_rules_scope;
1385
1385
}
1386
1386
1387
- fn visit_assoc_item ( & mut self , item : & ' b AssocItem , ctxt : AssocCtxt ) {
1387
+ fn visit_assoc_item ( & mut self , item : & ' a AssocItem , ctxt : AssocCtxt ) {
1388
1388
if let AssocItemKind :: MacCall ( _) = item. kind {
1389
1389
match ctxt {
1390
1390
AssocCtxt :: Trait => {
@@ -1440,7 +1440,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1440
1440
visit:: walk_assoc_item ( self , item, ctxt) ;
1441
1441
}
1442
1442
1443
- fn visit_attribute ( & mut self , attr : & ' b ast:: Attribute ) {
1443
+ fn visit_attribute ( & mut self , attr : & ' a ast:: Attribute ) {
1444
1444
if !attr. is_doc_comment ( ) && attr:: is_builtin_attr ( attr) {
1445
1445
self . r
1446
1446
. builtin_attrs
@@ -1449,47 +1449,47 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1449
1449
visit:: walk_attribute ( self , attr) ;
1450
1450
}
1451
1451
1452
- fn visit_arm ( & mut self , arm : & ' b ast:: Arm ) {
1452
+ fn visit_arm ( & mut self , arm : & ' a ast:: Arm ) {
1453
1453
if arm. is_placeholder {
1454
1454
self . visit_invoc ( arm. id ) ;
1455
1455
} else {
1456
1456
visit:: walk_arm ( self , arm) ;
1457
1457
}
1458
1458
}
1459
1459
1460
- fn visit_expr_field ( & mut self , f : & ' b ast:: ExprField ) {
1460
+ fn visit_expr_field ( & mut self , f : & ' a ast:: ExprField ) {
1461
1461
if f. is_placeholder {
1462
1462
self . visit_invoc ( f. id ) ;
1463
1463
} else {
1464
1464
visit:: walk_expr_field ( self , f) ;
1465
1465
}
1466
1466
}
1467
1467
1468
- fn visit_pat_field ( & mut self , fp : & ' b ast:: PatField ) {
1468
+ fn visit_pat_field ( & mut self , fp : & ' a ast:: PatField ) {
1469
1469
if fp. is_placeholder {
1470
1470
self . visit_invoc ( fp. id ) ;
1471
1471
} else {
1472
1472
visit:: walk_pat_field ( self , fp) ;
1473
1473
}
1474
1474
}
1475
1475
1476
- fn visit_generic_param ( & mut self , param : & ' b ast:: GenericParam ) {
1476
+ fn visit_generic_param ( & mut self , param : & ' a ast:: GenericParam ) {
1477
1477
if param. is_placeholder {
1478
1478
self . visit_invoc ( param. id ) ;
1479
1479
} else {
1480
1480
visit:: walk_generic_param ( self , param) ;
1481
1481
}
1482
1482
}
1483
1483
1484
- fn visit_param ( & mut self , p : & ' b ast:: Param ) {
1484
+ fn visit_param ( & mut self , p : & ' a ast:: Param ) {
1485
1485
if p. is_placeholder {
1486
1486
self . visit_invoc ( p. id ) ;
1487
1487
} else {
1488
1488
visit:: walk_param ( self , p) ;
1489
1489
}
1490
1490
}
1491
1491
1492
- fn visit_field_def ( & mut self , sf : & ' b ast:: FieldDef ) {
1492
+ fn visit_field_def ( & mut self , sf : & ' a ast:: FieldDef ) {
1493
1493
if sf. is_placeholder {
1494
1494
self . visit_invoc ( sf. id ) ;
1495
1495
} else {
@@ -1501,7 +1501,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1501
1501
1502
1502
// Constructs the reduced graph for one variant. Variants exist in the
1503
1503
// type and value namespaces.
1504
- fn visit_variant ( & mut self , variant : & ' b ast:: Variant ) {
1504
+ fn visit_variant ( & mut self , variant : & ' a ast:: Variant ) {
1505
1505
if variant. is_placeholder {
1506
1506
self . visit_invoc_in_module ( variant. id ) ;
1507
1507
return ;
@@ -1542,7 +1542,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1542
1542
visit:: walk_variant ( self , variant) ;
1543
1543
}
1544
1544
1545
- fn visit_crate ( & mut self , krate : & ' b ast:: Crate ) {
1545
+ fn visit_crate ( & mut self , krate : & ' a ast:: Crate ) {
1546
1546
if krate. is_placeholder {
1547
1547
self . visit_invoc_in_module ( krate. id ) ;
1548
1548
} else {
0 commit comments