Auto merge of #51182 - eddyb:not-just-visibility, r=nikomatsakis
[MIR] Change "scopes" from "visibility scopes" to "source scopes". These scopes are already used for source-oriented diagnostics, lint levels and unsafety checks. This PR generalizes the naming around scopes, making the type `SourceScope`, and flips (across several commits) the relationship/priority between `LocalDecl`'s "visibility" and "syntactic" scopes. r? @nikomatsakis
This commit is contained in:
commit
30cae58709
@ -26,8 +26,8 @@ impl_stable_hash_for!(struct mir::LocalDecl<'tcx> {
|
||||
ty,
|
||||
name,
|
||||
source_info,
|
||||
visibility_scope,
|
||||
internal,
|
||||
syntactic_scope,
|
||||
is_user_variable
|
||||
});
|
||||
impl_stable_hash_for!(struct mir::UpvarDecl { debug_name, by_ref, mutability });
|
||||
@ -127,7 +127,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for mir::Field {
|
||||
}
|
||||
|
||||
impl<'a> HashStable<StableHashingContext<'a>>
|
||||
for mir::VisibilityScope {
|
||||
for mir::SourceScope {
|
||||
#[inline]
|
||||
fn hash_stable<W: StableHasherResult>(&self,
|
||||
hcx: &mut StableHashingContext<'a>,
|
||||
@ -363,8 +363,8 @@ for mir::ProjectionElem<'gcx, V, T>
|
||||
}
|
||||
}
|
||||
|
||||
impl_stable_hash_for!(struct mir::VisibilityScopeData { span, parent_scope });
|
||||
impl_stable_hash_for!(struct mir::VisibilityScopeInfo {
|
||||
impl_stable_hash_for!(struct mir::SourceScopeData { span, parent_scope });
|
||||
impl_stable_hash_for!(struct mir::SourceScopeLocalData {
|
||||
lint_root, safety
|
||||
});
|
||||
|
||||
|
@ -78,13 +78,13 @@ pub struct Mir<'tcx> {
|
||||
/// that indexes into this vector.
|
||||
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
|
||||
|
||||
/// List of visibility (lexical) scopes; these are referenced by statements
|
||||
/// and used (eventually) for debuginfo. Indexed by a `VisibilityScope`.
|
||||
pub visibility_scopes: IndexVec<VisibilityScope, VisibilityScopeData>,
|
||||
/// List of source scopes; these are referenced by statements
|
||||
/// and used for debuginfo. Indexed by a `SourceScope`.
|
||||
pub source_scopes: IndexVec<SourceScope, SourceScopeData>,
|
||||
|
||||
/// Crate-local information for each visibility scope, that can't (and
|
||||
/// Crate-local information for each source scope, that can't (and
|
||||
/// needn't) be tracked across crates.
|
||||
pub visibility_scope_info: ClearCrossCrate<IndexVec<VisibilityScope, VisibilityScopeInfo>>,
|
||||
pub source_scope_local_data: ClearCrossCrate<IndexVec<SourceScope, SourceScopeLocalData>>,
|
||||
|
||||
/// 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
|
||||
@ -137,9 +137,9 @@ pub const START_BLOCK: BasicBlock = BasicBlock(0);
|
||||
|
||||
impl<'tcx> Mir<'tcx> {
|
||||
pub fn new(basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
|
||||
visibility_scopes: IndexVec<VisibilityScope, VisibilityScopeData>,
|
||||
visibility_scope_info: ClearCrossCrate<IndexVec<VisibilityScope,
|
||||
VisibilityScopeInfo>>,
|
||||
source_scopes: IndexVec<SourceScope, SourceScopeData>,
|
||||
source_scope_local_data: ClearCrossCrate<IndexVec<SourceScope,
|
||||
SourceScopeLocalData>>,
|
||||
promoted: IndexVec<Promoted, Mir<'tcx>>,
|
||||
yield_ty: Option<Ty<'tcx>>,
|
||||
local_decls: IndexVec<Local, LocalDecl<'tcx>>,
|
||||
@ -153,8 +153,8 @@ impl<'tcx> Mir<'tcx> {
|
||||
|
||||
Mir {
|
||||
basic_blocks,
|
||||
visibility_scopes,
|
||||
visibility_scope_info,
|
||||
source_scopes,
|
||||
source_scope_local_data,
|
||||
promoted,
|
||||
yield_ty,
|
||||
generator_drop: None,
|
||||
@ -308,14 +308,6 @@ impl<'tcx> Mir<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
|
||||
pub struct VisibilityScopeInfo {
|
||||
/// 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)]
|
||||
pub enum Safety {
|
||||
Safe,
|
||||
@ -329,8 +321,8 @@ pub enum Safety {
|
||||
|
||||
impl_stable_hash_for!(struct Mir<'tcx> {
|
||||
basic_blocks,
|
||||
visibility_scopes,
|
||||
visibility_scope_info,
|
||||
source_scopes,
|
||||
source_scope_local_data,
|
||||
promoted,
|
||||
yield_ty,
|
||||
generator_drop,
|
||||
@ -376,8 +368,9 @@ pub struct SourceInfo {
|
||||
/// Source span for the AST pertaining to this MIR entity.
|
||||
pub span: Span,
|
||||
|
||||
/// The lexical visibility scope, i.e. which bindings can be seen.
|
||||
pub scope: VisibilityScope
|
||||
/// The source scope, keeping track of which bindings can be
|
||||
/// seen by debuginfo, active lint levels, `unsafe {...}`, etc.
|
||||
pub scope: SourceScope
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -512,16 +505,13 @@ pub struct LocalDecl<'tcx> {
|
||||
/// to generate better debuginfo.
|
||||
pub name: Option<Name>,
|
||||
|
||||
/// Source info of the local.
|
||||
pub source_info: SourceInfo,
|
||||
|
||||
/// The *syntactic* visibility scope the local is defined
|
||||
/// The *syntactic* (i.e. not visibility) source scope the local is defined
|
||||
/// in. If the local was defined in a let-statement, this
|
||||
/// is *within* the let-statement, rather than outside
|
||||
/// of it.
|
||||
///
|
||||
/// This is needed because visibility scope of locals within a let-statement
|
||||
/// is weird.
|
||||
/// This is needed because the visibility source scope of locals within
|
||||
/// a let-statement is weird.
|
||||
///
|
||||
/// The reason is that we want the local to be *within* the let-statement
|
||||
/// for lint purposes, but we want the local to be *after* the let-statement
|
||||
@ -566,9 +556,9 @@ pub struct LocalDecl<'tcx> {
|
||||
/// `drop(x)`, we want it to refer to `x: u32`.
|
||||
///
|
||||
/// To allow both uses to work, we need to have more than a single scope
|
||||
/// for a local. We have the `syntactic_scope` represent the
|
||||
/// for a local. We have the `source_info.scope` represent the
|
||||
/// "syntactic" lint scope (with a variable being under its let
|
||||
/// block) while the source-info scope represents the "local variable"
|
||||
/// block) while the `visibility_scope` represents the "local variable"
|
||||
/// scope (where the "rest" of a block is under all prior let-statements).
|
||||
///
|
||||
/// The end result looks like this:
|
||||
@ -580,21 +570,25 @@ pub struct LocalDecl<'tcx> {
|
||||
/// │ │{ #[allow(unused_mut] } // this is actually split into 2 scopes
|
||||
/// │ │ // in practice because I'm lazy.
|
||||
/// │ │
|
||||
/// │ │← x.syntactic_scope
|
||||
/// │ │← x.source_info.scope
|
||||
/// │ │← `x.parse().unwrap()`
|
||||
/// │ │
|
||||
/// │ │ │← y.syntactic_scope
|
||||
/// │ │ │← y.source_info.scope
|
||||
/// │ │
|
||||
/// │ │ │{ let y: u32 }
|
||||
/// │ │ │
|
||||
/// │ │ │← y.source_info.scope
|
||||
/// │ │ │← y.visibility_scope
|
||||
/// │ │ │← `y + 2`
|
||||
/// │
|
||||
/// │ │{ let x: u32 }
|
||||
/// │ │← x.source_info.scope
|
||||
/// │ │← x.visibility_scope
|
||||
/// │ │← `drop(x)` // this accesses `x: u32`
|
||||
/// ```
|
||||
pub syntactic_scope: VisibilityScope,
|
||||
pub source_info: SourceInfo,
|
||||
|
||||
/// Source scope within which the local is visible (for debuginfo)
|
||||
/// (see `source_info` for more details).
|
||||
pub visibility_scope: SourceScope,
|
||||
}
|
||||
|
||||
impl<'tcx> LocalDecl<'tcx> {
|
||||
@ -607,9 +601,9 @@ impl<'tcx> LocalDecl<'tcx> {
|
||||
name: None,
|
||||
source_info: SourceInfo {
|
||||
span,
|
||||
scope: ARGUMENT_VISIBILITY_SCOPE
|
||||
scope: OUTERMOST_SOURCE_SCOPE
|
||||
},
|
||||
syntactic_scope: ARGUMENT_VISIBILITY_SCOPE,
|
||||
visibility_scope: OUTERMOST_SOURCE_SCOPE,
|
||||
internal: false,
|
||||
is_user_variable: false
|
||||
}
|
||||
@ -624,9 +618,9 @@ impl<'tcx> LocalDecl<'tcx> {
|
||||
name: None,
|
||||
source_info: SourceInfo {
|
||||
span,
|
||||
scope: ARGUMENT_VISIBILITY_SCOPE
|
||||
scope: OUTERMOST_SOURCE_SCOPE
|
||||
},
|
||||
syntactic_scope: ARGUMENT_VISIBILITY_SCOPE,
|
||||
visibility_scope: OUTERMOST_SOURCE_SCOPE,
|
||||
internal: true,
|
||||
is_user_variable: false
|
||||
}
|
||||
@ -642,9 +636,9 @@ impl<'tcx> LocalDecl<'tcx> {
|
||||
ty: return_ty,
|
||||
source_info: SourceInfo {
|
||||
span,
|
||||
scope: ARGUMENT_VISIBILITY_SCOPE
|
||||
scope: OUTERMOST_SOURCE_SCOPE
|
||||
},
|
||||
syntactic_scope: ARGUMENT_VISIBILITY_SCOPE,
|
||||
visibility_scope: OUTERMOST_SOURCE_SCOPE,
|
||||
internal: false,
|
||||
name: None, // FIXME maybe we do want some name here?
|
||||
is_user_variable: false
|
||||
@ -1047,7 +1041,7 @@ impl<'tcx> BasicBlockData<'tcx> {
|
||||
self.statements.resize(gap.end, Statement {
|
||||
source_info: SourceInfo {
|
||||
span: DUMMY_SP,
|
||||
scope: ARGUMENT_VISIBILITY_SCOPE
|
||||
scope: OUTERMOST_SOURCE_SCOPE
|
||||
},
|
||||
kind: StatementKind::Nop
|
||||
});
|
||||
@ -1501,16 +1495,24 @@ impl<'tcx> Debug for Place<'tcx> {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Scopes
|
||||
|
||||
newtype_index!(VisibilityScope
|
||||
newtype_index!(SourceScope
|
||||
{
|
||||
DEBUG_FORMAT = "scope[{}]",
|
||||
const ARGUMENT_VISIBILITY_SCOPE = 0,
|
||||
const OUTERMOST_SOURCE_SCOPE = 0,
|
||||
});
|
||||
|
||||
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
|
||||
pub struct VisibilityScopeData {
|
||||
pub struct SourceScopeData {
|
||||
pub span: Span,
|
||||
pub parent_scope: Option<VisibilityScope>,
|
||||
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,
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -2153,16 +2155,16 @@ CloneTypeFoldableAndLiftImpls! {
|
||||
SourceInfo,
|
||||
UpvarDecl,
|
||||
ValidationOp,
|
||||
VisibilityScopeData,
|
||||
VisibilityScope,
|
||||
VisibilityScopeInfo,
|
||||
SourceScope,
|
||||
SourceScopeData,
|
||||
SourceScopeLocalData,
|
||||
}
|
||||
|
||||
BraceStructTypeFoldableImpl! {
|
||||
impl<'tcx> TypeFoldable<'tcx> for Mir<'tcx> {
|
||||
basic_blocks,
|
||||
visibility_scopes,
|
||||
visibility_scope_info,
|
||||
source_scopes,
|
||||
source_scope_local_data,
|
||||
promoted,
|
||||
yield_ty,
|
||||
generator_drop,
|
||||
@ -2190,7 +2192,7 @@ BraceStructTypeFoldableImpl! {
|
||||
ty,
|
||||
name,
|
||||
source_info,
|
||||
syntactic_scope,
|
||||
visibility_scope,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,9 +92,9 @@ macro_rules! make_mir_visitor {
|
||||
self.super_basic_block_data(block, data);
|
||||
}
|
||||
|
||||
fn visit_visibility_scope_data(&mut self,
|
||||
scope_data: & $($mutability)* VisibilityScopeData) {
|
||||
self.super_visibility_scope_data(scope_data);
|
||||
fn visit_source_scope_data(&mut self,
|
||||
scope_data: & $($mutability)* SourceScopeData) {
|
||||
self.super_source_scope_data(scope_data);
|
||||
}
|
||||
|
||||
fn visit_statement(&mut self,
|
||||
@ -261,9 +261,9 @@ macro_rules! make_mir_visitor {
|
||||
_location: Location) {
|
||||
}
|
||||
|
||||
fn visit_visibility_scope(&mut self,
|
||||
scope: & $($mutability)* VisibilityScope) {
|
||||
self.super_visibility_scope(scope);
|
||||
fn visit_source_scope(&mut self,
|
||||
scope: & $($mutability)* SourceScope) {
|
||||
self.super_source_scope(scope);
|
||||
}
|
||||
|
||||
// The `super_xxx` methods comprise the default behavior and are
|
||||
@ -274,7 +274,7 @@ macro_rules! make_mir_visitor {
|
||||
if let Some(yield_ty) = &$($mutability)* mir.yield_ty {
|
||||
self.visit_ty(yield_ty, TyContext::YieldTy(SourceInfo {
|
||||
span: mir.span,
|
||||
scope: ARGUMENT_VISIBILITY_SCOPE,
|
||||
scope: OUTERMOST_SOURCE_SCOPE,
|
||||
}));
|
||||
}
|
||||
|
||||
@ -289,13 +289,13 @@ macro_rules! make_mir_visitor {
|
||||
self.visit_basic_block_data(bb, data);
|
||||
}
|
||||
|
||||
for scope in &$($mutability)* mir.visibility_scopes {
|
||||
self.visit_visibility_scope_data(scope);
|
||||
for scope in &$($mutability)* mir.source_scopes {
|
||||
self.visit_source_scope_data(scope);
|
||||
}
|
||||
|
||||
self.visit_ty(&$($mutability)* mir.return_ty(), TyContext::ReturnTy(SourceInfo {
|
||||
span: mir.span,
|
||||
scope: ARGUMENT_VISIBILITY_SCOPE,
|
||||
scope: OUTERMOST_SOURCE_SCOPE,
|
||||
}));
|
||||
|
||||
for local in mir.local_decls.indices() {
|
||||
@ -327,16 +327,16 @@ macro_rules! make_mir_visitor {
|
||||
}
|
||||
}
|
||||
|
||||
fn super_visibility_scope_data(&mut self,
|
||||
scope_data: & $($mutability)* VisibilityScopeData) {
|
||||
let VisibilityScopeData {
|
||||
fn super_source_scope_data(&mut self,
|
||||
scope_data: & $($mutability)* SourceScopeData) {
|
||||
let SourceScopeData {
|
||||
ref $($mutability)* span,
|
||||
ref $($mutability)* parent_scope,
|
||||
} = *scope_data;
|
||||
|
||||
self.visit_span(span);
|
||||
if let Some(ref $($mutability)* parent_scope) = *parent_scope {
|
||||
self.visit_visibility_scope(parent_scope);
|
||||
self.visit_source_scope(parent_scope);
|
||||
}
|
||||
}
|
||||
|
||||
@ -715,8 +715,8 @@ macro_rules! make_mir_visitor {
|
||||
ref $($mutability)* ty,
|
||||
name: _,
|
||||
ref $($mutability)* source_info,
|
||||
ref $($mutability)* visibility_scope,
|
||||
internal: _,
|
||||
ref $($mutability)* syntactic_scope,
|
||||
is_user_variable: _,
|
||||
} = *local_decl;
|
||||
|
||||
@ -725,11 +725,11 @@ macro_rules! make_mir_visitor {
|
||||
source_info: *source_info,
|
||||
});
|
||||
self.visit_source_info(source_info);
|
||||
self.visit_visibility_scope(syntactic_scope);
|
||||
self.visit_source_scope(visibility_scope);
|
||||
}
|
||||
|
||||
fn super_visibility_scope(&mut self,
|
||||
_scope: & $($mutability)* VisibilityScope) {
|
||||
fn super_source_scope(&mut self,
|
||||
_scope: & $($mutability)* SourceScope) {
|
||||
}
|
||||
|
||||
fn super_branch(&mut self,
|
||||
@ -775,7 +775,7 @@ macro_rules! make_mir_visitor {
|
||||
} = *source_info;
|
||||
|
||||
self.visit_span(span);
|
||||
self.visit_visibility_scope(scope);
|
||||
self.visit_source_scope(scope);
|
||||
}
|
||||
|
||||
fn super_ty(&mut self, _ty: & $($mutability)* Ty<'tcx>) {
|
||||
|
@ -15,7 +15,7 @@ use super::utils::{DIB, span_start};
|
||||
use llvm;
|
||||
use llvm::debuginfo::DIScope;
|
||||
use common::CodegenCx;
|
||||
use rustc::mir::{Mir, VisibilityScope};
|
||||
use rustc::mir::{Mir, SourceScope};
|
||||
|
||||
use libc::c_uint;
|
||||
use std::ptr;
|
||||
@ -45,13 +45,13 @@ impl MirDebugScope {
|
||||
/// Produce DIScope DIEs for each MIR Scope which has variables defined in it.
|
||||
/// If debuginfo is disabled, the returned vector is empty.
|
||||
pub fn create_mir_scopes(cx: &CodegenCx, mir: &Mir, debug_context: &FunctionDebugContext)
|
||||
-> IndexVec<VisibilityScope, MirDebugScope> {
|
||||
-> IndexVec<SourceScope, MirDebugScope> {
|
||||
let null_scope = MirDebugScope {
|
||||
scope_metadata: ptr::null_mut(),
|
||||
file_start_pos: BytePos(0),
|
||||
file_end_pos: BytePos(0)
|
||||
};
|
||||
let mut scopes = IndexVec::from_elem(null_scope, &mir.visibility_scopes);
|
||||
let mut scopes = IndexVec::from_elem(null_scope, &mir.source_scopes);
|
||||
|
||||
let debug_context = match *debug_context {
|
||||
FunctionDebugContext::RegularContext(ref data) => data,
|
||||
@ -62,15 +62,15 @@ pub fn create_mir_scopes(cx: &CodegenCx, mir: &Mir, debug_context: &FunctionDebu
|
||||
};
|
||||
|
||||
// Find all the scopes with variables defined in them.
|
||||
let mut has_variables = BitVector::new(mir.visibility_scopes.len());
|
||||
let mut has_variables = BitVector::new(mir.source_scopes.len());
|
||||
for var in mir.vars_iter() {
|
||||
let decl = &mir.local_decls[var];
|
||||
has_variables.insert(decl.source_info.scope.index());
|
||||
has_variables.insert(decl.visibility_scope.index());
|
||||
}
|
||||
|
||||
// Instantiate all scopes.
|
||||
for idx in 0..mir.visibility_scopes.len() {
|
||||
let scope = VisibilityScope::new(idx);
|
||||
for idx in 0..mir.source_scopes.len() {
|
||||
let scope = SourceScope::new(idx);
|
||||
make_mir_scope(cx, &mir, &has_variables, debug_context, scope, &mut scopes);
|
||||
}
|
||||
|
||||
@ -81,13 +81,13 @@ fn make_mir_scope(cx: &CodegenCx,
|
||||
mir: &Mir,
|
||||
has_variables: &BitVector,
|
||||
debug_context: &FunctionDebugContextData,
|
||||
scope: VisibilityScope,
|
||||
scopes: &mut IndexVec<VisibilityScope, MirDebugScope>) {
|
||||
scope: SourceScope,
|
||||
scopes: &mut IndexVec<SourceScope, MirDebugScope>) {
|
||||
if scopes[scope].is_valid() {
|
||||
return;
|
||||
}
|
||||
|
||||
let scope_data = &mir.visibility_scopes[scope];
|
||||
let scope_data = &mir.source_scopes[scope];
|
||||
let parent_scope = if let Some(parent) = scope_data.parent_scope {
|
||||
make_mir_scope(cx, mir, has_variables, debug_context, parent, scopes);
|
||||
scopes[parent]
|
||||
|
@ -99,7 +99,7 @@ pub struct FunctionCx<'a, 'tcx:'a> {
|
||||
locals: IndexVec<mir::Local, LocalRef<'tcx>>,
|
||||
|
||||
/// Debug information for MIR scopes.
|
||||
scopes: IndexVec<mir::VisibilityScope, debuginfo::MirDebugScope>,
|
||||
scopes: IndexVec<mir::SourceScope, debuginfo::MirDebugScope>,
|
||||
|
||||
/// If this function is being monomorphized, this contains the type substitutions used.
|
||||
param_substs: &'tcx Substs<'tcx>,
|
||||
@ -158,9 +158,9 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> {
|
||||
|
||||
// DILocations inherit source file name from the parent DIScope. Due to macro expansions
|
||||
// it may so happen that the current span belongs to a different file than the DIScope
|
||||
// corresponding to span's containing visibility scope. If so, we need to create a DIScope
|
||||
// corresponding to span's containing source scope. If so, we need to create a DIScope
|
||||
// "extension" into that file.
|
||||
fn scope_metadata_for_loc(&self, scope_id: mir::VisibilityScope, pos: BytePos)
|
||||
fn scope_metadata_for_loc(&self, scope_id: mir::SourceScope, pos: BytePos)
|
||||
-> llvm::debuginfo::DIScope {
|
||||
let scope_metadata = self.scopes[scope_id].scope_metadata;
|
||||
if pos < self.scopes[scope_id].file_start_pos ||
|
||||
@ -265,7 +265,7 @@ pub fn codegen_mir<'a, 'tcx: 'a>(
|
||||
|
||||
if let Some(name) = decl.name {
|
||||
// User variable
|
||||
let debug_scope = fx.scopes[decl.source_info.scope];
|
||||
let debug_scope = fx.scopes[decl.visibility_scope];
|
||||
let dbg = debug_scope.is_valid() && bx.sess().opts.debuginfo == FullDebugInfo;
|
||||
|
||||
if !memory_locals.contains(local.index()) && !dbg {
|
||||
@ -276,7 +276,10 @@ pub fn codegen_mir<'a, 'tcx: 'a>(
|
||||
debug!("alloc: {:?} ({}) -> place", local, name);
|
||||
let place = PlaceRef::alloca(&bx, layout, &name.as_str());
|
||||
if dbg {
|
||||
let (scope, span) = fx.debug_loc(decl.source_info);
|
||||
let (scope, span) = fx.debug_loc(mir::SourceInfo {
|
||||
span: decl.source_info.span,
|
||||
scope: decl.visibility_scope,
|
||||
});
|
||||
declare_local(&bx, &fx.debug_context, name, layout.ty, scope,
|
||||
VariableAccess::DirectVariable { alloca: place.llval },
|
||||
VariableKind::LocalVariable, span);
|
||||
@ -411,7 +414,7 @@ fn create_funclets<'a, 'tcx>(
|
||||
/// indirect.
|
||||
fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
|
||||
fx: &FunctionCx<'a, 'tcx>,
|
||||
scopes: &IndexVec<mir::VisibilityScope, debuginfo::MirDebugScope>,
|
||||
scopes: &IndexVec<mir::SourceScope, debuginfo::MirDebugScope>,
|
||||
memory_locals: &BitVector)
|
||||
-> Vec<LocalRef<'tcx>> {
|
||||
let mir = fx.mir;
|
||||
@ -420,7 +423,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
|
||||
let mut llarg_idx = fx.fn_ty.ret.is_indirect() as usize;
|
||||
|
||||
// Get the argument scope, if it exists and if we need it.
|
||||
let arg_scope = scopes[mir::ARGUMENT_VISIBILITY_SCOPE];
|
||||
let arg_scope = scopes[mir::OUTERMOST_SOURCE_SCOPE];
|
||||
let arg_scope = if arg_scope.is_valid() && bx.sess().opts.debuginfo == FullDebugInfo {
|
||||
Some(arg_scope.scope_metadata)
|
||||
} else {
|
||||
|
@ -292,7 +292,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
|
||||
debug!("mbcx.used_mut: {:?}", mbcx.used_mut);
|
||||
|
||||
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.visibility_scope_info {
|
||||
if let ClearCrossCrate::Set(ref vsi) = mbcx.mir.source_scope_local_data {
|
||||
let local_decl = &mbcx.mir.local_decls[local];
|
||||
|
||||
// Skip implicit `self` argument for closures
|
||||
@ -306,13 +306,13 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
|
||||
None => continue,
|
||||
}
|
||||
|
||||
let source_info = local_decl.source_info;
|
||||
let mut_span = tcx.sess.codemap().span_until_non_whitespace(source_info.span);
|
||||
let span = local_decl.source_info.span;
|
||||
let mut_span = tcx.sess.codemap().span_until_non_whitespace(span);
|
||||
|
||||
tcx.struct_span_lint_node(
|
||||
UNUSED_MUT,
|
||||
vsi[local_decl.syntactic_scope].lint_root,
|
||||
source_info.span,
|
||||
vsi[local_decl.source_info.scope].lint_root,
|
||||
span,
|
||||
"variable does not need to be mutable"
|
||||
)
|
||||
.span_suggestion_short(mut_span, "remove this `mut`", "".to_owned())
|
||||
|
@ -81,10 +81,10 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
//
|
||||
// First we build all the statements in the block.
|
||||
let mut let_scope_stack = Vec::with_capacity(8);
|
||||
let outer_visibility_scope = this.visibility_scope;
|
||||
let outer_source_scope = this.source_scope;
|
||||
let outer_push_unsafe_count = this.push_unsafe_count;
|
||||
let outer_unpushed_unsafe = this.unpushed_unsafe;
|
||||
this.update_visibility_scope_for_safety_mode(span, safety_mode);
|
||||
this.update_source_scope_for_safety_mode(span, safety_mode);
|
||||
|
||||
let source_info = this.source_info(span);
|
||||
for stmt in stmts {
|
||||
@ -112,7 +112,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
this.push_scope((remainder_scope, source_info));
|
||||
let_scope_stack.push(remainder_scope);
|
||||
|
||||
// Declare the bindings, which may create a visibility scope.
|
||||
// Declare the bindings, which may create a source scope.
|
||||
let remainder_span = remainder_scope.span(this.hir.tcx(),
|
||||
&this.hir.region_scope_tree);
|
||||
let scope = this.declare_bindings(None, remainder_span, lint_level, &pattern,
|
||||
@ -143,9 +143,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
})
|
||||
}
|
||||
|
||||
// Enter the visibility scope, after evaluating the initializer.
|
||||
if let Some(visibility_scope) = scope {
|
||||
this.visibility_scope = visibility_scope;
|
||||
// Enter the source scope, after evaluating the initializer.
|
||||
if let Some(source_scope) = scope {
|
||||
this.source_scope = source_scope;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -172,19 +172,19 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
for scope in let_scope_stack.into_iter().rev() {
|
||||
unpack!(block = this.pop_scope((scope, source_info), block));
|
||||
}
|
||||
// Restore the original visibility scope.
|
||||
this.visibility_scope = outer_visibility_scope;
|
||||
// Restore the original source scope.
|
||||
this.source_scope = outer_source_scope;
|
||||
this.push_unsafe_count = outer_push_unsafe_count;
|
||||
this.unpushed_unsafe = outer_unpushed_unsafe;
|
||||
block.unit()
|
||||
}
|
||||
|
||||
/// If we are changing the safety mode, create a new visibility scope
|
||||
fn update_visibility_scope_for_safety_mode(&mut self,
|
||||
/// If we are changing the safety mode, create a new source scope
|
||||
fn update_source_scope_for_safety_mode(&mut self,
|
||||
span: Span,
|
||||
safety_mode: BlockSafety)
|
||||
{
|
||||
debug!("update_visibility_scope_for({:?}, {:?})", span, safety_mode);
|
||||
debug!("update_source_scope_for({:?}, {:?})", span, safety_mode);
|
||||
let new_unsafety = match safety_mode {
|
||||
BlockSafety::Safe => None,
|
||||
BlockSafety::ExplicitUnsafe(node_id) => {
|
||||
@ -214,7 +214,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
};
|
||||
|
||||
if let Some(unsafety) = new_unsafety {
|
||||
self.visibility_scope = self.new_visibility_scope(
|
||||
self.source_scope = self.new_source_scope(
|
||||
span, LintLevel::Inherited, Some(unsafety));
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
ty: ptr_ty,
|
||||
name: None,
|
||||
source_info,
|
||||
syntactic_scope: source_info.scope,
|
||||
visibility_scope: source_info.scope,
|
||||
internal: true,
|
||||
is_user_variable: false
|
||||
});
|
||||
|
@ -97,7 +97,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
LintLevel::Inherited,
|
||||
&arm.patterns[0],
|
||||
ArmHasGuard(arm.guard.is_some()));
|
||||
(body, scope.unwrap_or(self.visibility_scope))
|
||||
(body, scope.unwrap_or(self.source_scope))
|
||||
}).collect();
|
||||
|
||||
// create binding start block for link them by false edges
|
||||
@ -200,15 +200,15 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
let end_block = self.cfg.start_new_block();
|
||||
|
||||
let outer_source_info = self.source_info(span);
|
||||
for (arm_index, (body, visibility_scope)) in arm_bodies.into_iter().enumerate() {
|
||||
for (arm_index, (body, source_scope)) in arm_bodies.into_iter().enumerate() {
|
||||
let mut arm_block = arm_blocks.blocks[arm_index];
|
||||
// Re-enter the visibility scope we created the bindings in.
|
||||
self.visibility_scope = visibility_scope;
|
||||
// Re-enter the source scope we created the bindings in.
|
||||
self.source_scope = source_scope;
|
||||
unpack!(arm_block = self.into(destination, arm_block, body));
|
||||
self.cfg.terminate(arm_block, outer_source_info,
|
||||
TerminatorKind::Goto { target: end_block });
|
||||
}
|
||||
self.visibility_scope = outer_source_info.scope;
|
||||
self.source_scope = outer_source_info.scope;
|
||||
|
||||
end_block.unit()
|
||||
}
|
||||
@ -298,36 +298,37 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
/// for the bindings in this patterns, if such a scope had to be created.
|
||||
/// NOTE: Declaring the bindings should always be done in their drop scope.
|
||||
pub fn declare_bindings(&mut self,
|
||||
mut var_scope: Option<VisibilityScope>,
|
||||
mut visibility_scope: Option<SourceScope>,
|
||||
scope_span: Span,
|
||||
lint_level: LintLevel,
|
||||
pattern: &Pattern<'tcx>,
|
||||
has_guard: ArmHasGuard)
|
||||
-> Option<VisibilityScope> {
|
||||
assert!(!(var_scope.is_some() && lint_level.is_explicit()),
|
||||
"can't have both a var and a lint scope at the same time");
|
||||
let mut syntactic_scope = self.visibility_scope;
|
||||
-> Option<SourceScope> {
|
||||
assert!(!(visibility_scope.is_some() && lint_level.is_explicit()),
|
||||
"can't have both a visibility and a lint scope at the same time");
|
||||
let mut scope = self.source_scope;
|
||||
self.visit_bindings(pattern, &mut |this, mutability, name, var, span, ty| {
|
||||
if var_scope.is_none() {
|
||||
var_scope = Some(this.new_visibility_scope(scope_span,
|
||||
if visibility_scope.is_none() {
|
||||
visibility_scope = Some(this.new_source_scope(scope_span,
|
||||
LintLevel::Inherited,
|
||||
None));
|
||||
// If we have lints, create a new visibility scope
|
||||
// If we have lints, create a new source scope
|
||||
// that marks the lints for the locals. See the comment
|
||||
// on the `syntactic_scope` field for why this is needed.
|
||||
// on the `source_info` field for why this is needed.
|
||||
if lint_level.is_explicit() {
|
||||
syntactic_scope =
|
||||
this.new_visibility_scope(scope_span, lint_level, None);
|
||||
scope =
|
||||
this.new_source_scope(scope_span, lint_level, None);
|
||||
}
|
||||
}
|
||||
let source_info = SourceInfo {
|
||||
span,
|
||||
scope: var_scope.unwrap()
|
||||
scope,
|
||||
};
|
||||
this.declare_binding(source_info, syntactic_scope, mutability, name, var,
|
||||
let visibility_scope = visibility_scope.unwrap();
|
||||
this.declare_binding(source_info, visibility_scope, mutability, name, var,
|
||||
ty, has_guard);
|
||||
});
|
||||
var_scope
|
||||
visibility_scope
|
||||
}
|
||||
|
||||
pub fn storage_live_binding(&mut self,
|
||||
@ -1114,16 +1115,16 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
/// in the arm body, which will have type `T`.
|
||||
fn declare_binding(&mut self,
|
||||
source_info: SourceInfo,
|
||||
syntactic_scope: VisibilityScope,
|
||||
visibility_scope: SourceScope,
|
||||
mutability: Mutability,
|
||||
name: Name,
|
||||
var_id: NodeId,
|
||||
var_ty: Ty<'tcx>,
|
||||
has_guard: ArmHasGuard)
|
||||
{
|
||||
debug!("declare_binding(var_id={:?}, name={:?}, var_ty={:?}, source_info={:?}, \
|
||||
syntactic_scope={:?})",
|
||||
var_id, name, var_ty, source_info, syntactic_scope);
|
||||
debug!("declare_binding(var_id={:?}, name={:?}, var_ty={:?}, visibility_scope={:?}, \
|
||||
source_info={:?})",
|
||||
var_id, name, var_ty, visibility_scope, source_info);
|
||||
|
||||
let tcx = self.hir.tcx();
|
||||
let local = LocalDecl::<'tcx> {
|
||||
@ -1131,7 +1132,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
ty: var_ty.clone(),
|
||||
name: Some(name),
|
||||
source_info,
|
||||
syntactic_scope,
|
||||
visibility_scope,
|
||||
internal: false,
|
||||
is_user_variable: true,
|
||||
};
|
||||
@ -1143,7 +1144,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
ty: tcx.mk_imm_ref(tcx.types.re_empty, var_ty),
|
||||
name: Some(name),
|
||||
source_info,
|
||||
syntactic_scope,
|
||||
visibility_scope,
|
||||
internal: false,
|
||||
is_user_variable: true,
|
||||
});
|
||||
|
@ -256,9 +256,9 @@ struct Builder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
|
||||
/// the vector of all scopes that we have created thus far;
|
||||
/// we track this for debuginfo later
|
||||
visibility_scopes: IndexVec<VisibilityScope, VisibilityScopeData>,
|
||||
visibility_scope_info: IndexVec<VisibilityScope, VisibilityScopeInfo>,
|
||||
visibility_scope: VisibilityScope,
|
||||
source_scopes: IndexVec<SourceScope, SourceScopeData>,
|
||||
source_scope_local_data: IndexVec<SourceScope, SourceScopeLocalData>,
|
||||
source_scope: SourceScope,
|
||||
|
||||
/// the guard-context: each time we build the guard expression for
|
||||
/// a match arm, we push onto this stack, and then pop when we
|
||||
@ -593,9 +593,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
fn_span: span,
|
||||
arg_count,
|
||||
scopes: vec![],
|
||||
visibility_scopes: IndexVec::new(),
|
||||
visibility_scope: ARGUMENT_VISIBILITY_SCOPE,
|
||||
visibility_scope_info: IndexVec::new(),
|
||||
source_scopes: IndexVec::new(),
|
||||
source_scope: OUTERMOST_SOURCE_SCOPE,
|
||||
source_scope_local_data: IndexVec::new(),
|
||||
guard_context: vec![],
|
||||
push_unsafe_count: 0,
|
||||
unpushed_unsafe: safety,
|
||||
@ -611,9 +611,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
|
||||
assert_eq!(builder.cfg.start_new_block(), START_BLOCK);
|
||||
assert_eq!(
|
||||
builder.new_visibility_scope(span, lint_level, Some(safety)),
|
||||
ARGUMENT_VISIBILITY_SCOPE);
|
||||
builder.visibility_scopes[ARGUMENT_VISIBILITY_SCOPE].parent_scope = None;
|
||||
builder.new_source_scope(span, lint_level, Some(safety)),
|
||||
OUTERMOST_SOURCE_SCOPE);
|
||||
builder.source_scopes[OUTERMOST_SOURCE_SCOPE].parent_scope = None;
|
||||
|
||||
builder
|
||||
}
|
||||
@ -629,8 +629,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
|
||||
Mir::new(self.cfg.basic_blocks,
|
||||
self.visibility_scopes,
|
||||
ClearCrossCrate::Set(self.visibility_scope_info),
|
||||
self.source_scopes,
|
||||
ClearCrossCrate::Set(self.source_scope_local_data),
|
||||
IndexVec::new(),
|
||||
yield_ty,
|
||||
self.local_decls,
|
||||
@ -657,14 +657,15 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
let source_info = SourceInfo {
|
||||
scope: OUTERMOST_SOURCE_SCOPE,
|
||||
span: pattern.map_or(self.fn_span, |pat| pat.span)
|
||||
};
|
||||
self.local_decls.push(LocalDecl {
|
||||
mutability: Mutability::Mut,
|
||||
ty,
|
||||
source_info: SourceInfo {
|
||||
scope: ARGUMENT_VISIBILITY_SCOPE,
|
||||
span: pattern.map_or(self.fn_span, |pat| pat.span)
|
||||
},
|
||||
syntactic_scope: ARGUMENT_VISIBILITY_SCOPE,
|
||||
source_info,
|
||||
visibility_scope: source_info.scope,
|
||||
name,
|
||||
internal: false,
|
||||
is_user_variable: false,
|
||||
@ -702,9 +703,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
|
||||
}
|
||||
|
||||
// Enter the argument pattern bindings visibility scope, if it exists.
|
||||
if let Some(visibility_scope) = scope {
|
||||
self.visibility_scope = visibility_scope;
|
||||
// Enter the argument pattern bindings source scope, if it exists.
|
||||
if let Some(source_scope) = scope {
|
||||
self.source_scope = source_scope;
|
||||
}
|
||||
|
||||
let body = self.hir.mirror(ast_body);
|
||||
|
@ -100,8 +100,8 @@ use rustc_data_structures::fx::FxHashMap;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Scope<'tcx> {
|
||||
/// The visibility scope this scope was created in.
|
||||
visibility_scope: VisibilityScope,
|
||||
/// The source scope this scope was created in.
|
||||
source_scope: SourceScope,
|
||||
|
||||
/// the region span of this scope within source code.
|
||||
region_scope: region::Scope,
|
||||
@ -251,11 +251,11 @@ impl<'tcx> Scope<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Given a span and this scope's visibility scope, make a SourceInfo.
|
||||
/// Given a span and this scope's source scope, make a SourceInfo.
|
||||
fn source_info(&self, span: Span) -> SourceInfo {
|
||||
SourceInfo {
|
||||
span,
|
||||
scope: self.visibility_scope
|
||||
scope: self.source_scope
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -316,14 +316,14 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
where F: FnOnce(&mut Builder<'a, 'gcx, 'tcx>) -> BlockAnd<R>
|
||||
{
|
||||
debug!("in_scope(region_scope={:?}, block={:?})", region_scope, block);
|
||||
let visibility_scope = self.visibility_scope;
|
||||
let source_scope = self.source_scope;
|
||||
let tcx = self.hir.tcx();
|
||||
if let LintLevel::Explicit(node_id) = lint_level {
|
||||
let same_lint_scopes = tcx.dep_graph.with_ignore(|| {
|
||||
let sets = tcx.lint_levels(LOCAL_CRATE);
|
||||
let parent_hir_id =
|
||||
tcx.hir.definitions().node_to_hir_id(
|
||||
self.visibility_scope_info[visibility_scope].lint_root
|
||||
self.source_scope_local_data[source_scope].lint_root
|
||||
);
|
||||
let current_hir_id =
|
||||
tcx.hir.definitions().node_to_hir_id(node_id);
|
||||
@ -332,15 +332,15 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
});
|
||||
|
||||
if !same_lint_scopes {
|
||||
self.visibility_scope =
|
||||
self.new_visibility_scope(region_scope.1.span, lint_level,
|
||||
self.source_scope =
|
||||
self.new_source_scope(region_scope.1.span, lint_level,
|
||||
None);
|
||||
}
|
||||
}
|
||||
self.push_scope(region_scope);
|
||||
let rv = unpack!(block = f(self));
|
||||
unpack!(block = self.pop_scope(region_scope, block));
|
||||
self.visibility_scope = visibility_scope;
|
||||
self.source_scope = source_scope;
|
||||
debug!("in_scope: exiting region_scope={:?} block={:?}", region_scope, block);
|
||||
block.and(rv)
|
||||
}
|
||||
@ -351,9 +351,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
/// wrapper maybe preferable.
|
||||
pub fn push_scope(&mut self, region_scope: (region::Scope, SourceInfo)) {
|
||||
debug!("push_scope({:?})", region_scope);
|
||||
let vis_scope = self.visibility_scope;
|
||||
let vis_scope = self.source_scope;
|
||||
self.scopes.push(Scope {
|
||||
visibility_scope: vis_scope,
|
||||
source_scope: vis_scope,
|
||||
region_scope: region_scope.0,
|
||||
region_scope_span: region_scope.1.span,
|
||||
needs_cleanup: false,
|
||||
@ -509,30 +509,30 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
Some(result)
|
||||
}
|
||||
|
||||
/// Creates a new visibility scope, nested in the current one.
|
||||
pub fn new_visibility_scope(&mut self,
|
||||
/// Creates a new source scope, nested in the current one.
|
||||
pub fn new_source_scope(&mut self,
|
||||
span: Span,
|
||||
lint_level: LintLevel,
|
||||
safety: Option<Safety>) -> VisibilityScope {
|
||||
let parent = self.visibility_scope;
|
||||
debug!("new_visibility_scope({:?}, {:?}, {:?}) - parent({:?})={:?}",
|
||||
safety: Option<Safety>) -> SourceScope {
|
||||
let parent = self.source_scope;
|
||||
debug!("new_source_scope({:?}, {:?}, {:?}) - parent({:?})={:?}",
|
||||
span, lint_level, safety,
|
||||
parent, self.visibility_scope_info.get(parent));
|
||||
let scope = self.visibility_scopes.push(VisibilityScopeData {
|
||||
parent, self.source_scope_local_data.get(parent));
|
||||
let scope = self.source_scopes.push(SourceScopeData {
|
||||
span,
|
||||
parent_scope: Some(parent),
|
||||
});
|
||||
let scope_info = VisibilityScopeInfo {
|
||||
let scope_local_data = SourceScopeLocalData {
|
||||
lint_root: if let LintLevel::Explicit(lint_root) = lint_level {
|
||||
lint_root
|
||||
} else {
|
||||
self.visibility_scope_info[parent].lint_root
|
||||
self.source_scope_local_data[parent].lint_root
|
||||
},
|
||||
safety: safety.unwrap_or_else(|| {
|
||||
self.visibility_scope_info[parent].safety
|
||||
self.source_scope_local_data[parent].safety
|
||||
})
|
||||
};
|
||||
self.visibility_scope_info.push(scope_info);
|
||||
self.source_scope_local_data.push(scope_local_data);
|
||||
scope
|
||||
}
|
||||
|
||||
@ -552,11 +552,11 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
.unwrap_or_else(|| span_bug!(span, "no enclosing breakable scope found"))
|
||||
}
|
||||
|
||||
/// Given a span and the current visibility scope, make a SourceInfo.
|
||||
/// Given a span and the current source scope, make a SourceInfo.
|
||||
pub fn source_info(&self, span: Span) -> SourceInfo {
|
||||
SourceInfo {
|
||||
span,
|
||||
scope: self.visibility_scope
|
||||
scope: self.source_scope
|
||||
}
|
||||
}
|
||||
|
||||
@ -730,7 +730,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
let resumeblk = self.cfg.start_new_cleanup_block();
|
||||
self.cfg.terminate(resumeblk,
|
||||
SourceInfo {
|
||||
scope: ARGUMENT_VISIBILITY_SCOPE,
|
||||
scope: OUTERMOST_SOURCE_SCOPE,
|
||||
span: self.fn_span
|
||||
},
|
||||
TerminatorKind::Resume);
|
||||
@ -939,10 +939,10 @@ fn build_diverge_scope<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
// remainder. If everything is cached, we'll just walk right to
|
||||
// left reading the cached results but never create anything.
|
||||
|
||||
let visibility_scope = scope.visibility_scope;
|
||||
let source_scope = scope.source_scope;
|
||||
let source_info = |span| SourceInfo {
|
||||
span,
|
||||
scope: visibility_scope
|
||||
scope: source_scope
|
||||
};
|
||||
|
||||
// Next, build up the drops. Here we iterate the vector in
|
||||
|
@ -138,10 +138,11 @@ enum CallKind {
|
||||
}
|
||||
|
||||
fn temp_decl(mutability: Mutability, ty: Ty, span: Span) -> LocalDecl {
|
||||
let source_info = SourceInfo { scope: OUTERMOST_SOURCE_SCOPE, span };
|
||||
LocalDecl {
|
||||
mutability, ty, name: None,
|
||||
source_info: SourceInfo { scope: ARGUMENT_VISIBILITY_SCOPE, span },
|
||||
syntactic_scope: ARGUMENT_VISIBILITY_SCOPE,
|
||||
source_info,
|
||||
visibility_scope: source_info.scope,
|
||||
internal: false,
|
||||
is_user_variable: false
|
||||
}
|
||||
@ -178,7 +179,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
let sig = tcx.erase_late_bound_regions(&sig);
|
||||
let span = tcx.def_span(def_id);
|
||||
|
||||
let source_info = SourceInfo { span, scope: ARGUMENT_VISIBILITY_SCOPE };
|
||||
let source_info = SourceInfo { span, scope: OUTERMOST_SOURCE_SCOPE };
|
||||
|
||||
let return_block = BasicBlock::new(1);
|
||||
let mut blocks = IndexVec::new();
|
||||
@ -195,7 +196,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
let mut mir = Mir::new(
|
||||
blocks,
|
||||
IndexVec::from_elem_n(
|
||||
VisibilityScopeData { span: span, parent_scope: None }, 1
|
||||
SourceScopeData { span: span, parent_scope: None }, 1
|
||||
),
|
||||
ClearCrossCrate::Clear,
|
||||
IndexVec::new(),
|
||||
@ -354,7 +355,7 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
|
||||
Mir::new(
|
||||
self.blocks,
|
||||
IndexVec::from_elem_n(
|
||||
VisibilityScopeData { span: self.span, parent_scope: None }, 1
|
||||
SourceScopeData { span: self.span, parent_scope: None }, 1
|
||||
),
|
||||
ClearCrossCrate::Clear,
|
||||
IndexVec::new(),
|
||||
@ -367,7 +368,7 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn source_info(&self) -> SourceInfo {
|
||||
SourceInfo { span: self.span, scope: ARGUMENT_VISIBILITY_SCOPE }
|
||||
SourceInfo { span: self.span, scope: OUTERMOST_SOURCE_SCOPE }
|
||||
}
|
||||
|
||||
fn block(
|
||||
@ -688,7 +689,7 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
debug!("build_call_shim: sig={:?}", sig);
|
||||
|
||||
let mut local_decls = local_decls_for_sig(&sig, span);
|
||||
let source_info = SourceInfo { span, scope: ARGUMENT_VISIBILITY_SCOPE };
|
||||
let source_info = SourceInfo { span, scope: OUTERMOST_SOURCE_SCOPE };
|
||||
|
||||
let rcvr_arg = Local::new(1+0);
|
||||
let rcvr_l = Place::Local(rcvr_arg);
|
||||
@ -794,7 +795,7 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
let mut mir = Mir::new(
|
||||
blocks,
|
||||
IndexVec::from_elem_n(
|
||||
VisibilityScopeData { span: span, parent_scope: None }, 1
|
||||
SourceScopeData { span: span, parent_scope: None }, 1
|
||||
),
|
||||
ClearCrossCrate::Clear,
|
||||
IndexVec::new(),
|
||||
@ -836,7 +837,7 @@ pub fn build_adt_ctor<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>,
|
||||
|
||||
let source_info = SourceInfo {
|
||||
span,
|
||||
scope: ARGUMENT_VISIBILITY_SCOPE
|
||||
scope: OUTERMOST_SOURCE_SCOPE
|
||||
};
|
||||
|
||||
let variant_no = if adt_def.is_enum() {
|
||||
@ -869,7 +870,7 @@ pub fn build_adt_ctor<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>,
|
||||
Mir::new(
|
||||
IndexVec::from_elem_n(start_block, 1),
|
||||
IndexVec::from_elem_n(
|
||||
VisibilityScopeData { span: span, parent_scope: None }, 1
|
||||
SourceScopeData { span: span, parent_scope: None }, 1
|
||||
),
|
||||
ClearCrossCrate::Clear,
|
||||
IndexVec::new(),
|
||||
|
@ -231,7 +231,7 @@ impl MirPass for AddValidation {
|
||||
// Add an AcquireValid at the beginning of the start block.
|
||||
{
|
||||
let source_info = SourceInfo {
|
||||
scope: ARGUMENT_VISIBILITY_SCOPE,
|
||||
scope: OUTERMOST_SOURCE_SCOPE,
|
||||
span: mir.span, // FIXME: Consider using just the span covering the function
|
||||
// argument declaration.
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ use util;
|
||||
|
||||
pub struct UnsafetyChecker<'a, 'tcx: 'a> {
|
||||
mir: &'a Mir<'tcx>,
|
||||
visibility_scope_info: &'a IndexVec<VisibilityScope, VisibilityScopeInfo>,
|
||||
source_scope_local_data: &'a IndexVec<SourceScope, SourceScopeLocalData>,
|
||||
violations: Vec<UnsafetyViolation>,
|
||||
source_info: SourceInfo,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
@ -38,16 +38,16 @@ pub struct UnsafetyChecker<'a, 'tcx: 'a> {
|
||||
|
||||
impl<'a, 'gcx, 'tcx> UnsafetyChecker<'a, 'tcx> {
|
||||
fn new(mir: &'a Mir<'tcx>,
|
||||
visibility_scope_info: &'a IndexVec<VisibilityScope, VisibilityScopeInfo>,
|
||||
source_scope_local_data: &'a IndexVec<SourceScope, SourceScopeLocalData>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>) -> Self {
|
||||
Self {
|
||||
mir,
|
||||
visibility_scope_info,
|
||||
source_scope_local_data,
|
||||
violations: vec![],
|
||||
source_info: SourceInfo {
|
||||
span: mir.span,
|
||||
scope: ARGUMENT_VISIBILITY_SCOPE
|
||||
scope: OUTERMOST_SOURCE_SCOPE
|
||||
},
|
||||
tcx,
|
||||
param_env,
|
||||
@ -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) {
|
||||
let source_info = self.source_info;
|
||||
let lint_root =
|
||||
self.visibility_scope_info[source_info.scope].lint_root;
|
||||
self.source_scope_local_data[source_info.scope].lint_root;
|
||||
self.register_violations(&[UnsafetyViolation {
|
||||
source_info,
|
||||
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) {
|
||||
let source_info = self.source_info;
|
||||
let lint_root =
|
||||
self.visibility_scope_info[source_info.scope].lint_root;
|
||||
self.source_scope_local_data[source_info.scope].lint_root;
|
||||
self.register_violations(&[UnsafetyViolation {
|
||||
source_info,
|
||||
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,
|
||||
violations: &[UnsafetyViolation],
|
||||
unsafe_blocks: &[(ast::NodeId, bool)]) {
|
||||
let within_unsafe = match self.visibility_scope_info[self.source_info.scope].safety {
|
||||
let within_unsafe = match self.source_scope_local_data[self.source_info.scope].safety {
|
||||
Safety::Safe => {
|
||||
for violation in violations {
|
||||
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.
|
||||
let mir = &tcx.mir_built(def_id).borrow();
|
||||
|
||||
let visibility_scope_info = match mir.visibility_scope_info {
|
||||
let source_scope_local_data = match mir.source_scope_local_data {
|
||||
ClearCrossCrate::Set(ref data) => data,
|
||||
ClearCrossCrate::Clear => {
|
||||
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 mut checker = UnsafetyChecker::new(
|
||||
mir, visibility_scope_info, tcx, param_env);
|
||||
mir, source_scope_local_data, tcx, param_env);
|
||||
checker.visit_mir(mir);
|
||||
|
||||
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();
|
||||
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) {
|
||||
let scope_info = match self.mir.visibility_scope_info {
|
||||
let source_scope_local_data = match self.mir.source_scope_local_data {
|
||||
ClearCrossCrate::Set(ref data) => data,
|
||||
ClearCrossCrate::Clear => return None,
|
||||
};
|
||||
@ -347,7 +347,7 @@ impl<'b, 'a, 'tcx:'b> ConstPropagator<'b, 'a, 'tcx> {
|
||||
} else {
|
||||
"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(
|
||||
::rustc::lint::builtin::EXCEEDING_BITSHIFTS,
|
||||
node_id,
|
||||
|
@ -295,12 +295,13 @@ fn make_generator_state_argument_indirect<'a, 'tcx>(
|
||||
|
||||
fn replace_result_variable<'tcx>(ret_ty: Ty<'tcx>,
|
||||
mir: &mut Mir<'tcx>) -> Local {
|
||||
let source_info = source_info(mir);
|
||||
let new_ret = LocalDecl {
|
||||
mutability: Mutability::Mut,
|
||||
ty: ret_ty,
|
||||
name: None,
|
||||
source_info: source_info(mir),
|
||||
syntactic_scope: ARGUMENT_VISIBILITY_SCOPE,
|
||||
source_info,
|
||||
visibility_scope: source_info.scope,
|
||||
internal: false,
|
||||
is_user_variable: false,
|
||||
};
|
||||
@ -641,7 +642,7 @@ fn create_generator_drop_shim<'a, 'tcx>(
|
||||
ty: tcx.mk_nil(),
|
||||
name: None,
|
||||
source_info,
|
||||
syntactic_scope: ARGUMENT_VISIBILITY_SCOPE,
|
||||
visibility_scope: source_info.scope,
|
||||
internal: false,
|
||||
is_user_variable: false,
|
||||
};
|
||||
@ -657,7 +658,7 @@ fn create_generator_drop_shim<'a, 'tcx>(
|
||||
}),
|
||||
name: None,
|
||||
source_info,
|
||||
syntactic_scope: ARGUMENT_VISIBILITY_SCOPE,
|
||||
visibility_scope: source_info.scope,
|
||||
internal: false,
|
||||
is_user_variable: false,
|
||||
};
|
||||
@ -762,7 +763,7 @@ fn create_generator_resume_function<'a, 'tcx>(
|
||||
fn source_info<'a, 'tcx>(mir: &Mir<'tcx>) -> SourceInfo {
|
||||
SourceInfo {
|
||||
span: mir.span,
|
||||
scope: ARGUMENT_VISIBILITY_SCOPE,
|
||||
scope: OUTERMOST_SOURCE_SCOPE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -380,10 +380,10 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
|
||||
debug!("Inlined {:?} into {:?}", callsite.callee, self.source);
|
||||
|
||||
let mut local_map = IndexVec::with_capacity(callee_mir.local_decls.len());
|
||||
let mut scope_map = IndexVec::with_capacity(callee_mir.visibility_scopes.len());
|
||||
let mut scope_map = IndexVec::with_capacity(callee_mir.source_scopes.len());
|
||||
let mut promoted_map = IndexVec::with_capacity(callee_mir.promoted.len());
|
||||
|
||||
for mut scope in callee_mir.visibility_scopes.iter().cloned() {
|
||||
for mut scope in callee_mir.source_scopes.iter().cloned() {
|
||||
if scope.parent_scope.is_none() {
|
||||
scope.parent_scope = Some(callsite.location.scope);
|
||||
scope.span = callee_mir.span;
|
||||
@ -391,15 +391,17 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
|
||||
|
||||
scope.span = callsite.location.span;
|
||||
|
||||
let idx = caller_mir.visibility_scopes.push(scope);
|
||||
let idx = caller_mir.source_scopes.push(scope);
|
||||
scope_map.push(idx);
|
||||
}
|
||||
|
||||
for loc in callee_mir.vars_and_temps_iter() {
|
||||
let mut local = callee_mir.local_decls[loc].clone();
|
||||
|
||||
local.source_info.scope = scope_map[local.source_info.scope];
|
||||
local.source_info.scope =
|
||||
scope_map[local.source_info.scope];
|
||||
local.source_info.span = callsite.location.span;
|
||||
local.visibility_scope = scope_map[local.visibility_scope];
|
||||
|
||||
let idx = caller_mir.local_decls.push(local);
|
||||
local_map.push(idx);
|
||||
@ -618,7 +620,7 @@ struct Integrator<'a, 'tcx: 'a> {
|
||||
block_idx: usize,
|
||||
args: &'a [Local],
|
||||
local_map: IndexVec<Local, Local>,
|
||||
scope_map: IndexVec<VisibilityScope, VisibilityScope>,
|
||||
scope_map: IndexVec<SourceScope, SourceScope>,
|
||||
promoted_map: IndexVec<Promoted, Promoted>,
|
||||
_callsite: CallSite<'tcx>,
|
||||
destination: Place<'tcx>,
|
||||
@ -745,7 +747,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_visibility_scope(&mut self, scope: &mut VisibilityScope) {
|
||||
fn visit_source_scope(&mut self, scope: &mut SourceScope) {
|
||||
*scope = self.scope_map[*scope];
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
|
||||
terminator: Some(Terminator {
|
||||
source_info: SourceInfo {
|
||||
span,
|
||||
scope: ARGUMENT_VISIBILITY_SCOPE
|
||||
scope: OUTERMOST_SOURCE_SCOPE
|
||||
},
|
||||
kind: TerminatorKind::Return
|
||||
}),
|
||||
@ -181,7 +181,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
|
||||
data.statements.push(Statement {
|
||||
source_info: SourceInfo {
|
||||
span,
|
||||
scope: ARGUMENT_VISIBILITY_SCOPE
|
||||
scope: OUTERMOST_SOURCE_SCOPE
|
||||
},
|
||||
kind: StatementKind::Assign(Place::Local(dest), rvalue)
|
||||
});
|
||||
@ -335,6 +335,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
|
||||
// otherwise we would use the `promoted` directly.
|
||||
let mut promoted_ref = LocalDecl::new_temp(ref_ty, span);
|
||||
promoted_ref.source_info = statement.source_info;
|
||||
promoted_ref.visibility_scope = statement.source_info.scope;
|
||||
let promoted_ref = local_decls.push(promoted_ref);
|
||||
assert_eq!(self.temps.push(TempState::Unpromotable), promoted_ref);
|
||||
self.extra_statements.push((loc, Statement {
|
||||
@ -424,8 +425,8 @@ pub fn promote_candidates<'a, 'tcx>(mir: &mut Mir<'tcx>,
|
||||
IndexVec::new(),
|
||||
// FIXME: maybe try to filter this to avoid blowing up
|
||||
// memory usage?
|
||||
mir.visibility_scopes.clone(),
|
||||
mir.visibility_scope_info.clone(),
|
||||
mir.source_scopes.clone(),
|
||||
mir.source_scope_local_data.clone(),
|
||||
IndexVec::new(),
|
||||
None,
|
||||
initial_locals,
|
||||
|
@ -62,7 +62,7 @@ impl<'tcx> MirPatch<'tcx> {
|
||||
terminator: Some(Terminator {
|
||||
source_info: SourceInfo {
|
||||
span: mir.span,
|
||||
scope: ARGUMENT_VISIBILITY_SCOPE
|
||||
scope: OUTERMOST_SOURCE_SCOPE
|
||||
},
|
||||
kind: TerminatorKind::Resume
|
||||
}),
|
||||
|
@ -447,9 +447,9 @@ fn comment(tcx: TyCtxt, SourceInfo { span, scope }: SourceInfo) -> String {
|
||||
fn write_scope_tree(
|
||||
tcx: TyCtxt,
|
||||
mir: &Mir,
|
||||
scope_tree: &FxHashMap<VisibilityScope, Vec<VisibilityScope>>,
|
||||
scope_tree: &FxHashMap<SourceScope, Vec<SourceScope>>,
|
||||
w: &mut dyn Write,
|
||||
parent: VisibilityScope,
|
||||
parent: SourceScope,
|
||||
depth: usize,
|
||||
) -> io::Result<()> {
|
||||
let indent = depth * INDENT.len();
|
||||
@ -460,7 +460,7 @@ fn write_scope_tree(
|
||||
};
|
||||
|
||||
for &child in children {
|
||||
let data = &mir.visibility_scopes[child];
|
||||
let data = &mir.source_scopes[child];
|
||||
assert_eq!(data.parent_scope, Some(parent));
|
||||
writeln!(w, "{0:1$}scope {2} {{", "", indent, child.index())?;
|
||||
|
||||
@ -519,16 +519,16 @@ pub fn write_mir_intro<'a, 'gcx, 'tcx>(
|
||||
writeln!(w, "{{")?;
|
||||
|
||||
// construct a scope tree and write it out
|
||||
let mut scope_tree: FxHashMap<VisibilityScope, Vec<VisibilityScope>> = FxHashMap();
|
||||
for (index, scope_data) in mir.visibility_scopes.iter().enumerate() {
|
||||
let mut scope_tree: FxHashMap<SourceScope, Vec<SourceScope>> = FxHashMap();
|
||||
for (index, scope_data) in mir.source_scopes.iter().enumerate() {
|
||||
if let Some(parent) = scope_data.parent_scope {
|
||||
scope_tree
|
||||
.entry(parent)
|
||||
.or_insert(vec![])
|
||||
.push(VisibilityScope::new(index));
|
||||
.push(SourceScope::new(index));
|
||||
} else {
|
||||
// Only the argument scope has no parent, because it's the root.
|
||||
assert_eq!(index, ARGUMENT_VISIBILITY_SCOPE.index());
|
||||
assert_eq!(index, OUTERMOST_SOURCE_SCOPE.index());
|
||||
}
|
||||
}
|
||||
|
||||
@ -541,7 +541,7 @@ pub fn write_mir_intro<'a, 'gcx, 'tcx>(
|
||||
indented_retptr,
|
||||
ALIGN)?;
|
||||
|
||||
write_scope_tree(tcx, mir, &scope_tree, w, ARGUMENT_VISIBILITY_SCOPE, 1)?;
|
||||
write_scope_tree(tcx, mir, &scope_tree, w, OUTERMOST_SOURCE_SCOPE, 1)?;
|
||||
|
||||
write_temp_decls(mir, w)?;
|
||||
|
||||
|
@ -17,7 +17,7 @@ use rustc::mir::{Constant, Literal, Location, Local, LocalDecl};
|
||||
use rustc::mir::{Place, PlaceElem, PlaceProjection};
|
||||
use rustc::mir::{Mir, Operand, ProjectionElem};
|
||||
use rustc::mir::{Rvalue, SourceInfo, Statement, StatementKind};
|
||||
use rustc::mir::{Terminator, TerminatorKind, VisibilityScope, VisibilityScopeData};
|
||||
use rustc::mir::{Terminator, TerminatorKind, SourceScope, SourceScopeData};
|
||||
use rustc::mir::interpret::EvalErrorKind;
|
||||
use rustc::mir::visit as mir_visit;
|
||||
use rustc::ty::{self, ClosureSubsts, TyCtxt};
|
||||
@ -72,10 +72,10 @@ impl<'a, 'tcx> mir_visit::Visitor<'tcx> for StatCollector<'a, 'tcx> {
|
||||
self.super_basic_block_data(block, data);
|
||||
}
|
||||
|
||||
fn visit_visibility_scope_data(&mut self,
|
||||
scope_data: &VisibilityScopeData) {
|
||||
self.record("VisibilityScopeData", scope_data);
|
||||
self.super_visibility_scope_data(scope_data);
|
||||
fn visit_source_scope_data(&mut self,
|
||||
scope_data: &SourceScopeData) {
|
||||
self.record("SourceScopeData", scope_data);
|
||||
self.super_source_scope_data(scope_data);
|
||||
}
|
||||
|
||||
fn visit_statement(&mut self,
|
||||
@ -278,9 +278,9 @@ impl<'a, 'tcx> mir_visit::Visitor<'tcx> for StatCollector<'a, 'tcx> {
|
||||
self.super_local_decl(local, local_decl);
|
||||
}
|
||||
|
||||
fn visit_visibility_scope(&mut self,
|
||||
scope: &VisibilityScope) {
|
||||
fn visit_source_scope(&mut self,
|
||||
scope: &SourceScope) {
|
||||
self.record("VisiblityScope", scope);
|
||||
self.super_visibility_scope(scope);
|
||||
self.super_source_scope(scope);
|
||||
}
|
||||
}
|
||||
|
@ -33,9 +33,10 @@ impl Drop for S {
|
||||
// START rustc.main.ElaborateDrops.before.mir
|
||||
// let mut _0: ();
|
||||
// scope 1 {
|
||||
// }
|
||||
// scope 2 {
|
||||
// let _1: std::boxed::Box<S>;
|
||||
// }
|
||||
// ...
|
||||
// let mut _2: std::boxed::Box<S>;
|
||||
// let mut _3: ();
|
||||
// let mut _4: std::boxed::Box<S>;
|
||||
|
@ -22,10 +22,10 @@ fn main() {
|
||||
// START rustc.main.SimplifyCfg-qualify-consts.after.mir
|
||||
// let mut _0: ();
|
||||
// ...
|
||||
// let _1: i32;
|
||||
// ...
|
||||
// let _2: &'10_1rs i32;
|
||||
// ...
|
||||
// let _1: i32;
|
||||
// ...
|
||||
// bb0: {
|
||||
// StorageLive(_1);
|
||||
// _1 = const 3i32;
|
||||
|
@ -27,11 +27,11 @@ fn main() {
|
||||
// START rustc.main.SimplifyCfg-qualify-consts.after.mir
|
||||
// let mut _0: ();
|
||||
// ...
|
||||
// let _2: bool;
|
||||
// let _7: &'23_3rs bool;
|
||||
// ...
|
||||
// let _3: &'23_1rs bool;
|
||||
// ...
|
||||
// let _7: &'23_3rs bool;
|
||||
// let _2: bool;
|
||||
// ...
|
||||
// let mut _4: ();
|
||||
// let mut _5: bool;
|
||||
|
@ -28,11 +28,11 @@ fn main() {
|
||||
// START rustc.main.SimplifyCfg-qualify-consts.after.mir
|
||||
// let mut _0: ();
|
||||
// ...
|
||||
// let mut _1: bool;
|
||||
// let _7: &'26_3rs bool;
|
||||
// ...
|
||||
// let _3: &'26_1rs bool;
|
||||
// ...
|
||||
// let _7: &'26_3rs bool;
|
||||
// let mut _1: bool;
|
||||
// ...
|
||||
// let mut _2: ();
|
||||
// let mut _4: ();
|
||||
|
@ -32,13 +32,13 @@ fn foo(i: i32) {
|
||||
// START rustc.main.SimplifyCfg-qualify-consts.after.mir
|
||||
// let mut _0: ();
|
||||
// ...
|
||||
// let _1: D;
|
||||
// ...
|
||||
// let _2: i32;
|
||||
// let _6: &'26_4rs i32;
|
||||
// ...
|
||||
// let _3: &'26_2rs i32;
|
||||
// ...
|
||||
// let _6: &'26_4rs i32;
|
||||
// let _2: i32;
|
||||
// ...
|
||||
// let _1: D;
|
||||
// ...
|
||||
// let mut _4: ();
|
||||
// let mut _5: i32;
|
||||
|
@ -31,10 +31,10 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
|
||||
// fn main() -> () {
|
||||
// let mut _0: ();
|
||||
// ...
|
||||
// let _1: D;
|
||||
// ...
|
||||
// let _2: &'21_1rs D;
|
||||
// ...
|
||||
// let _1: D;
|
||||
// ...
|
||||
// let mut _3: ();
|
||||
// let mut _4: [closure@NodeId(22) r:&'19s D];
|
||||
// let mut _5: &'21_1rs D;
|
||||
|
@ -41,11 +41,11 @@ fn main() {
|
||||
// fn main() -> () {
|
||||
// let mut _0: ();
|
||||
// ...
|
||||
// let mut _1: bool;
|
||||
// let mut _4: &'33_0rs i32;
|
||||
// ...
|
||||
// let _2: i32;
|
||||
// ...
|
||||
// let mut _4: &'33_0rs i32;
|
||||
// let mut _1: bool;
|
||||
// ...
|
||||
// let mut _3: ();
|
||||
// let mut _5: !;
|
||||
|
@ -43,9 +43,9 @@ fn query() -> bool { true }
|
||||
// fn main() -> (){
|
||||
// let mut _0: ();
|
||||
// scope 1 {
|
||||
// let _2: S<'36_0rs>;
|
||||
// }
|
||||
// scope 2 {
|
||||
// let _2: S<'36_0rs>;
|
||||
// }
|
||||
// let mut _1: ();
|
||||
// let mut _3: std::cell::Cell<std::option::Option<&'36_0rs S<'36_0rs>>>;
|
||||
|
@ -40,9 +40,10 @@ impl S {
|
||||
// START rustc.main.ElaborateDrops.after.mir
|
||||
// let mut _0: ();
|
||||
// scope 1 {
|
||||
// }
|
||||
// scope 2 {
|
||||
// let _1: ();
|
||||
// }
|
||||
// ...
|
||||
// let mut _2: S;
|
||||
// let mut _3: S;
|
||||
// let mut _4: S;
|
||||
@ -52,10 +53,10 @@ impl S {
|
||||
// START rustc.test.ElaborateDrops.after.mir
|
||||
// let mut _0: ();
|
||||
// ...
|
||||
// let _1: S;
|
||||
// ...
|
||||
// let mut _2: S;
|
||||
// ...
|
||||
// let _1: S;
|
||||
// ...
|
||||
// let mut _3: ();
|
||||
// let mut _4: S;
|
||||
// let mut _5: S;
|
||||
|
@ -32,7 +32,7 @@ fn main() {
|
||||
// ...
|
||||
// | '_#9r | {bb0[10], bb0[14..=17]}
|
||||
// ...
|
||||
// let _2: &'_#7r mut i32;
|
||||
// ...
|
||||
// let _4: &'_#9r mut i32;
|
||||
// ...
|
||||
// let _2: &'_#7r mut i32;
|
||||
// END rustc.main.nll.0.mir
|
||||
|
@ -37,10 +37,10 @@ fn main() {
|
||||
// | '_#4r | {bb2[5..=6], bb3[0..=1]}
|
||||
// END rustc.main.nll.0.mir
|
||||
// START rustc.main.nll.0.mir
|
||||
// let _2: &'_#3r usize;
|
||||
// ...
|
||||
// let _6: &'_#4r usize;
|
||||
// ...
|
||||
// let _2: &'_#3r usize;
|
||||
// ...
|
||||
// _2 = &'_#2r _1[_3];
|
||||
// ...
|
||||
// _7 = _2;
|
||||
|
@ -29,9 +29,9 @@ impl Drop for Droppy {
|
||||
// fn main() -> () {
|
||||
// let mut _0: ();
|
||||
// scope 1 {
|
||||
// let mut _1: Packed;
|
||||
// }
|
||||
// scope 2 {
|
||||
// let mut _1: Packed;
|
||||
// }
|
||||
// let mut _2: Aligned;
|
||||
// let mut _3: Droppy;
|
||||
|
@ -32,14 +32,14 @@ fn main() {
|
||||
// fn main() -> (){
|
||||
// let mut _0: ();
|
||||
// scope 1 {
|
||||
// let _1: Test;
|
||||
// scope 3 {
|
||||
// let _2: &ReErased Test;
|
||||
// }
|
||||
// scope 4 {
|
||||
// let _2: &ReErased Test;
|
||||
// }
|
||||
// }
|
||||
// scope 2 {
|
||||
// let _1: Test;
|
||||
// }
|
||||
// let mut _3: ();
|
||||
// let mut _4: &ReErased i32;
|
||||
|
Loading…
Reference in New Issue
Block a user