@@ -78,13 +78,13 @@ pub struct Mir<'tcx> {
78
78
/// that indexes into this vector.
79
79
basic_blocks : IndexVec < BasicBlock , BasicBlockData < ' tcx > > ,
80
80
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 > ,
84
84
85
- /// Crate-local information for each visibility scope, that can't (and
85
+ /// Crate-local information for each source scope, that can't (and
86
86
/// needn't) be tracked across crates.
87
- pub visibility_scope_info : ClearCrossCrate < IndexVec < VisibilityScope , VisibilityScopeInfo > > ,
87
+ pub source_scope_info : ClearCrossCrate < IndexVec < SourceScope , SourceScopeInfo > > ,
88
88
89
89
/// Rvalues promoted from this function, such as borrows of constants.
90
90
/// 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);
137
137
138
138
impl < ' tcx > Mir < ' tcx > {
139
139
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 > > ,
143
143
promoted : IndexVec < Promoted , Mir < ' tcx > > ,
144
144
yield_ty : Option < Ty < ' tcx > > ,
145
145
local_decls : IndexVec < Local , LocalDecl < ' tcx > > ,
@@ -153,8 +153,8 @@ impl<'tcx> Mir<'tcx> {
153
153
154
154
Mir {
155
155
basic_blocks,
156
- visibility_scopes ,
157
- visibility_scope_info ,
156
+ source_scopes ,
157
+ source_scope_info ,
158
158
promoted,
159
159
yield_ty,
160
160
generator_drop : None ,
@@ -309,7 +309,7 @@ impl<'tcx> Mir<'tcx> {
309
309
}
310
310
311
311
#[ derive( Clone , Debug , RustcEncodable , RustcDecodable ) ]
312
- pub struct VisibilityScopeInfo {
312
+ pub struct SourceScopeInfo {
313
313
/// A NodeId with lint levels equivalent to this scope's lint levels.
314
314
pub lint_root : ast:: NodeId ,
315
315
/// The unsafe block that contains this node.
@@ -329,8 +329,8 @@ pub enum Safety {
329
329
330
330
impl_stable_hash_for ! ( struct Mir <' tcx> {
331
331
basic_blocks,
332
- visibility_scopes ,
333
- visibility_scope_info ,
332
+ source_scopes ,
333
+ source_scope_info ,
334
334
promoted,
335
335
yield_ty,
336
336
generator_drop,
@@ -376,8 +376,9 @@ pub struct SourceInfo {
376
376
/// Source span for the AST pertaining to this MIR entity.
377
377
pub span : Span ,
378
378
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
381
382
}
382
383
383
384
///////////////////////////////////////////////////////////////////////////
@@ -512,16 +513,17 @@ pub struct LocalDecl<'tcx> {
512
513
/// to generate better debuginfo.
513
514
pub name : Option < Name > ,
514
515
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).
516
518
pub source_info : SourceInfo ,
517
519
518
- /// The *syntactic* visibility scope the local is defined
520
+ /// The *syntactic* (i.e. not visibility) source scope the local is defined
519
521
/// in. If the local was defined in a let-statement, this
520
522
/// is *within* the let-statement, rather than outside
521
523
/// of it.
522
524
///
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.
525
527
///
526
528
/// The reason is that we want the local to be *within* the let-statement
527
529
/// for lint purposes, but we want the local to be *after* the let-statement
@@ -594,7 +596,7 @@ pub struct LocalDecl<'tcx> {
594
596
/// │ │← x.source_info.scope
595
597
/// │ │← `drop(x)` // this accesses `x: u32`
596
598
/// ```
597
- pub syntactic_scope : VisibilityScope ,
599
+ pub syntactic_scope : SourceScope ,
598
600
}
599
601
600
602
impl < ' tcx > LocalDecl < ' tcx > {
@@ -607,9 +609,9 @@ impl<'tcx> LocalDecl<'tcx> {
607
609
name : None ,
608
610
source_info : SourceInfo {
609
611
span,
610
- scope : ARGUMENT_VISIBILITY_SCOPE
612
+ scope : OUTERMOST_SOURCE_SCOPE
611
613
} ,
612
- syntactic_scope : ARGUMENT_VISIBILITY_SCOPE ,
614
+ syntactic_scope : OUTERMOST_SOURCE_SCOPE ,
613
615
internal : false ,
614
616
is_user_variable : false
615
617
}
@@ -624,9 +626,9 @@ impl<'tcx> LocalDecl<'tcx> {
624
626
name : None ,
625
627
source_info : SourceInfo {
626
628
span,
627
- scope : ARGUMENT_VISIBILITY_SCOPE
629
+ scope : OUTERMOST_SOURCE_SCOPE
628
630
} ,
629
- syntactic_scope : ARGUMENT_VISIBILITY_SCOPE ,
631
+ syntactic_scope : OUTERMOST_SOURCE_SCOPE ,
630
632
internal : true ,
631
633
is_user_variable : false
632
634
}
@@ -642,9 +644,9 @@ impl<'tcx> LocalDecl<'tcx> {
642
644
ty : return_ty,
643
645
source_info : SourceInfo {
644
646
span,
645
- scope : ARGUMENT_VISIBILITY_SCOPE
647
+ scope : OUTERMOST_SOURCE_SCOPE
646
648
} ,
647
- syntactic_scope : ARGUMENT_VISIBILITY_SCOPE ,
649
+ syntactic_scope : OUTERMOST_SOURCE_SCOPE ,
648
650
internal : false ,
649
651
name : None , // FIXME maybe we do want some name here?
650
652
is_user_variable : false
@@ -1047,7 +1049,7 @@ impl<'tcx> BasicBlockData<'tcx> {
1047
1049
self . statements . resize ( gap. end , Statement {
1048
1050
source_info : SourceInfo {
1049
1051
span : DUMMY_SP ,
1050
- scope : ARGUMENT_VISIBILITY_SCOPE
1052
+ scope : OUTERMOST_SOURCE_SCOPE
1051
1053
} ,
1052
1054
kind : StatementKind :: Nop
1053
1055
} ) ;
@@ -1501,16 +1503,16 @@ impl<'tcx> Debug for Place<'tcx> {
1501
1503
///////////////////////////////////////////////////////////////////////////
1502
1504
// Scopes
1503
1505
1504
- newtype_index ! ( VisibilityScope
1506
+ newtype_index ! ( SourceScope
1505
1507
{
1506
1508
DEBUG_FORMAT = "scope[{}]" ,
1507
- const ARGUMENT_VISIBILITY_SCOPE = 0 ,
1509
+ const OUTERMOST_SOURCE_SCOPE = 0 ,
1508
1510
} ) ;
1509
1511
1510
1512
#[ derive( Clone , Debug , RustcEncodable , RustcDecodable ) ]
1511
- pub struct VisibilityScopeData {
1513
+ pub struct SourceScopeData {
1512
1514
pub span : Span ,
1513
- pub parent_scope : Option < VisibilityScope > ,
1515
+ pub parent_scope : Option < SourceScope > ,
1514
1516
}
1515
1517
1516
1518
///////////////////////////////////////////////////////////////////////////
@@ -2153,16 +2155,16 @@ CloneTypeFoldableAndLiftImpls! {
2153
2155
SourceInfo ,
2154
2156
UpvarDecl ,
2155
2157
ValidationOp ,
2156
- VisibilityScopeData ,
2157
- VisibilityScope ,
2158
- VisibilityScopeInfo ,
2158
+ SourceScopeData ,
2159
+ SourceScope ,
2160
+ SourceScopeInfo ,
2159
2161
}
2160
2162
2161
2163
BraceStructTypeFoldableImpl ! {
2162
2164
impl <' tcx> TypeFoldable <' tcx> for Mir <' tcx> {
2163
2165
basic_blocks,
2164
- visibility_scopes ,
2165
- visibility_scope_info ,
2166
+ source_scopes ,
2167
+ source_scope_info ,
2166
2168
promoted,
2167
2169
yield_ty,
2168
2170
generator_drop,
0 commit comments