@@ -264,12 +264,10 @@ struct RegionResolutionVisitor<'a, 'tcx: 'a> {
264
264
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
265
265
266
266
// Generated maps:
267
- region_maps : & ' a mut RegionMaps ,
267
+ region_maps : RegionMaps ,
268
268
269
269
cx : Context ,
270
270
271
- map : & ' a hir_map:: Map < ' tcx > ,
272
-
273
271
/// `terminating_scopes` is a set containing the ids of each
274
272
/// statement, or conditional/repeating expression. These scopes
275
273
/// are calling "terminating scopes" because, when attempting to
@@ -1105,7 +1103,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> {
1105
1103
1106
1104
fn visit_body ( & mut self , body : & ' tcx hir:: Body ) {
1107
1105
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) ;
1109
1107
1110
1108
debug ! ( "visit_body(id={:?}, span={:?}, body.id={:?}, cx.parent={:?})" ,
1111
1109
owner_id,
@@ -1170,37 +1168,38 @@ fn region_maps<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
1170
1168
return tcx. region_maps ( closure_base_def_id) ;
1171
1169
}
1172
1170
1173
- let mut maps = RegionMaps :: new ( ) ;
1174
-
1175
1171
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) ;
1178
1185
1179
1186
// If the item is an associated const or a method,
1180
1187
// record its impl/trait parent, as it can also have
1181
1188
// lifetime parameters free in this body.
1182
1189
match tcx. hir . get ( id) {
1183
1190
hir:: map:: NodeImplItem ( _) |
1184
1191
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) ) ;
1186
1193
}
1187
1194
_ => { }
1188
1195
}
1189
1196
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
-
1202
1197
visitor. visit_body ( tcx. hir . body ( body) ) ;
1203
- }
1198
+
1199
+ visitor. region_maps
1200
+ } else {
1201
+ RegionMaps :: new ( )
1202
+ } ;
1204
1203
1205
1204
Rc :: new ( maps)
1206
1205
}
0 commit comments