Skip to content

Commit 800b783

Browse files
cramertjnikomatsakis
authored andcommitted
Remove assumption that region_maps arg is fn id
1 parent f242329 commit 800b783

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/librustc/ty/context.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -698,17 +698,18 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
698698
local as usize == global as usize
699699
}
700700

701-
pub fn region_maps(self, fn_id: NodeId) -> Rc<RegionMaps<'tcx>> {
702-
// Find the `NodeId` of the outermost function that wraps the function pointed to by fn_id
703-
let mut outermost_fn_id = fn_id;
701+
pub fn region_maps(self, node_id: NodeId) -> Rc<RegionMaps<'tcx>> {
702+
// Find the `NodeId` of the outermost function that wraps the node pointed to by node_id
703+
let mut outermost_fn_id_opt = None;
704704
let mut outermost_id = fn_id;
705705
loop {
706-
let next_id = self.hir.get_parent(outermost_id);
707-
if outermost_id == next_id { break; }
708706
if self.hir.is_fn(outermost_id) {
709-
outermost_fn_id = outermost_id;
707+
outermost_fn_id_opt = Some(outermost_id);
710708
}
709+
let next_id = self.hir.get_parent(outermost_id);
710+
if outermost_id == next_id { break; }
711711
}
712+
let outermost_fn_id = outermost_fn_id_opt.expect("node_id should point inside a fn");
712713

713714
ty::queries::region_resolve_fn::get(self, DUMMY_SP, self.hir.local_def_id(outermost_fn_id))
714715
}

0 commit comments

Comments
 (0)