rustc: rename mir::SourceScopeInfo to mir::SourceScopeLocalData.
This commit is contained in:
parent
85d44c4276
commit
ca1ac6b6fb
8 changed files with 38 additions and 38 deletions
|
@ -364,7 +364,7 @@ for mir::ProjectionElem<'gcx, V, T>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_stable_hash_for!(struct mir::SourceScopeData { span, parent_scope });
|
impl_stable_hash_for!(struct mir::SourceScopeData { span, parent_scope });
|
||||||
impl_stable_hash_for!(struct mir::SourceScopeInfo {
|
impl_stable_hash_for!(struct mir::SourceScopeLocalData {
|
||||||
lint_root, safety
|
lint_root, safety
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ pub struct Mir<'tcx> {
|
||||||
|
|
||||||
/// Crate-local information for each source scope, that can't (and
|
/// Crate-local information for each source scope, that can't (and
|
||||||
/// needn't) be tracked across crates.
|
/// needn't) be tracked across crates.
|
||||||
pub source_scope_info: ClearCrossCrate<IndexVec<SourceScope, SourceScopeInfo>>,
|
pub source_scope_local_data: ClearCrossCrate<IndexVec<SourceScope, SourceScopeLocalData>>,
|
||||||
|
|
||||||
/// Rvalues promoted from this function, such as borrows of constants.
|
/// Rvalues promoted from this function, such as borrows of constants.
|
||||||
/// Each of them is the Mir of a constant with the fn's type parameters
|
/// Each of them is the Mir of a constant with the fn's type parameters
|
||||||
|
@ -138,8 +138,8 @@ pub const START_BLOCK: BasicBlock = BasicBlock(0);
|
||||||
impl<'tcx> Mir<'tcx> {
|
impl<'tcx> Mir<'tcx> {
|
||||||
pub fn new(basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
|
pub fn new(basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
|
||||||
source_scopes: IndexVec<SourceScope, SourceScopeData>,
|
source_scopes: IndexVec<SourceScope, SourceScopeData>,
|
||||||
source_scope_info: ClearCrossCrate<IndexVec<SourceScope,
|
source_scope_local_data: ClearCrossCrate<IndexVec<SourceScope,
|
||||||
SourceScopeInfo>>,
|
SourceScopeLocalData>>,
|
||||||
promoted: IndexVec<Promoted, Mir<'tcx>>,
|
promoted: IndexVec<Promoted, Mir<'tcx>>,
|
||||||
yield_ty: Option<Ty<'tcx>>,
|
yield_ty: Option<Ty<'tcx>>,
|
||||||
local_decls: IndexVec<Local, LocalDecl<'tcx>>,
|
local_decls: IndexVec<Local, LocalDecl<'tcx>>,
|
||||||
|
@ -154,7 +154,7 @@ impl<'tcx> Mir<'tcx> {
|
||||||
Mir {
|
Mir {
|
||||||
basic_blocks,
|
basic_blocks,
|
||||||
source_scopes,
|
source_scopes,
|
||||||
source_scope_info,
|
source_scope_local_data,
|
||||||
promoted,
|
promoted,
|
||||||
yield_ty,
|
yield_ty,
|
||||||
generator_drop: None,
|
generator_drop: None,
|
||||||
|
@ -308,14 +308,6 @@ impl<'tcx> Mir<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
|
|
||||||
pub struct SourceScopeInfo {
|
|
||||||
/// A NodeId with lint levels equivalent to this scope's lint levels.
|
|
||||||
pub lint_root: ast::NodeId,
|
|
||||||
/// The unsafe block that contains this node.
|
|
||||||
pub safety: Safety,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable)]
|
#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable)]
|
||||||
pub enum Safety {
|
pub enum Safety {
|
||||||
Safe,
|
Safe,
|
||||||
|
@ -330,7 +322,7 @@ pub enum Safety {
|
||||||
impl_stable_hash_for!(struct Mir<'tcx> {
|
impl_stable_hash_for!(struct Mir<'tcx> {
|
||||||
basic_blocks,
|
basic_blocks,
|
||||||
source_scopes,
|
source_scopes,
|
||||||
source_scope_info,
|
source_scope_local_data,
|
||||||
promoted,
|
promoted,
|
||||||
yield_ty,
|
yield_ty,
|
||||||
generator_drop,
|
generator_drop,
|
||||||
|
@ -1515,6 +1507,14 @@ pub struct SourceScopeData {
|
||||||
pub parent_scope: Option<SourceScope>,
|
pub parent_scope: Option<SourceScope>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
|
||||||
|
pub struct SourceScopeLocalData {
|
||||||
|
/// A NodeId with lint levels equivalent to this scope's lint levels.
|
||||||
|
pub lint_root: ast::NodeId,
|
||||||
|
/// The unsafe block that contains this node.
|
||||||
|
pub safety: Safety,
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Operands
|
// Operands
|
||||||
|
|
||||||
|
@ -2155,16 +2155,16 @@ CloneTypeFoldableAndLiftImpls! {
|
||||||
SourceInfo,
|
SourceInfo,
|
||||||
UpvarDecl,
|
UpvarDecl,
|
||||||
ValidationOp,
|
ValidationOp,
|
||||||
SourceScopeData,
|
|
||||||
SourceScope,
|
SourceScope,
|
||||||
SourceScopeInfo,
|
SourceScopeData,
|
||||||
|
SourceScopeLocalData,
|
||||||
}
|
}
|
||||||
|
|
||||||
BraceStructTypeFoldableImpl! {
|
BraceStructTypeFoldableImpl! {
|
||||||
impl<'tcx> TypeFoldable<'tcx> for Mir<'tcx> {
|
impl<'tcx> TypeFoldable<'tcx> for Mir<'tcx> {
|
||||||
basic_blocks,
|
basic_blocks,
|
||||||
source_scopes,
|
source_scopes,
|
||||||
source_scope_info,
|
source_scope_local_data,
|
||||||
promoted,
|
promoted,
|
||||||
yield_ty,
|
yield_ty,
|
||||||
generator_drop,
|
generator_drop,
|
||||||
|
|
|
@ -292,7 +292,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
|
||||||
debug!("mbcx.used_mut: {:?}", mbcx.used_mut);
|
debug!("mbcx.used_mut: {:?}", mbcx.used_mut);
|
||||||
|
|
||||||
for local in mbcx.mir.mut_vars_and_args_iter().filter(|local| !mbcx.used_mut.contains(local)) {
|
for local in mbcx.mir.mut_vars_and_args_iter().filter(|local| !mbcx.used_mut.contains(local)) {
|
||||||
if let ClearCrossCrate::Set(ref vsi) = mbcx.mir.source_scope_info {
|
if let ClearCrossCrate::Set(ref vsi) = mbcx.mir.source_scope_local_data {
|
||||||
let local_decl = &mbcx.mir.local_decls[local];
|
let local_decl = &mbcx.mir.local_decls[local];
|
||||||
|
|
||||||
// Skip implicit `self` argument for closures
|
// Skip implicit `self` argument for closures
|
||||||
|
|
|
@ -257,7 +257,7 @@ struct Builder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||||
/// the vector of all scopes that we have created thus far;
|
/// the vector of all scopes that we have created thus far;
|
||||||
/// we track this for debuginfo later
|
/// we track this for debuginfo later
|
||||||
source_scopes: IndexVec<SourceScope, SourceScopeData>,
|
source_scopes: IndexVec<SourceScope, SourceScopeData>,
|
||||||
source_scope_info: IndexVec<SourceScope, SourceScopeInfo>,
|
source_scope_local_data: IndexVec<SourceScope, SourceScopeLocalData>,
|
||||||
source_scope: SourceScope,
|
source_scope: SourceScope,
|
||||||
|
|
||||||
/// the guard-context: each time we build the guard expression for
|
/// the guard-context: each time we build the guard expression for
|
||||||
|
@ -595,7 +595,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||||
scopes: vec![],
|
scopes: vec![],
|
||||||
source_scopes: IndexVec::new(),
|
source_scopes: IndexVec::new(),
|
||||||
source_scope: OUTERMOST_SOURCE_SCOPE,
|
source_scope: OUTERMOST_SOURCE_SCOPE,
|
||||||
source_scope_info: IndexVec::new(),
|
source_scope_local_data: IndexVec::new(),
|
||||||
guard_context: vec![],
|
guard_context: vec![],
|
||||||
push_unsafe_count: 0,
|
push_unsafe_count: 0,
|
||||||
unpushed_unsafe: safety,
|
unpushed_unsafe: safety,
|
||||||
|
@ -630,7 +630,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
Mir::new(self.cfg.basic_blocks,
|
Mir::new(self.cfg.basic_blocks,
|
||||||
self.source_scopes,
|
self.source_scopes,
|
||||||
ClearCrossCrate::Set(self.source_scope_info),
|
ClearCrossCrate::Set(self.source_scope_local_data),
|
||||||
IndexVec::new(),
|
IndexVec::new(),
|
||||||
yield_ty,
|
yield_ty,
|
||||||
self.local_decls,
|
self.local_decls,
|
||||||
|
|
|
@ -323,7 +323,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||||
let sets = tcx.lint_levels(LOCAL_CRATE);
|
let sets = tcx.lint_levels(LOCAL_CRATE);
|
||||||
let parent_hir_id =
|
let parent_hir_id =
|
||||||
tcx.hir.definitions().node_to_hir_id(
|
tcx.hir.definitions().node_to_hir_id(
|
||||||
self.source_scope_info[source_scope].lint_root
|
self.source_scope_local_data[source_scope].lint_root
|
||||||
);
|
);
|
||||||
let current_hir_id =
|
let current_hir_id =
|
||||||
tcx.hir.definitions().node_to_hir_id(node_id);
|
tcx.hir.definitions().node_to_hir_id(node_id);
|
||||||
|
@ -517,22 +517,22 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||||
let parent = self.source_scope;
|
let parent = self.source_scope;
|
||||||
debug!("new_source_scope({:?}, {:?}, {:?}) - parent({:?})={:?}",
|
debug!("new_source_scope({:?}, {:?}, {:?}) - parent({:?})={:?}",
|
||||||
span, lint_level, safety,
|
span, lint_level, safety,
|
||||||
parent, self.source_scope_info.get(parent));
|
parent, self.source_scope_local_data.get(parent));
|
||||||
let scope = self.source_scopes.push(SourceScopeData {
|
let scope = self.source_scopes.push(SourceScopeData {
|
||||||
span,
|
span,
|
||||||
parent_scope: Some(parent),
|
parent_scope: Some(parent),
|
||||||
});
|
});
|
||||||
let scope_info = SourceScopeInfo {
|
let scope_local_data = SourceScopeLocalData {
|
||||||
lint_root: if let LintLevel::Explicit(lint_root) = lint_level {
|
lint_root: if let LintLevel::Explicit(lint_root) = lint_level {
|
||||||
lint_root
|
lint_root
|
||||||
} else {
|
} else {
|
||||||
self.source_scope_info[parent].lint_root
|
self.source_scope_local_data[parent].lint_root
|
||||||
},
|
},
|
||||||
safety: safety.unwrap_or_else(|| {
|
safety: safety.unwrap_or_else(|| {
|
||||||
self.source_scope_info[parent].safety
|
self.source_scope_local_data[parent].safety
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
self.source_scope_info.push(scope_info);
|
self.source_scope_local_data.push(scope_local_data);
|
||||||
scope
|
scope
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ use util;
|
||||||
|
|
||||||
pub struct UnsafetyChecker<'a, 'tcx: 'a> {
|
pub struct UnsafetyChecker<'a, 'tcx: 'a> {
|
||||||
mir: &'a Mir<'tcx>,
|
mir: &'a Mir<'tcx>,
|
||||||
source_scope_info: &'a IndexVec<SourceScope, SourceScopeInfo>,
|
source_scope_local_data: &'a IndexVec<SourceScope, SourceScopeLocalData>,
|
||||||
violations: Vec<UnsafetyViolation>,
|
violations: Vec<UnsafetyViolation>,
|
||||||
source_info: SourceInfo,
|
source_info: SourceInfo,
|
||||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
@ -38,12 +38,12 @@ pub struct UnsafetyChecker<'a, 'tcx: 'a> {
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> UnsafetyChecker<'a, 'tcx> {
|
impl<'a, 'gcx, 'tcx> UnsafetyChecker<'a, 'tcx> {
|
||||||
fn new(mir: &'a Mir<'tcx>,
|
fn new(mir: &'a Mir<'tcx>,
|
||||||
source_scope_info: &'a IndexVec<SourceScope, SourceScopeInfo>,
|
source_scope_local_data: &'a IndexVec<SourceScope, SourceScopeLocalData>,
|
||||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>) -> Self {
|
param_env: ty::ParamEnv<'tcx>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
mir,
|
mir,
|
||||||
source_scope_info,
|
source_scope_local_data,
|
||||||
violations: vec![],
|
violations: vec![],
|
||||||
source_info: SourceInfo {
|
source_info: SourceInfo {
|
||||||
span: mir.span,
|
span: mir.span,
|
||||||
|
@ -147,7 +147,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
|
||||||
if util::is_disaligned(self.tcx, self.mir, self.param_env, place) {
|
if util::is_disaligned(self.tcx, self.mir, self.param_env, place) {
|
||||||
let source_info = self.source_info;
|
let source_info = self.source_info;
|
||||||
let lint_root =
|
let lint_root =
|
||||||
self.source_scope_info[source_info.scope].lint_root;
|
self.source_scope_local_data[source_info.scope].lint_root;
|
||||||
self.register_violations(&[UnsafetyViolation {
|
self.register_violations(&[UnsafetyViolation {
|
||||||
source_info,
|
source_info,
|
||||||
description: Symbol::intern("borrow of packed field").as_interned_str(),
|
description: Symbol::intern("borrow of packed field").as_interned_str(),
|
||||||
|
@ -212,7 +212,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
|
||||||
} else if self.tcx.is_foreign_item(def_id) {
|
} else if self.tcx.is_foreign_item(def_id) {
|
||||||
let source_info = self.source_info;
|
let source_info = self.source_info;
|
||||||
let lint_root =
|
let lint_root =
|
||||||
self.source_scope_info[source_info.scope].lint_root;
|
self.source_scope_local_data[source_info.scope].lint_root;
|
||||||
self.register_violations(&[UnsafetyViolation {
|
self.register_violations(&[UnsafetyViolation {
|
||||||
source_info,
|
source_info,
|
||||||
description: Symbol::intern("use of extern static").as_interned_str(),
|
description: Symbol::intern("use of extern static").as_interned_str(),
|
||||||
|
@ -240,7 +240,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
|
||||||
fn register_violations(&mut self,
|
fn register_violations(&mut self,
|
||||||
violations: &[UnsafetyViolation],
|
violations: &[UnsafetyViolation],
|
||||||
unsafe_blocks: &[(ast::NodeId, bool)]) {
|
unsafe_blocks: &[(ast::NodeId, bool)]) {
|
||||||
let within_unsafe = match self.source_scope_info[self.source_info.scope].safety {
|
let within_unsafe = match self.source_scope_local_data[self.source_info.scope].safety {
|
||||||
Safety::Safe => {
|
Safety::Safe => {
|
||||||
for violation in violations {
|
for violation in violations {
|
||||||
if !self.violations.contains(violation) {
|
if !self.violations.contains(violation) {
|
||||||
|
@ -327,7 +327,7 @@ fn unsafety_check_result<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
||||||
// `mir_built` force this.
|
// `mir_built` force this.
|
||||||
let mir = &tcx.mir_built(def_id).borrow();
|
let mir = &tcx.mir_built(def_id).borrow();
|
||||||
|
|
||||||
let source_scope_info = match mir.source_scope_info {
|
let source_scope_local_data = match mir.source_scope_local_data {
|
||||||
ClearCrossCrate::Set(ref data) => data,
|
ClearCrossCrate::Set(ref data) => data,
|
||||||
ClearCrossCrate::Clear => {
|
ClearCrossCrate::Clear => {
|
||||||
debug!("unsafety_violations: {:?} - remote, skipping", def_id);
|
debug!("unsafety_violations: {:?} - remote, skipping", def_id);
|
||||||
|
@ -340,7 +340,7 @@ fn unsafety_check_result<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
||||||
|
|
||||||
let param_env = tcx.param_env(def_id);
|
let param_env = tcx.param_env(def_id);
|
||||||
let mut checker = UnsafetyChecker::new(
|
let mut checker = UnsafetyChecker::new(
|
||||||
mir, source_scope_info, tcx, param_env);
|
mir, source_scope_local_data, tcx, param_env);
|
||||||
checker.visit_mir(mir);
|
checker.visit_mir(mir);
|
||||||
|
|
||||||
check_unused_unsafe(tcx, def_id, &checker.used_unsafe, &mut checker.inherited_blocks);
|
check_unused_unsafe(tcx, def_id, &checker.used_unsafe, &mut checker.inherited_blocks);
|
||||||
|
|
|
@ -338,7 +338,7 @@ impl<'b, 'a, 'tcx:'b> ConstPropagator<'b, 'a, 'tcx> {
|
||||||
.bits();
|
.bits();
|
||||||
let right_size = self.tcx.layout_of(self.param_env.and(right.1)).unwrap().size;
|
let right_size = self.tcx.layout_of(self.param_env.and(right.1)).unwrap().size;
|
||||||
if r.to_bits(right_size).ok().map_or(false, |b| b >= left_bits as u128) {
|
if r.to_bits(right_size).ok().map_or(false, |b| b >= left_bits as u128) {
|
||||||
let scope_info = match self.mir.source_scope_info {
|
let source_scope_local_data = match self.mir.source_scope_local_data {
|
||||||
ClearCrossCrate::Set(ref data) => data,
|
ClearCrossCrate::Set(ref data) => data,
|
||||||
ClearCrossCrate::Clear => return None,
|
ClearCrossCrate::Clear => return None,
|
||||||
};
|
};
|
||||||
|
@ -347,7 +347,7 @@ impl<'b, 'a, 'tcx:'b> ConstPropagator<'b, 'a, 'tcx> {
|
||||||
} else {
|
} else {
|
||||||
"left"
|
"left"
|
||||||
};
|
};
|
||||||
let node_id = scope_info[source_info.scope].lint_root;
|
let node_id = source_scope_local_data[source_info.scope].lint_root;
|
||||||
self.tcx.lint_node(
|
self.tcx.lint_node(
|
||||||
::rustc::lint::builtin::EXCEEDING_BITSHIFTS,
|
::rustc::lint::builtin::EXCEEDING_BITSHIFTS,
|
||||||
node_id,
|
node_id,
|
||||||
|
|
|
@ -425,7 +425,7 @@ pub fn promote_candidates<'a, 'tcx>(mir: &mut Mir<'tcx>,
|
||||||
// FIXME: maybe try to filter this to avoid blowing up
|
// FIXME: maybe try to filter this to avoid blowing up
|
||||||
// memory usage?
|
// memory usage?
|
||||||
mir.source_scopes.clone(),
|
mir.source_scopes.clone(),
|
||||||
mir.source_scope_info.clone(),
|
mir.source_scope_local_data.clone(),
|
||||||
IndexVec::new(),
|
IndexVec::new(),
|
||||||
None,
|
None,
|
||||||
initial_locals,
|
initial_locals,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue