@@ -264,12 +264,10 @@ struct RegionResolutionVisitor<'a, 'tcx: 'a> {
264264 tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
265265
266266 // Generated maps:
267- region_maps : & ' a mut RegionMaps ,
267+ region_maps : RegionMaps ,
268268
269269 cx : Context ,
270270
271- map : & ' a hir_map:: Map < ' tcx > ,
272-
273271 /// `terminating_scopes` is a set containing the ids of each
274272 /// statement, or conditional/repeating expression. These scopes
275273 /// are calling "terminating scopes" because, when attempting to
@@ -1105,7 +1103,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> {
11051103
11061104 fn visit_body ( & mut self , body : & ' tcx hir:: Body ) {
11071105 let body_id = body. id ( ) ;
1108- let owner_id = self . map . body_owner ( body_id) ;
1106+ let owner_id = self . tcx . hir . body_owner ( body_id) ;
11091107
11101108 debug ! ( "visit_body(id={:?}, span={:?}, body.id={:?}, cx.parent={:?})" ,
11111109 owner_id,
@@ -1170,37 +1168,38 @@ fn region_maps<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
11701168 return tcx. region_maps ( closure_base_def_id) ;
11711169 }
11721170
1173- let mut maps = RegionMaps :: new ( ) ;
1174-
11751171 let id = tcx. hir . as_local_node_id ( def_id) . unwrap ( ) ;
1176- if let Some ( body) = tcx. hir . maybe_body_owned_by ( id) {
1177- maps. root_body = Some ( body) ;
1172+ let maps = if let Some ( body) = tcx. hir . maybe_body_owned_by ( id) {
1173+ let mut visitor = RegionResolutionVisitor {
1174+ tcx,
1175+ region_maps : RegionMaps :: new ( ) ,
1176+ cx : Context {
1177+ root_id : None ,
1178+ parent : None ,
1179+ var_parent : None ,
1180+ } ,
1181+ terminating_scopes : NodeSet ( ) ,
1182+ } ;
1183+
1184+ visitor. region_maps . root_body = Some ( body) ;
11781185
11791186 // If the item is an associated const or a method,
11801187 // record its impl/trait parent, as it can also have
11811188 // lifetime parameters free in this body.
11821189 match tcx. hir . get ( id) {
11831190 hir:: map:: NodeImplItem ( _) |
11841191 hir:: map:: NodeTraitItem ( _) => {
1185- maps . root_parent = Some ( tcx. hir . get_parent ( id) ) ;
1192+ visitor . region_maps . root_parent = Some ( tcx. hir . get_parent ( id) ) ;
11861193 }
11871194 _ => { }
11881195 }
11891196
1190- let mut visitor = RegionResolutionVisitor {
1191- tcx : tcx,
1192- region_maps : & mut maps,
1193- map : & tcx. hir ,
1194- cx : Context {
1195- root_id : None ,
1196- parent : None ,
1197- var_parent : None ,
1198- } ,
1199- terminating_scopes : NodeSet ( ) ,
1200- } ;
1201-
12021197 visitor. visit_body ( tcx. hir . body ( body) ) ;
1203- }
1198+
1199+ visitor. region_maps
1200+ } else {
1201+ RegionMaps :: new ( )
1202+ } ;
12041203
12051204 Rc :: new ( maps)
12061205}
0 commit comments