@@ -1098,7 +1098,7 @@ pub struct Resolver<'a, 'tcx> {
10981098
10991099 next_node_id : NodeId ,
11001100
1101- node_id_to_def_id : NodeMap < LocalDefId > ,
1101+ node_id_to_def_id : NodeMap < Feed < ' tcx , LocalDefId > > ,
11021102 def_id_to_node_id : IndexVec < LocalDefId , ast:: NodeId > ,
11031103
11041104 /// Indices of unnamed struct or variant fields with unresolved attributes.
@@ -1214,11 +1214,19 @@ impl<'a, 'tcx> AsMut<Resolver<'a, 'tcx>> for Resolver<'a, 'tcx> {
12141214
12151215impl < ' tcx > Resolver < ' _ , ' tcx > {
12161216 fn opt_local_def_id ( & self , node : NodeId ) -> Option < LocalDefId > {
1217- self . node_id_to_def_id . get ( & node) . copied ( )
1217+ self . opt_feed ( node) . map ( |f| f . key ( ) )
12181218 }
12191219
12201220 fn local_def_id ( & self , node : NodeId ) -> LocalDefId {
1221- self . opt_local_def_id ( node) . unwrap_or_else ( || panic ! ( "no entry for node id: `{node:?}`" ) )
1221+ self . feed ( node) . key ( )
1222+ }
1223+
1224+ fn opt_feed ( & self , node : NodeId ) -> Option < Feed < ' tcx , LocalDefId > > {
1225+ self . node_id_to_def_id . get ( & node) . copied ( )
1226+ }
1227+
1228+ fn feed ( & self , node : NodeId ) -> Feed < ' tcx , LocalDefId > {
1229+ self . opt_feed ( node) . unwrap_or_else ( || panic ! ( "no entry for node id: `{node:?}`" ) )
12221230 }
12231231
12241232 fn local_def_kind ( & self , node : NodeId ) -> DefKind {
@@ -1241,7 +1249,7 @@ impl<'tcx> Resolver<'_, 'tcx> {
12411249 "adding a def'n for node-id {:?} and data {:?} but a previous def'n exists: {:?}" ,
12421250 node_id,
12431251 data,
1244- self . tcx. definitions_untracked( ) . def_key( self . node_id_to_def_id[ & node_id] ) ,
1252+ self . tcx. definitions_untracked( ) . def_key( self . node_id_to_def_id[ & node_id] . key ( ) ) ,
12451253 ) ;
12461254
12471255 // FIXME: remove `def_span` body, pass in the right spans here and call `tcx.at().create_def()`
@@ -1263,7 +1271,7 @@ impl<'tcx> Resolver<'_, 'tcx> {
12631271 // we don't need a mapping from `NodeId` to `LocalDefId`.
12641272 if node_id != ast:: DUMMY_NODE_ID {
12651273 debug ! ( "create_def: def_id_to_node_id[{:?}] <-> {:?}" , def_id, node_id) ;
1266- self . node_id_to_def_id . insert ( node_id, def_id ) ;
1274+ self . node_id_to_def_id . insert ( node_id, feed . downgrade ( ) ) ;
12671275 }
12681276 assert_eq ! ( self . def_id_to_node_id. push( node_id) , def_id) ;
12691277
@@ -1315,7 +1323,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
13151323 let mut def_id_to_node_id = IndexVec :: default ( ) ;
13161324 assert_eq ! ( def_id_to_node_id. push( CRATE_NODE_ID ) , CRATE_DEF_ID ) ;
13171325 let mut node_id_to_def_id = NodeMap :: default ( ) ;
1318- node_id_to_def_id. insert ( CRATE_NODE_ID , CRATE_DEF_ID ) ;
1326+ let crate_feed = tcx. feed_local_def_id ( CRATE_DEF_ID ) . downgrade ( ) ;
1327+ node_id_to_def_id. insert ( CRATE_NODE_ID , crate_feed) ;
13191328
13201329 let mut invocation_parents = FxHashMap :: default ( ) ;
13211330 invocation_parents. insert ( LocalExpnId :: ROOT , ( CRATE_DEF_ID , ImplTraitContext :: Existential ) ) ;
@@ -1531,7 +1540,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
15311540
15321541 self . tcx . feed_local_crate ( ) . stripped_cfg_items ( self . tcx . arena . alloc_from_iter (
15331542 self . stripped_cfg_items . into_iter ( ) . filter_map ( |item| {
1534- let parent_module = self . node_id_to_def_id . get ( & item. parent_module ) ?. to_def_id ( ) ;
1543+ let parent_module =
1544+ self . node_id_to_def_id . get ( & item. parent_module ) ?. key ( ) . to_def_id ( ) ;
15351545 Some ( StrippedCfgItem { parent_module, name : item. name , cfg : item. cfg } )
15361546 } ) ,
15371547 ) ) ;
@@ -1560,7 +1570,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
15601570 lifetimes_res_map : self . lifetimes_res_map ,
15611571 extra_lifetime_params_map : self . extra_lifetime_params_map ,
15621572 next_node_id : self . next_node_id ,
1563- node_id_to_def_id : self . node_id_to_def_id ,
1573+ node_id_to_def_id : self
1574+ . node_id_to_def_id
1575+ . into_items ( )
1576+ . map ( |( k, f) | ( k, f. key ( ) ) )
1577+ . collect ( ) ,
15641578 def_id_to_node_id : self . def_id_to_node_id ,
15651579 trait_map : self . trait_map ,
15661580 lifetime_elision_allowed : self . lifetime_elision_allowed ,
0 commit comments