Skip to content

Commit

Permalink
Add ids to several region_maps calls
Browse files Browse the repository at this point in the history
  • Loading branch information
cramertj committed Apr 15, 2017
1 parent 3508874 commit b95e875
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/librustc/infer/region_inference/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,8 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
// A "free" region can be interpreted as "some region
// at least as big as the block fr.scope_id". So, we can
// reasonably compare free regions and scopes:
let r_id = self.tcx.region_maps().nearest_common_ancestor(fr.scope, s_id);
let r_id = self.tcx.region_maps()
.nearest_common_ancestor(fr.scope, s_id);

if r_id == fr.scope {
// if the free region's scope `fr.scope_id` is bigger than
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
// and must outlive the *call-site* of the function.
let fn_ret =
self.ir.tcx.liberate_late_bound_regions(
self.ir.tcx.region_maps().call_site_extent(id, body.value.id),
self.ir.tcx.region_maps(id).call_site_extent(id, body.value.id),
&fn_ret);

if !fn_ret.is_never() && self.live_on_entry(entry_ln, self.s.no_ret_var).is_some() {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
// The environment of a closure is guaranteed to
// outlive any bindings introduced in the body of the
// closure itself.
scope: self.tcx().region_maps().item_extent(fn_body_id),
scope: self.tcx().region_maps(fn_body_id).item_extent(fn_body_id),
bound_region: ty::BrEnv
}));

Expand Down Expand Up @@ -842,7 +842,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
pub fn temporary_scope(&self, id: ast::NodeId) -> (&'tcx ty::Region, &'tcx ty::Region)
{
let (scope, old_scope) =
self.tcx().region_maps().old_and_new_temporary_scope(id);
self.tcx().region_maps(id).old_and_new_temporary_scope(id);
(self.tcx().mk_region(match scope {
Some(scope) => ty::ReScope(scope),
None => ty::ReStatic
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/traits/object_safety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {

// Search for a predicate like `Self : Sized` amongst the trait bounds.
let free_substs = self.construct_free_substs(def_id,
self.region_maps().node_extent(ast::DUMMY_NODE_ID));
self.region_maps(self.hir.as_local_node_id(def_id).unwrap())
.node_extent(ast::DUMMY_NODE_ID));
let predicates = self.item_predicates(def_id);
let predicates = predicates.instantiate(self, free_substs).predicates;
elaborate_predicates(self, predicates)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
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;
let mut outermost_id = node_id;
loop {
if self.hir.is_fn(outermost_id) {
outermost_fn_id_opt = Some(outermost_id);
Expand Down
22 changes: 12 additions & 10 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,13 +1212,14 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
let impl_def_id = tcx.hir.local_def_id(impl_id);
tcx.construct_parameter_environment(impl_item.span,
impl_def_id,
tcx.region_maps().item_extent(id))
tcx.region_maps(impl_id)
.item_extent(id))
}
hir::ImplItemKind::Method(_, ref body) => {
tcx.construct_parameter_environment(
impl_item.span,
tcx.hir.local_def_id(id),
tcx.region_maps().call_site_extent(id, body.node_id))
tcx.region_maps(id).call_site_extent(id, body.node_id))
}
}
}
Expand All @@ -1231,18 +1232,19 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
let trait_def_id = tcx.hir.local_def_id(trait_id);
tcx.construct_parameter_environment(trait_item.span,
trait_def_id,
tcx.region_maps().item_extent(id))
tcx.region_maps(id).item_extent(id))
}
hir::TraitItemKind::Method(_, ref body) => {
// Use call-site for extent (unless this is a
// trait method with no default; then fallback
// to the method id).
let extent = if let hir::TraitMethod::Provided(body_id) = *body {
// default impl: use call_site extent as free_id_outlive bound.
tcx.region_maps().call_site_extent(id, body_id.node_id)
tcx.region_maps(body_id.node_id)
.call_site_extent(id, body_id.node_id)
} else {
// no default impl: use item extent as free_id_outlive bound.
tcx.region_maps().item_extent(id)
tcx.region_maps(id).item_extent(id)
};
tcx.construct_parameter_environment(
trait_item.span,
Expand All @@ -1260,7 +1262,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
tcx.construct_parameter_environment(
item.span,
fn_def_id,
tcx.region_maps().call_site_extent(id, body_id.node_id))
tcx.region_maps(body_id.node_id).call_site_extent(id, body_id.node_id))
}
hir::ItemEnum(..) |
hir::ItemStruct(..) |
Expand All @@ -1272,13 +1274,13 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
let def_id = tcx.hir.local_def_id(id);
tcx.construct_parameter_environment(item.span,
def_id,
tcx.region_maps().item_extent(id))
tcx.region_maps(id).item_extent(id))
}
hir::ItemTrait(..) => {
let def_id = tcx.hir.local_def_id(id);
tcx.construct_parameter_environment(item.span,
def_id,
tcx.region_maps().item_extent(id))
tcx.region_maps(id).item_extent(id))
}
_ => {
span_bug!(item.span,
Expand All @@ -1296,7 +1298,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
tcx.construct_parameter_environment(
expr.span,
base_def_id,
tcx.region_maps().call_site_extent(id, body.node_id))
tcx.region_maps(body.node_id).call_site_extent(id, body.node_id))
} else {
tcx.empty_parameter_environment()
}
Expand Down Expand Up @@ -2560,7 +2562,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}

pub fn node_scope_region(self, id: NodeId) -> &'tcx Region {
self.mk_region(ty::ReScope(self.region_maps().node_extent(id)))
self.mk_region(ty::ReScope(self.region_maps(id).node_extent(id)))
}

pub fn visit_all_item_likes_in_krate<V,F>(self,
Expand Down

0 comments on commit b95e875

Please sign in to comment.