@@ -20,7 +20,6 @@ use rustc_errors::DiagnosticId;
2020use rustc_hir:: def:: Namespace :: { self , * } ;
2121use rustc_hir:: def:: { self , CtorKind , DefKind , LifetimeRes , PartialRes , PerNS } ;
2222use rustc_hir:: def_id:: { DefId , LocalDefId , CRATE_DEF_ID } ;
23- use rustc_hir:: definitions:: DefPathData ;
2423use rustc_hir:: { PrimTy , TraitCandidate } ;
2524use rustc_index:: vec:: Idx ;
2625use rustc_middle:: ty:: DefIdTree ;
@@ -1418,31 +1417,20 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
14181417 }
14191418
14201419 #[ 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 {
14271421 debug_assert_eq ! ( ident. name, kw:: UnderscoreLifetime ) ;
14281422 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) ;
14391423
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) ) ;
14461434 res
14471435 }
14481436
0 commit comments