@@ -141,14 +141,8 @@ pub struct Body<'tcx> {
141
141
/// This is used for the "rust-call" ABI.
142
142
pub spread_arg : Option < Local > ,
143
143
144
- /// Names and capture modes of all the closure upvars, assuming
145
- /// the first argument is either the closure or a reference to it.
146
- //
147
- // NOTE(eddyb) This is *strictly* a temporary hack for codegen
148
- // debuginfo generation, and will be removed at some point.
149
- // Do **NOT** use it for anything else; upvar information should not be
150
- // in the MIR, so please rely on local crate HIR or other side-channels.
151
- pub __upvar_debuginfo_codegen_only_do_not_use : Vec < UpvarDebuginfo > ,
144
+ /// Debug information pertaining to user variables, including captures.
145
+ pub var_debug_info : Vec < VarDebugInfo < ' tcx > > ,
152
146
153
147
/// Mark this MIR of a const context other than const functions as having converted a `&&` or
154
148
/// `||` expression into `&` or `|` respectively. This is problematic because if we ever stop
@@ -170,11 +164,10 @@ impl<'tcx> Body<'tcx> {
170
164
basic_blocks : IndexVec < BasicBlock , BasicBlockData < ' tcx > > ,
171
165
source_scopes : IndexVec < SourceScope , SourceScopeData > ,
172
166
source_scope_local_data : ClearCrossCrate < IndexVec < SourceScope , SourceScopeLocalData > > ,
173
- yield_ty : Option < Ty < ' tcx > > ,
174
167
local_decls : LocalDecls < ' tcx > ,
175
168
user_type_annotations : CanonicalUserTypeAnnotations < ' tcx > ,
176
169
arg_count : usize ,
177
- __upvar_debuginfo_codegen_only_do_not_use : Vec < UpvarDebuginfo > ,
170
+ var_debug_info : Vec < VarDebugInfo < ' tcx > > ,
178
171
span : Span ,
179
172
control_flow_destroyed : Vec < ( Span , String ) > ,
180
173
) -> Self {
@@ -191,14 +184,14 @@ impl<'tcx> Body<'tcx> {
191
184
basic_blocks,
192
185
source_scopes,
193
186
source_scope_local_data,
194
- yield_ty,
187
+ yield_ty : None ,
195
188
generator_drop : None ,
196
189
generator_layout : None ,
197
190
local_decls,
198
191
user_type_annotations,
199
192
arg_count,
200
- __upvar_debuginfo_codegen_only_do_not_use,
201
193
spread_arg : None ,
194
+ var_debug_info,
202
195
span,
203
196
cache : cache:: Cache :: new ( ) ,
204
197
control_flow_destroyed,
@@ -280,7 +273,7 @@ impl<'tcx> Body<'tcx> {
280
273
LocalKind :: ReturnPointer
281
274
} else if index < self . arg_count + 1 {
282
275
LocalKind :: Arg
283
- } else if self . local_decls [ local] . name . is_some ( ) {
276
+ } else if self . local_decls [ local] . is_user_variable ( ) {
284
277
LocalKind :: Var
285
278
} else {
286
279
LocalKind :: Temp
@@ -728,12 +721,6 @@ pub struct LocalDecl<'tcx> {
728
721
// FIXME(matthewjasper) Don't store in this in `Body`
729
722
pub user_ty : UserTypeProjections ,
730
723
731
- /// The name of the local, used in debuginfo and pretty-printing.
732
- ///
733
- /// Note that function arguments can also have this set to `Some(_)`
734
- /// to generate better debuginfo.
735
- pub name : Option < Name > ,
736
-
737
724
/// The *syntactic* (i.e., not visibility) source scope the local is defined
738
725
/// in. If the local was defined in a let-statement, this
739
726
/// is *within* the let-statement, rather than outside
@@ -785,9 +772,9 @@ pub struct LocalDecl<'tcx> {
785
772
/// `drop(x)`, we want it to refer to `x: u32`.
786
773
///
787
774
/// To allow both uses to work, we need to have more than a single scope
788
- /// for a local. We have the `source_info.scope` represent the
789
- /// "syntactic" lint scope (with a variable being under its let
790
- /// block) while the `visibility_scope ` represents the "local variable"
775
+ /// for a local. We have the `source_info.scope` represent the "syntactic"
776
+ /// lint scope (with a variable being under its let block) while the
777
+ /// `var_debug_info.source_info.scope ` represents the "local variable"
791
778
/// scope (where the "rest" of a block is under all prior let-statements).
792
779
///
793
780
/// The end result looks like this:
@@ -806,18 +793,14 @@ pub struct LocalDecl<'tcx> {
806
793
/// │ │
807
794
/// │ │ │{ let y: u32 }
808
795
/// │ │ │
809
- /// │ │ │← y.visibility_scope
796
+ /// │ │ │← y.var_debug_info.source_info.scope
810
797
/// │ │ │← `y + 2`
811
798
/// │
812
799
/// │ │{ let x: u32 }
813
- /// │ │← x.visibility_scope
800
+ /// │ │← x.var_debug_info.source_info.scope
814
801
/// │ │← `drop(x)` // This accesses `x: u32`.
815
802
/// ```
816
803
pub source_info : SourceInfo ,
817
-
818
- /// Source scope within which the local is visible (for debuginfo)
819
- /// (see `source_info` for more details).
820
- pub visibility_scope : SourceScope ,
821
804
}
822
805
823
806
/// Extra information about a local that's used for diagnostics.
@@ -955,9 +938,7 @@ impl<'tcx> LocalDecl<'tcx> {
955
938
mutability,
956
939
ty,
957
940
user_ty : UserTypeProjections :: none ( ) ,
958
- name : None ,
959
941
source_info : SourceInfo { span, scope : OUTERMOST_SOURCE_SCOPE } ,
960
- visibility_scope : OUTERMOST_SOURCE_SCOPE ,
961
942
internal,
962
943
local_info : LocalInfo :: Other ,
963
944
is_block_tail : None ,
@@ -974,22 +955,27 @@ impl<'tcx> LocalDecl<'tcx> {
974
955
ty : return_ty,
975
956
user_ty : UserTypeProjections :: none ( ) ,
976
957
source_info : SourceInfo { span, scope : OUTERMOST_SOURCE_SCOPE } ,
977
- visibility_scope : OUTERMOST_SOURCE_SCOPE ,
978
958
internal : false ,
979
959
is_block_tail : None ,
980
- name : None , // FIXME maybe we do want some name here?
981
960
local_info : LocalInfo :: Other ,
982
961
}
983
962
}
984
963
}
985
964
986
- /// A closure capture, with its name and mode .
987
- #[ derive( Clone , Debug , RustcEncodable , RustcDecodable , HashStable ) ]
988
- pub struct UpvarDebuginfo {
989
- pub debug_name : Name ,
965
+ /// Debug information pertaining to a user variable .
966
+ #[ derive( Clone , Debug , RustcEncodable , RustcDecodable , HashStable , TypeFoldable ) ]
967
+ pub struct VarDebugInfo < ' tcx > {
968
+ pub name : Name ,
990
969
991
- /// If true, the capture is behind a reference.
992
- pub by_ref : bool ,
970
+ /// Source info of the user variable, including the scope
971
+ /// within which the variable is visible (to debuginfo)
972
+ /// (see `LocalDecl`'s `source_info` field for more details).
973
+ pub source_info : SourceInfo ,
974
+
975
+ /// Where the data for this user variable is to be found.
976
+ /// NOTE(eddyb) There's an unenforced invariant that this `Place` is
977
+ /// based on a `Local`, not a `Static`, and contains no indexing.
978
+ pub place : Place < ' tcx > ,
993
979
}
994
980
995
981
///////////////////////////////////////////////////////////////////////////
@@ -2758,16 +2744,6 @@ pub struct GeneratorLayout<'tcx> {
2758
2744
/// have conflicts with each other are allowed to overlap in the computed
2759
2745
/// layout.
2760
2746
pub storage_conflicts : BitMatrix < GeneratorSavedLocal , GeneratorSavedLocal > ,
2761
-
2762
- /// The names and scopes of all the stored generator locals.
2763
- ///
2764
- /// N.B., this is *strictly* a temporary hack for codegen
2765
- /// debuginfo generation, and will be removed at some point.
2766
- /// Do **NOT** use it for anything else, local information should not be
2767
- /// in the MIR, please rely on local crate HIR or other side-channels.
2768
- //
2769
- // FIXME(tmandry): see above.
2770
- pub __local_debuginfo_codegen_only_do_not_use : IndexVec < GeneratorSavedLocal , LocalDecl < ' tcx > > ,
2771
2747
}
2772
2748
2773
2749
#[ derive( Clone , Debug , RustcEncodable , RustcDecodable , HashStable ) ]
@@ -2946,7 +2922,6 @@ CloneTypeFoldableAndLiftImpls! {
2946
2922
MirPhase ,
2947
2923
Mutability ,
2948
2924
SourceInfo ,
2949
- UpvarDebuginfo ,
2950
2925
FakeReadCause ,
2951
2926
RetagKind ,
2952
2927
SourceScope ,
0 commit comments