Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc: rename CodeExtent to Scope and RegionMaps to ScopeTree. #44253

Merged
merged 1 commit into from
Sep 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/librustc/cfg/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use rustc_data_structures::graph;
use cfg::*;
use middle::region::CodeExtent;
use middle::region;
use ty::{self, TyCtxt};
use syntax::ptr::P;

Expand Down Expand Up @@ -579,14 +579,14 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
fn add_exiting_edge(&mut self,
from_expr: &hir::Expr,
from_index: CFGIndex,
target_scope: CodeExtent,
target_scope: region::Scope,
to_index: CFGIndex) {
let mut data = CFGEdgeData { exiting_scopes: vec![] };
let mut scope = CodeExtent::Misc(from_expr.hir_id.local_id);
let region_maps = self.tcx.region_maps(self.owner_def_id);
let mut scope = region::Scope::Node(from_expr.hir_id.local_id);
let region_scope_tree = self.tcx.region_scope_tree(self.owner_def_id);
while scope != target_scope {
data.exiting_scopes.push(scope.item_local_id());
scope = region_maps.encl_scope(scope);
scope = region_scope_tree.encl_scope(scope);
}
self.graph.add_edge(from_index, to_index, data);
}
Expand All @@ -606,14 +606,14 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
fn find_scope_edge(&self,
expr: &hir::Expr,
destination: hir::Destination,
scope_cf_kind: ScopeCfKind) -> (CodeExtent, CFGIndex) {
scope_cf_kind: ScopeCfKind) -> (region::Scope, CFGIndex) {

match destination.target_id {
hir::ScopeTarget::Block(block_expr_id) => {
for b in &self.breakable_block_scopes {
if b.block_expr_id == self.tcx.hir.node_to_hir_id(block_expr_id).local_id {
let scope_id = self.tcx.hir.node_to_hir_id(block_expr_id).local_id;
return (CodeExtent::Misc(scope_id), match scope_cf_kind {
return (region::Scope::Node(scope_id), match scope_cf_kind {
ScopeCfKind::Break => b.break_index,
ScopeCfKind::Continue => bug!("can't continue to block"),
});
Expand All @@ -625,7 +625,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
for l in &self.loop_scopes {
if l.loop_id == self.tcx.hir.node_to_hir_id(loop_id).local_id {
let scope_id = self.tcx.hir.node_to_hir_id(loop_id).local_id;
return (CodeExtent::Misc(scope_id), match scope_cf_kind {
return (region::Scope::Node(scope_id), match scope_cf_kind {
ScopeCfKind::Break => l.break_index,
ScopeCfKind::Continue => l.continue_index,
});
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ define_dep_nodes!( <'tcx>
[] WorkProduct(WorkProductId),

// Represents different phases in the compiler.
[] RegionMaps(DefId),
[] RegionScopeTree(DefId),
[] Coherence,
[] CoherenceInherentImplOverlapCheck,
[] Resolve,
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ich/impls_mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ for mir::StatementKind<'gcx> {
mir::StatementKind::StorageDead(ref lvalue) => {
lvalue.hash_stable(hcx, hasher);
}
mir::StatementKind::EndRegion(ref extent) => {
extent.hash_stable(hcx, hasher);
mir::StatementKind::EndRegion(ref region_scope) => {
region_scope.hash_stable(hcx, hasher);
}
mir::StatementKind::Validate(ref op, ref lvalues) => {
op.hash_stable(hcx, hasher);
Expand Down Expand Up @@ -271,7 +271,7 @@ impl<'a, 'gcx, 'tcx, T> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
}
}

impl_stable_hash_for!(enum mir::ValidationOp { Acquire, Release, Suspend(extent) });
impl_stable_hash_for!(enum mir::ValidationOp { Acquire, Release, Suspend(region_scope) });

impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for mir::Lvalue<'gcx> {
fn hash_stable<W: StableHasherResult>(&self,
Expand Down
19 changes: 9 additions & 10 deletions src/librustc/ich/impls_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher,
use std::hash as std_hash;
use std::mem;
use syntax_pos::symbol::InternedString;
use middle::region;
use ty;

impl<'a, 'gcx, 'tcx, T> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
Expand Down Expand Up @@ -65,8 +66,8 @@ for ty::RegionKind {
index.hash_stable(hcx, hasher);
name.hash_stable(hcx, hasher);
}
ty::ReScope(code_extent) => {
code_extent.hash_stable(hcx, hasher);
ty::ReScope(scope) => {
scope.hash_stable(hcx, hasher);
}
ty::ReFree(ref free_region) => {
free_region.hash_stable(hcx, hasher);
Expand Down Expand Up @@ -450,24 +451,22 @@ impl_stable_hash_for!(enum ty::cast::CastKind {
});

impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
for ::middle::region::CodeExtent
for region::Scope
{
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
hasher: &mut StableHasher<W>) {
use middle::region::CodeExtent;

mem::discriminant(self).hash_stable(hcx, hasher);
match *self {
CodeExtent::Misc(node_id) |
CodeExtent::DestructionScope(node_id) => {
region::Scope::Node(node_id) |
region::Scope::Destruction(node_id) => {
node_id.hash_stable(hcx, hasher);
}
CodeExtent::CallSiteScope(body_id) |
CodeExtent::ParameterScope(body_id) => {
region::Scope::CallSite(body_id) |
region::Scope::Arguments(body_id) => {
body_id.hash_stable(hcx, hasher);
}
CodeExtent::Remainder(block_remainder) => {
region::Scope::Remainder(block_remainder) => {
block_remainder.hash_stable(hcx, hasher);
}
}
Expand Down
36 changes: 18 additions & 18 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ use std::fmt;
use hir;
use hir::map as hir_map;
use hir::def_id::DefId;
use middle::region::{self, RegionMaps};
use middle::region;
use traits::{ObligationCause, ObligationCauseCode};
use ty::{self, Region, TyCtxt, TypeFoldable};
use ty::error::TypeError;
Expand All @@ -83,7 +83,7 @@ mod anon_anon_conflict;

impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn note_and_explain_region(self,
region_maps: &RegionMaps,
region_scope_tree: &region::ScopeTree,
err: &mut DiagnosticBuilder,
prefix: &str,
region: ty::Region<'tcx>,
Expand Down Expand Up @@ -131,8 +131,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
format!("{}unknown scope: {:?}{}. Please report a bug.",
prefix, scope, suffix)
};
let span = scope.span(self, region_maps);
let tag = match self.hir.find(scope.node_id(self, region_maps)) {
let span = scope.span(self, region_scope_tree);
let tag = match self.hir.find(scope.node_id(self, region_scope_tree)) {
Some(hir_map::NodeBlock(_)) => "block",
Some(hir_map::NodeExpr(expr)) => match expr.node {
hir::ExprCall(..) => "call",
Expand All @@ -153,18 +153,18 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}
};
let scope_decorated_tag = match scope {
region::CodeExtent::Misc(_) => tag,
region::CodeExtent::CallSiteScope(_) => {
region::Scope::Node(_) => tag,
region::Scope::CallSite(_) => {
"scope of call-site for function"
}
region::CodeExtent::ParameterScope(_) => {
region::Scope::Arguments(_) => {
"scope of function body"
}
region::CodeExtent::DestructionScope(_) => {
region::Scope::Destruction(_) => {
new_string = format!("destruction scope surrounding {}", tag);
&new_string[..]
}
region::CodeExtent::Remainder(r) => {
region::Scope::Remainder(r) => {
new_string = format!("block suffix following statement {}",
r.first_statement_index);
&new_string[..]
Expand Down Expand Up @@ -256,7 +256,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {

impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
pub fn report_region_errors(&self,
region_maps: &RegionMaps,
region_scope_tree: &region::ScopeTree,
errors: &Vec<RegionResolutionError<'tcx>>) {
debug!("report_region_errors(): {} errors to start", errors.len());

Expand All @@ -281,15 +281,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// the error. If all of these fails, we fall back to a rather
// general bit of code that displays the error information
ConcreteFailure(origin, sub, sup) => {
self.report_concrete_failure(region_maps, origin, sub, sup).emit();
self.report_concrete_failure(region_scope_tree, origin, sub, sup).emit();
}

GenericBoundFailure(kind, param_ty, sub) => {
self.report_generic_bound_failure(region_maps, kind, param_ty, sub);
self.report_generic_bound_failure(region_scope_tree, kind, param_ty, sub);
}

SubSupConflict(var_origin, sub_origin, sub_r, sup_origin, sup_r) => {
self.report_sub_sup_conflict(region_maps,
self.report_sub_sup_conflict(region_scope_tree,
var_origin,
sub_origin,
sub_r,
Expand Down Expand Up @@ -769,7 +769,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
}

fn report_generic_bound_failure(&self,
region_maps: &RegionMaps,
region_scope_tree: &region::ScopeTree,
origin: SubregionOrigin<'tcx>,
bound_kind: GenericKind<'tcx>,
sub: Region<'tcx>)
Expand Down Expand Up @@ -837,7 +837,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
err.help(&format!("consider adding an explicit lifetime bound for `{}`",
bound_kind));
self.tcx.note_and_explain_region(
region_maps,
region_scope_tree,
&mut err,
&format!("{} must be valid for ", labeled_user_string),
sub,
Expand All @@ -851,22 +851,22 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
}

fn report_sub_sup_conflict(&self,
region_maps: &RegionMaps,
region_scope_tree: &region::ScopeTree,
var_origin: RegionVariableOrigin,
sub_origin: SubregionOrigin<'tcx>,
sub_region: Region<'tcx>,
sup_origin: SubregionOrigin<'tcx>,
sup_region: Region<'tcx>) {
let mut err = self.report_inference_failure(var_origin);

self.tcx.note_and_explain_region(region_maps, &mut err,
self.tcx.note_and_explain_region(region_scope_tree, &mut err,
"first, the lifetime cannot outlive ",
sup_region,
"...");

self.note_region_origin(&mut err, &sup_origin);

self.tcx.note_and_explain_region(region_maps, &mut err,
self.tcx.note_and_explain_region(region_scope_tree, &mut err,
"but, the lifetime must be valid for ",
sub_region,
"...");
Expand Down
Loading