Skip to content

Commit 85d44c4

Browse files
committed
rustc: rename mir::VisibilityScope to mir::SourceScope.
1 parent 74d0939 commit 85d44c4

File tree

20 files changed

+193
-191
lines changed

20 files changed

+193
-191
lines changed

src/librustc/ich/impls_mir.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for mir::Field {
127127
}
128128

129129
impl<'a> HashStable<StableHashingContext<'a>>
130-
for mir::VisibilityScope {
130+
for mir::SourceScope {
131131
#[inline]
132132
fn hash_stable<W: StableHasherResult>(&self,
133133
hcx: &mut StableHashingContext<'a>,
@@ -363,8 +363,8 @@ for mir::ProjectionElem<'gcx, V, T>
363363
}
364364
}
365365

366-
impl_stable_hash_for!(struct mir::VisibilityScopeData { span, parent_scope });
367-
impl_stable_hash_for!(struct mir::VisibilityScopeInfo {
366+
impl_stable_hash_for!(struct mir::SourceScopeData { span, parent_scope });
367+
impl_stable_hash_for!(struct mir::SourceScopeInfo {
368368
lint_root, safety
369369
});
370370

src/librustc/mir/mod.rs

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ pub struct Mir<'tcx> {
7878
/// that indexes into this vector.
7979
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
8080

81-
/// List of visibility (lexical) scopes; these are referenced by statements
82-
/// and used (eventually) for debuginfo. Indexed by a `VisibilityScope`.
83-
pub visibility_scopes: IndexVec<VisibilityScope, VisibilityScopeData>,
81+
/// List of source scopes; these are referenced by statements
82+
/// and used for debuginfo. Indexed by a `SourceScope`.
83+
pub source_scopes: IndexVec<SourceScope, SourceScopeData>,
8484

85-
/// Crate-local information for each visibility scope, that can't (and
85+
/// Crate-local information for each source scope, that can't (and
8686
/// needn't) be tracked across crates.
87-
pub visibility_scope_info: ClearCrossCrate<IndexVec<VisibilityScope, VisibilityScopeInfo>>,
87+
pub source_scope_info: ClearCrossCrate<IndexVec<SourceScope, SourceScopeInfo>>,
8888

8989
/// Rvalues promoted from this function, such as borrows of constants.
9090
/// 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);
137137

138138
impl<'tcx> Mir<'tcx> {
139139
pub fn new(basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
140-
visibility_scopes: IndexVec<VisibilityScope, VisibilityScopeData>,
141-
visibility_scope_info: ClearCrossCrate<IndexVec<VisibilityScope,
142-
VisibilityScopeInfo>>,
140+
source_scopes: IndexVec<SourceScope, SourceScopeData>,
141+
source_scope_info: ClearCrossCrate<IndexVec<SourceScope,
142+
SourceScopeInfo>>,
143143
promoted: IndexVec<Promoted, Mir<'tcx>>,
144144
yield_ty: Option<Ty<'tcx>>,
145145
local_decls: IndexVec<Local, LocalDecl<'tcx>>,
@@ -153,8 +153,8 @@ impl<'tcx> Mir<'tcx> {
153153

154154
Mir {
155155
basic_blocks,
156-
visibility_scopes,
157-
visibility_scope_info,
156+
source_scopes,
157+
source_scope_info,
158158
promoted,
159159
yield_ty,
160160
generator_drop: None,
@@ -309,7 +309,7 @@ impl<'tcx> Mir<'tcx> {
309309
}
310310

311311
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
312-
pub struct VisibilityScopeInfo {
312+
pub struct SourceScopeInfo {
313313
/// A NodeId with lint levels equivalent to this scope's lint levels.
314314
pub lint_root: ast::NodeId,
315315
/// The unsafe block that contains this node.
@@ -329,8 +329,8 @@ pub enum Safety {
329329

330330
impl_stable_hash_for!(struct Mir<'tcx> {
331331
basic_blocks,
332-
visibility_scopes,
333-
visibility_scope_info,
332+
source_scopes,
333+
source_scope_info,
334334
promoted,
335335
yield_ty,
336336
generator_drop,
@@ -376,8 +376,9 @@ pub struct SourceInfo {
376376
/// Source span for the AST pertaining to this MIR entity.
377377
pub span: Span,
378378

379-
/// The lexical visibility scope, i.e. which bindings can be seen.
380-
pub scope: VisibilityScope
379+
/// The source scope, keeping track of which bindings can be
380+
/// seen by debuginfo, active lint levels, `unsafe {...}`, etc.
381+
pub scope: SourceScope
381382
}
382383

383384
///////////////////////////////////////////////////////////////////////////
@@ -512,16 +513,17 @@ pub struct LocalDecl<'tcx> {
512513
/// to generate better debuginfo.
513514
pub name: Option<Name>,
514515

515-
/// Source info of the local.
516+
/// Source info of the local. The `SourceScope` is the *visibility* one,
517+
/// not the the *syntactic* one (see `syntactic_scope` for more details).
516518
pub source_info: SourceInfo,
517519

518-
/// The *syntactic* visibility scope the local is defined
520+
/// The *syntactic* (i.e. not visibility) source scope the local is defined
519521
/// in. If the local was defined in a let-statement, this
520522
/// is *within* the let-statement, rather than outside
521523
/// of it.
522524
///
523-
/// This is needed because visibility scope of locals within a let-statement
524-
/// is weird.
525+
/// This is needed because the visibility source scope of locals within
526+
/// a let-statement is weird.
525527
///
526528
/// The reason is that we want the local to be *within* the let-statement
527529
/// for lint purposes, but we want the local to be *after* the let-statement
@@ -594,7 +596,7 @@ pub struct LocalDecl<'tcx> {
594596
/// │ │← x.source_info.scope
595597
/// │ │← `drop(x)` // this accesses `x: u32`
596598
/// ```
597-
pub syntactic_scope: VisibilityScope,
599+
pub syntactic_scope: SourceScope,
598600
}
599601

600602
impl<'tcx> LocalDecl<'tcx> {
@@ -607,9 +609,9 @@ impl<'tcx> LocalDecl<'tcx> {
607609
name: None,
608610
source_info: SourceInfo {
609611
span,
610-
scope: ARGUMENT_VISIBILITY_SCOPE
612+
scope: OUTERMOST_SOURCE_SCOPE
611613
},
612-
syntactic_scope: ARGUMENT_VISIBILITY_SCOPE,
614+
syntactic_scope: OUTERMOST_SOURCE_SCOPE,
613615
internal: false,
614616
is_user_variable: false
615617
}
@@ -624,9 +626,9 @@ impl<'tcx> LocalDecl<'tcx> {
624626
name: None,
625627
source_info: SourceInfo {
626628
span,
627-
scope: ARGUMENT_VISIBILITY_SCOPE
629+
scope: OUTERMOST_SOURCE_SCOPE
628630
},
629-
syntactic_scope: ARGUMENT_VISIBILITY_SCOPE,
631+
syntactic_scope: OUTERMOST_SOURCE_SCOPE,
630632
internal: true,
631633
is_user_variable: false
632634
}
@@ -642,9 +644,9 @@ impl<'tcx> LocalDecl<'tcx> {
642644
ty: return_ty,
643645
source_info: SourceInfo {
644646
span,
645-
scope: ARGUMENT_VISIBILITY_SCOPE
647+
scope: OUTERMOST_SOURCE_SCOPE
646648
},
647-
syntactic_scope: ARGUMENT_VISIBILITY_SCOPE,
649+
syntactic_scope: OUTERMOST_SOURCE_SCOPE,
648650
internal: false,
649651
name: None, // FIXME maybe we do want some name here?
650652
is_user_variable: false
@@ -1047,7 +1049,7 @@ impl<'tcx> BasicBlockData<'tcx> {
10471049
self.statements.resize(gap.end, Statement {
10481050
source_info: SourceInfo {
10491051
span: DUMMY_SP,
1050-
scope: ARGUMENT_VISIBILITY_SCOPE
1052+
scope: OUTERMOST_SOURCE_SCOPE
10511053
},
10521054
kind: StatementKind::Nop
10531055
});
@@ -1501,16 +1503,16 @@ impl<'tcx> Debug for Place<'tcx> {
15011503
///////////////////////////////////////////////////////////////////////////
15021504
// Scopes
15031505

1504-
newtype_index!(VisibilityScope
1506+
newtype_index!(SourceScope
15051507
{
15061508
DEBUG_FORMAT = "scope[{}]",
1507-
const ARGUMENT_VISIBILITY_SCOPE = 0,
1509+
const OUTERMOST_SOURCE_SCOPE = 0,
15081510
});
15091511

15101512
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
1511-
pub struct VisibilityScopeData {
1513+
pub struct SourceScopeData {
15121514
pub span: Span,
1513-
pub parent_scope: Option<VisibilityScope>,
1515+
pub parent_scope: Option<SourceScope>,
15141516
}
15151517

15161518
///////////////////////////////////////////////////////////////////////////
@@ -2153,16 +2155,16 @@ CloneTypeFoldableAndLiftImpls! {
21532155
SourceInfo,
21542156
UpvarDecl,
21552157
ValidationOp,
2156-
VisibilityScopeData,
2157-
VisibilityScope,
2158-
VisibilityScopeInfo,
2158+
SourceScopeData,
2159+
SourceScope,
2160+
SourceScopeInfo,
21592161
}
21602162

21612163
BraceStructTypeFoldableImpl! {
21622164
impl<'tcx> TypeFoldable<'tcx> for Mir<'tcx> {
21632165
basic_blocks,
2164-
visibility_scopes,
2165-
visibility_scope_info,
2166+
source_scopes,
2167+
source_scope_info,
21662168
promoted,
21672169
yield_ty,
21682170
generator_drop,

src/librustc/mir/visit.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ macro_rules! make_mir_visitor {
9292
self.super_basic_block_data(block, data);
9393
}
9494

95-
fn visit_visibility_scope_data(&mut self,
96-
scope_data: & $($mutability)* VisibilityScopeData) {
97-
self.super_visibility_scope_data(scope_data);
95+
fn visit_source_scope_data(&mut self,
96+
scope_data: & $($mutability)* SourceScopeData) {
97+
self.super_source_scope_data(scope_data);
9898
}
9999

100100
fn visit_statement(&mut self,
@@ -261,9 +261,9 @@ macro_rules! make_mir_visitor {
261261
_location: Location) {
262262
}
263263

264-
fn visit_visibility_scope(&mut self,
265-
scope: & $($mutability)* VisibilityScope) {
266-
self.super_visibility_scope(scope);
264+
fn visit_source_scope(&mut self,
265+
scope: & $($mutability)* SourceScope) {
266+
self.super_source_scope(scope);
267267
}
268268

269269
// The `super_xxx` methods comprise the default behavior and are
@@ -274,7 +274,7 @@ macro_rules! make_mir_visitor {
274274
if let Some(yield_ty) = &$($mutability)* mir.yield_ty {
275275
self.visit_ty(yield_ty, TyContext::YieldTy(SourceInfo {
276276
span: mir.span,
277-
scope: ARGUMENT_VISIBILITY_SCOPE,
277+
scope: OUTERMOST_SOURCE_SCOPE,
278278
}));
279279
}
280280

@@ -289,13 +289,13 @@ macro_rules! make_mir_visitor {
289289
self.visit_basic_block_data(bb, data);
290290
}
291291

292-
for scope in &$($mutability)* mir.visibility_scopes {
293-
self.visit_visibility_scope_data(scope);
292+
for scope in &$($mutability)* mir.source_scopes {
293+
self.visit_source_scope_data(scope);
294294
}
295295

296296
self.visit_ty(&$($mutability)* mir.return_ty(), TyContext::ReturnTy(SourceInfo {
297297
span: mir.span,
298-
scope: ARGUMENT_VISIBILITY_SCOPE,
298+
scope: OUTERMOST_SOURCE_SCOPE,
299299
}));
300300

301301
for local in mir.local_decls.indices() {
@@ -327,16 +327,16 @@ macro_rules! make_mir_visitor {
327327
}
328328
}
329329

330-
fn super_visibility_scope_data(&mut self,
331-
scope_data: & $($mutability)* VisibilityScopeData) {
332-
let VisibilityScopeData {
330+
fn super_source_scope_data(&mut self,
331+
scope_data: & $($mutability)* SourceScopeData) {
332+
let SourceScopeData {
333333
ref $($mutability)* span,
334334
ref $($mutability)* parent_scope,
335335
} = *scope_data;
336336

337337
self.visit_span(span);
338338
if let Some(ref $($mutability)* parent_scope) = *parent_scope {
339-
self.visit_visibility_scope(parent_scope);
339+
self.visit_source_scope(parent_scope);
340340
}
341341
}
342342

@@ -725,11 +725,11 @@ macro_rules! make_mir_visitor {
725725
source_info: *source_info,
726726
});
727727
self.visit_source_info(source_info);
728-
self.visit_visibility_scope(syntactic_scope);
728+
self.visit_source_scope(syntactic_scope);
729729
}
730730

731-
fn super_visibility_scope(&mut self,
732-
_scope: & $($mutability)* VisibilityScope) {
731+
fn super_source_scope(&mut self,
732+
_scope: & $($mutability)* SourceScope) {
733733
}
734734

735735
fn super_branch(&mut self,
@@ -775,7 +775,7 @@ macro_rules! make_mir_visitor {
775775
} = *source_info;
776776

777777
self.visit_span(span);
778-
self.visit_visibility_scope(scope);
778+
self.visit_source_scope(scope);
779779
}
780780

781781
fn super_ty(&mut self, _ty: & $($mutability)* Ty<'tcx>) {

src/librustc_codegen_llvm/debuginfo/create_scope_map.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use super::utils::{DIB, span_start};
1515
use llvm;
1616
use llvm::debuginfo::DIScope;
1717
use common::CodegenCx;
18-
use rustc::mir::{Mir, VisibilityScope};
18+
use rustc::mir::{Mir, SourceScope};
1919

2020
use libc::c_uint;
2121
use std::ptr;
@@ -45,13 +45,13 @@ impl MirDebugScope {
4545
/// Produce DIScope DIEs for each MIR Scope which has variables defined in it.
4646
/// If debuginfo is disabled, the returned vector is empty.
4747
pub fn create_mir_scopes(cx: &CodegenCx, mir: &Mir, debug_context: &FunctionDebugContext)
48-
-> IndexVec<VisibilityScope, MirDebugScope> {
48+
-> IndexVec<SourceScope, MirDebugScope> {
4949
let null_scope = MirDebugScope {
5050
scope_metadata: ptr::null_mut(),
5151
file_start_pos: BytePos(0),
5252
file_end_pos: BytePos(0)
5353
};
54-
let mut scopes = IndexVec::from_elem(null_scope, &mir.visibility_scopes);
54+
let mut scopes = IndexVec::from_elem(null_scope, &mir.source_scopes);
5555

5656
let debug_context = match *debug_context {
5757
FunctionDebugContext::RegularContext(ref data) => data,
@@ -62,15 +62,15 @@ pub fn create_mir_scopes(cx: &CodegenCx, mir: &Mir, debug_context: &FunctionDebu
6262
};
6363

6464
// Find all the scopes with variables defined in them.
65-
let mut has_variables = BitVector::new(mir.visibility_scopes.len());
65+
let mut has_variables = BitVector::new(mir.source_scopes.len());
6666
for var in mir.vars_iter() {
6767
let decl = &mir.local_decls[var];
6868
has_variables.insert(decl.source_info.scope.index());
6969
}
7070

7171
// Instantiate all scopes.
72-
for idx in 0..mir.visibility_scopes.len() {
73-
let scope = VisibilityScope::new(idx);
72+
for idx in 0..mir.source_scopes.len() {
73+
let scope = SourceScope::new(idx);
7474
make_mir_scope(cx, &mir, &has_variables, debug_context, scope, &mut scopes);
7575
}
7676

@@ -81,13 +81,13 @@ fn make_mir_scope(cx: &CodegenCx,
8181
mir: &Mir,
8282
has_variables: &BitVector,
8383
debug_context: &FunctionDebugContextData,
84-
scope: VisibilityScope,
85-
scopes: &mut IndexVec<VisibilityScope, MirDebugScope>) {
84+
scope: SourceScope,
85+
scopes: &mut IndexVec<SourceScope, MirDebugScope>) {
8686
if scopes[scope].is_valid() {
8787
return;
8888
}
8989

90-
let scope_data = &mir.visibility_scopes[scope];
90+
let scope_data = &mir.source_scopes[scope];
9191
let parent_scope = if let Some(parent) = scope_data.parent_scope {
9292
make_mir_scope(cx, mir, has_variables, debug_context, parent, scopes);
9393
scopes[parent]

0 commit comments

Comments
 (0)