Skip to content

Commit 3438cda

Browse files
committed
use closure_base_def_id rather than walking up HIR
1 parent c0434e2 commit 3438cda

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/librustc/middle/region.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -1188,20 +1188,17 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> {
11881188
fn region_maps<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_id: DefId)
11891189
-> Rc<RegionMaps<'tcx>>
11901190
{
1191-
let fn_node_id = tcx.hir.as_local_node_id(fn_id)
1192-
.expect("fn DefId should be for LOCAL_CRATE");
1193-
let node = tcx.hir.get(fn_node_id);
1194-
match node {
1195-
hir_map::NodeItem(_) | hir_map::NodeTraitItem(_) | hir_map::NodeImplItem(_) => { }
1196-
_ => {
1197-
let parent_id = tcx.hir.get_parent(fn_node_id);
1198-
let parent_def_id = tcx.hir.local_def_id(parent_id);
1199-
return tcx.region_maps(parent_def_id);
1200-
}
1191+
let closure_base_def_id = tcx.closure_base_def_id(fn_id);
1192+
if closure_base_def_id != fn_id {
1193+
return tcx.region_maps(closure_base_def_id);
12011194
}
12021195

12031196
let mut maps = RegionMaps::new();
12041197

1198+
let fn_node_id = tcx.hir.as_local_node_id(fn_id)
1199+
.expect("fn DefId should be for LOCAL_CRATE");
1200+
let node = tcx.hir.get(fn_node_id);
1201+
12051202
{
12061203
let mut visitor = RegionResolutionVisitor {
12071204
tcx: tcx,

0 commit comments

Comments
 (0)