@@ -348,7 +348,7 @@ struct RegionResolutionVisitor<'hir: 'a, 'a> {
348
348
/// destructor's execution.
349
349
terminating_scopes : NodeSet ,
350
350
351
- target_fn_id : DefId ,
351
+ target_fn_node_id : NodeId ,
352
352
353
353
found_target_fn : bool ,
354
354
}
@@ -1142,11 +1142,10 @@ fn resolve_fn<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'tcx, 'a>,
1142
1142
body_id : hir:: BodyId ,
1143
1143
sp : Span ,
1144
1144
id : ast:: NodeId ) {
1145
-
1146
1145
visitor. cx . parent = visitor. new_code_extent (
1147
1146
CodeExtentData :: CallSiteScope { fn_id : id, body_id : body_id. node_id } ) ;
1148
1147
1149
- if body_id == visitor. target_fn_id {
1148
+ if id == visitor. target_fn_node_id {
1150
1149
// We've found the top level `fn`. Store it and its children in the `RegionMaps`
1151
1150
visitor. found_target_fn = true ;
1152
1151
}
@@ -1270,8 +1269,23 @@ impl<'hir, 'a> Visitor<'hir> for RegionResolutionVisitor<'hir, 'a> {
1270
1269
}
1271
1270
}
1272
1271
1273
- pub fn resolve_crate < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ) -> Rc < RegionMaps > {
1274
- ty:: queries:: region_resolve_fn:: get ( tcx, DUMMY_SP , LOCAL_CRATE )
1272
+ pub fn resolve_crate < ' a , ' tcx : ' a > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ) {
1273
+
1274
+ struct CrateResolutionVisitor < ' a , ' tcx : ' a > ( TyCtxt < ' a , ' tcx , ' tcx > ) ;
1275
+
1276
+ impl < ' a , ' hir : ' a > Visitor < ' hir > for CrateResolutionVisitor < ' a , ' hir > {
1277
+ fn nested_visit_map < ' this > ( & ' this mut self ) -> NestedVisitorMap < ' this , ' hir > {
1278
+ NestedVisitorMap :: OnlyBodies ( & self . 0 . hir )
1279
+ }
1280
+ fn visit_fn ( & mut self , _fk : FnKind < ' hir > , _fd : & ' hir FnDecl ,
1281
+ _b : hir:: BodyId , _s : Span , fn_id : NodeId )
1282
+ {
1283
+ let fn_def_id = self . 0 . hir . local_def_id ( fn_id) ;
1284
+ ty:: queries:: region_resolve_fn:: get ( self . 0 , DUMMY_SP , fn_def_id) ;
1285
+ }
1286
+ }
1287
+
1288
+ tcx. hir . krate ( ) . visit_all_item_likes ( & mut CrateResolutionVisitor ( tcx) . as_deep_visitor ( ) ) ;
1275
1289
}
1276
1290
1277
1291
fn region_resolve_fn < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , fn_id : DefId )
@@ -1308,7 +1322,8 @@ fn region_resolve_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_id: DefId)
1308
1322
var_parent : ROOT_CODE_EXTENT
1309
1323
} ,
1310
1324
terminating_scopes : NodeSet ( ) ,
1311
- target_fn_id : fn_id,
1325
+ target_fn_node_id : hir_map. as_local_node_id ( fn_id)
1326
+ . expect ( "fn DefId should be for LOCAL_CRATE" ) ,
1312
1327
found_target_fn : false ,
1313
1328
} ;
1314
1329
krate. visit_all_item_likes ( & mut visitor. as_deep_visitor ( ) ) ;
0 commit comments