@@ -303,7 +303,7 @@ struct RegionResolutionVisitor<'a, 'tcx: 'a> {
303
303
/// destructor's execution.
304
304
terminating_scopes : NodeSet ,
305
305
306
- target_fn_id : DefId ,
306
+ target_fn_node_id : NodeId ,
307
307
308
308
found_target_fn : bool ,
309
309
}
@@ -1037,7 +1037,7 @@ fn resolve_fn<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>,
1037
1037
visitor. cx . parent = Some ( visitor. new_code_extent (
1038
1038
CodeExtentData :: CallSiteScope { fn_id : id, body_id : body_id. node_id } ) ) ;
1039
1039
1040
- if body_id == visitor. target_fn_id {
1040
+ if id == visitor. target_fn_node_id {
1041
1041
// We've found the top level `fn`. Store it and its children in the `RegionMaps`
1042
1042
visitor. found_target_fn = true ;
1043
1043
}
@@ -1170,8 +1170,23 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> {
1170
1170
}
1171
1171
}
1172
1172
1173
- pub fn resolve_crate < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ) -> Rc < RegionMaps < ' tcx > > {
1174
- ty:: queries:: region_resolve_fn:: get ( tcx, DUMMY_SP , LOCAL_CRATE )
1173
+ pub fn resolve_crate < ' a , ' tcx : ' a > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ) {
1174
+
1175
+ struct CrateResolutionVisitor < ' a , ' tcx : ' a > ( TyCtxt < ' a , ' tcx , ' tcx > ) ;
1176
+
1177
+ impl < ' a , ' hir : ' a > Visitor < ' hir > for CrateResolutionVisitor < ' a , ' hir > {
1178
+ fn nested_visit_map < ' this > ( & ' this mut self ) -> NestedVisitorMap < ' this , ' hir > {
1179
+ NestedVisitorMap :: OnlyBodies ( & self . 0 . hir )
1180
+ }
1181
+ fn visit_fn ( & mut self , _fk : FnKind < ' hir > , _fd : & ' hir FnDecl ,
1182
+ _b : hir:: BodyId , _s : Span , fn_id : NodeId )
1183
+ {
1184
+ let fn_def_id = self . 0 . hir . local_def_id ( fn_id) ;
1185
+ ty:: queries:: region_resolve_fn:: get ( self . 0 , DUMMY_SP , fn_def_id) ;
1186
+ }
1187
+ }
1188
+
1189
+ tcx. hir . krate ( ) . visit_all_item_likes ( & mut CrateResolutionVisitor ( tcx) . as_deep_visitor ( ) ) ;
1175
1190
}
1176
1191
1177
1192
fn region_resolve_fn < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , fn_id : DefId )
@@ -1202,7 +1217,8 @@ fn region_resolve_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_id: DefId)
1202
1217
var_parent : None ,
1203
1218
} ,
1204
1219
terminating_scopes : NodeSet ( ) ,
1205
- target_fn_id : fn_id,
1220
+ target_fn_node_id : hir_map. as_local_node_id ( fn_id)
1221
+ . expect ( "fn DefId should be for LOCAL_CRATE" ) ,
1206
1222
found_target_fn : false ,
1207
1223
} ;
1208
1224
krate. visit_all_item_likes ( & mut visitor. as_deep_visitor ( ) ) ;
0 commit comments