@@ -20,7 +20,6 @@ use rustc_errors::DiagnosticId;
20
20
use rustc_hir:: def:: Namespace :: { self , * } ;
21
21
use rustc_hir:: def:: { self , CtorKind , DefKind , LifetimeRes , PartialRes , PerNS } ;
22
22
use rustc_hir:: def_id:: { DefId , LocalDefId , CRATE_DEF_ID } ;
23
- use rustc_hir:: definitions:: DefPathData ;
24
23
use rustc_hir:: { PrimTy , TraitCandidate } ;
25
24
use rustc_index:: vec:: Idx ;
26
25
use rustc_middle:: ty:: DefIdTree ;
@@ -1418,31 +1417,20 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1418
1417
}
1419
1418
1420
1419
#[ tracing:: instrument( level = "debug" , skip( self ) ) ]
1421
- fn create_fresh_lifetime (
1422
- & mut self ,
1423
- id : NodeId ,
1424
- ident : Ident ,
1425
- item_node_id : NodeId ,
1426
- ) -> LifetimeRes {
1420
+ fn create_fresh_lifetime ( & mut self , id : NodeId , ident : Ident , binder : NodeId ) -> LifetimeRes {
1427
1421
debug_assert_eq ! ( ident. name, kw:: UnderscoreLifetime ) ;
1428
1422
debug ! ( ?ident. span) ;
1429
- let item_def_id = self . r . local_def_id ( item_node_id) ;
1430
- let def_node_id = self . r . next_node_id ( ) ;
1431
- let def_id = self . r . create_def (
1432
- item_def_id,
1433
- def_node_id,
1434
- DefPathData :: LifetimeNs ( kw:: UnderscoreLifetime ) ,
1435
- self . parent_scope . expansion . to_expn_id ( ) ,
1436
- ident. span ,
1437
- ) ;
1438
- debug ! ( ?def_id) ;
1439
1423
1440
- let res = LifetimeRes :: Fresh { param : def_id, binder : item_node_id } ;
1441
- self . r . extra_lifetime_params_map . entry ( item_node_id) . or_insert_with ( Vec :: new) . push ( (
1442
- ident,
1443
- def_node_id,
1444
- res,
1445
- ) ) ;
1424
+ // Leave the responsibility to create the `LocalDefId` to lowering.
1425
+ let param = self . r . next_node_id ( ) ;
1426
+ let res = LifetimeRes :: Fresh { param, binder } ;
1427
+
1428
+ // Record the created lifetime parameter so lowering can pick it up and add it to HIR.
1429
+ self . r
1430
+ . extra_lifetime_params_map
1431
+ . entry ( binder)
1432
+ . or_insert_with ( Vec :: new)
1433
+ . push ( ( ident, param, res) ) ;
1446
1434
res
1447
1435
}
1448
1436
0 commit comments