Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3508874

Browse files
committedApr 15, 2017
Remove assumption that region_maps arg is fn id
1 parent ec23e3f commit 3508874

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
@@ -663,17 +663,18 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
663663
local as usize == global as usize
664664
}
665665

666-
pub fn region_maps(self, fn_id: NodeId) -> Rc<RegionMaps> {
667-
// Find the `NodeId` of the outermost function that wraps the function pointed to by fn_id
668-
let mut outermost_fn_id = fn_id;
666+
pub fn region_maps(self, node_id: NodeId) -> Rc<RegionMaps> {
667+
// Find the `NodeId` of the outermost function that wraps the node pointed to by node_id
668+
let mut outermost_fn_id_opt = None;
669669
let mut outermost_id = fn_id;
670670
loop {
671-
let next_id = self.hir.get_parent(outermost_id);
672-
if outermost_id == next_id { break; }
673671
if self.hir.is_fn(outermost_id) {
674-
outermost_fn_id = outermost_id;
672+
outermost_fn_id_opt = Some(outermost_id);
675673
}
674+
let next_id = self.hir.get_parent(outermost_id);
675+
if outermost_id == next_id { break; }
676676
}
677+
let outermost_fn_id = outermost_fn_id_opt.expect("node_id should point inside a fn");
677678

678679
ty::queries::region_resolve_fn::get(self, DUMMY_SP, self.hir.local_def_id(outermost_fn_id))
679680
}

0 commit comments

Comments
 (0)
Please sign in to comment.