@@ -1098,7 +1098,7 @@ pub struct Resolver<'a, 'tcx> {
1098
1098
1099
1099
next_node_id : NodeId ,
1100
1100
1101
- node_id_to_def_id : NodeMap < LocalDefId > ,
1101
+ node_id_to_def_id : NodeMap < Feed < ' tcx , LocalDefId > > ,
1102
1102
def_id_to_node_id : IndexVec < LocalDefId , ast:: NodeId > ,
1103
1103
1104
1104
/// 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> {
1214
1214
1215
1215
impl < ' tcx > Resolver < ' _ , ' tcx > {
1216
1216
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 ( ) )
1218
1218
}
1219
1219
1220
1220
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:?}`" ) )
1222
1230
}
1223
1231
1224
1232
fn local_def_kind ( & self , node : NodeId ) -> DefKind {
@@ -1241,7 +1249,7 @@ impl<'tcx> Resolver<'_, 'tcx> {
1241
1249
"adding a def'n for node-id {:?} and data {:?} but a previous def'n exists: {:?}" ,
1242
1250
node_id,
1243
1251
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 ( ) ) ,
1245
1253
) ;
1246
1254
1247
1255
// 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> {
1263
1271
// we don't need a mapping from `NodeId` to `LocalDefId`.
1264
1272
if node_id != ast:: DUMMY_NODE_ID {
1265
1273
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 ( ) ) ;
1267
1275
}
1268
1276
assert_eq ! ( self . def_id_to_node_id. push( node_id) , def_id) ;
1269
1277
@@ -1315,13 +1323,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1315
1323
let mut def_id_to_node_id = IndexVec :: default ( ) ;
1316
1324
assert_eq ! ( def_id_to_node_id. push( CRATE_NODE_ID ) , CRATE_DEF_ID ) ;
1317
1325
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) ;
1319
1328
1320
1329
let mut invocation_parents = FxHashMap :: default ( ) ;
1321
- invocation_parents. insert (
1322
- LocalExpnId :: ROOT ,
1323
- ( tcx. feed_local_def_id ( CRATE_DEF_ID ) . downgrade ( ) , ImplTraitContext :: Existential ) ,
1324
- ) ;
1330
+ invocation_parents. insert ( LocalExpnId :: ROOT , ( crate_feed, ImplTraitContext :: Existential ) ) ;
1325
1331
1326
1332
let mut extern_prelude: FxHashMap < Ident , ExternPreludeEntry < ' _ > > = tcx
1327
1333
. sess
@@ -1534,7 +1540,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1534
1540
1535
1541
self . tcx . feed_local_crate ( ) . stripped_cfg_items ( self . tcx . arena . alloc_from_iter (
1536
1542
self . stripped_cfg_items . into_iter ( ) . filter_map ( |item| {
1537
- 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 ( ) ;
1538
1545
Some ( StrippedCfgItem { parent_module, name : item. name , cfg : item. cfg } )
1539
1546
} ) ,
1540
1547
) ) ;
@@ -1563,7 +1570,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1563
1570
lifetimes_res_map : self . lifetimes_res_map ,
1564
1571
extra_lifetime_params_map : self . extra_lifetime_params_map ,
1565
1572
next_node_id : self . next_node_id ,
1566
- 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 ( ) ,
1567
1578
def_id_to_node_id : self . def_id_to_node_id ,
1568
1579
trait_map : self . trait_map ,
1569
1580
lifetime_elision_allowed : self . lifetime_elision_allowed ,
0 commit comments