Skip to content

Commit

Permalink
Remove assumption that region_maps arg is fn id
Browse files Browse the repository at this point in the history
  • Loading branch information
cramertj committed Apr 15, 2017
1 parent ec23e3f commit 3508874
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,17 +663,18 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
local as usize == global as usize
}

pub fn region_maps(self, fn_id: NodeId) -> Rc<RegionMaps> {
// Find the `NodeId` of the outermost function that wraps the function pointed to by fn_id
let mut outermost_fn_id = fn_id;
pub fn region_maps(self, node_id: NodeId) -> Rc<RegionMaps> {
// Find the `NodeId` of the outermost function that wraps the node pointed to by node_id
let mut outermost_fn_id_opt = None;
let mut outermost_id = fn_id;
loop {
let next_id = self.hir.get_parent(outermost_id);
if outermost_id == next_id { break; }
if self.hir.is_fn(outermost_id) {
outermost_fn_id = outermost_id;
outermost_fn_id_opt = Some(outermost_id);
}
let next_id = self.hir.get_parent(outermost_id);
if outermost_id == next_id { break; }
}
let outermost_fn_id = outermost_fn_id_opt.expect("node_id should point inside a fn");

ty::queries::region_resolve_fn::get(self, DUMMY_SP, self.hir.local_def_id(outermost_fn_id))
}
Expand Down

0 comments on commit 3508874

Please sign in to comment.