@@ -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
138138impl < ' 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
330330impl_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
600602impl < ' 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
21612163BraceStructTypeFoldableImpl ! {
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,
0 commit comments