@@ -8,7 +8,7 @@ use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
8
8
use rustc_session:: config:: DebugInfo ;
9
9
use rustc_span:: symbol:: { kw, Symbol } ;
10
10
use rustc_span:: { BytePos , Span } ;
11
- use rustc_target:: abi:: { Abi , FieldIdx , Size , VariantIdx } ;
11
+ use rustc_target:: abi:: { Abi , FieldIdx , FieldsShape , Size , VariantIdx } ;
12
12
13
13
use super :: operand:: { OperandRef , OperandValue } ;
14
14
use super :: place:: PlaceRef ;
@@ -83,6 +83,7 @@ trait DebugInfoOffsetLocation<'tcx, Bx> {
83
83
fn deref ( & self , bx : & mut Bx ) -> Self ;
84
84
fn layout ( & self ) -> TyAndLayout < ' tcx > ;
85
85
fn project_field ( & self , bx : & mut Bx , field : FieldIdx ) -> Self ;
86
+ fn project_constant_index ( & self , bx : & mut Bx , offset : u64 ) -> Self ;
86
87
fn downcast ( & self , bx : & mut Bx , variant : VariantIdx ) -> Self ;
87
88
}
88
89
@@ -101,6 +102,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> DebugInfoOffsetLocation<'tcx, Bx>
101
102
PlaceRef :: project_field ( * self , bx, field. index ( ) )
102
103
}
103
104
105
+ fn project_constant_index ( & self , bx : & mut Bx , offset : u64 ) -> Self {
106
+ let lloffset = bx. cx ( ) . const_usize ( offset) ;
107
+ self . project_index ( bx, lloffset)
108
+ }
109
+
104
110
fn downcast ( & self , bx : & mut Bx , variant : VariantIdx ) -> Self {
105
111
self . project_downcast ( bx, variant)
106
112
}
@@ -123,6 +129,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> DebugInfoOffsetLocation<'tcx, Bx>
123
129
self . field ( bx. cx ( ) , field. index ( ) )
124
130
}
125
131
132
+ fn project_constant_index ( & self , bx : & mut Bx , index : u64 ) -> Self {
133
+ self . field ( bx. cx ( ) , index as usize )
134
+ }
135
+
126
136
fn downcast ( & self , bx : & mut Bx , variant : VariantIdx ) -> Self {
127
137
self . for_variant ( bx. cx ( ) , variant)
128
138
}
@@ -168,6 +178,18 @@ fn calculate_debuginfo_offset<
168
178
mir:: ProjectionElem :: Downcast ( _, variant) => {
169
179
place = place. downcast ( bx, variant) ;
170
180
}
181
+ mir:: ProjectionElem :: ConstantIndex {
182
+ offset : index,
183
+ min_length : _,
184
+ from_end : false ,
185
+ } => {
186
+ let offset = indirect_offsets. last_mut ( ) . unwrap_or ( & mut direct_offset) ;
187
+ let FieldsShape :: Array { stride, count : _ } = place. layout ( ) . fields else {
188
+ span_bug ! ( var. source_info. span, "ConstantIndex on non-array type {:?}" , place. layout( ) )
189
+ } ;
190
+ * offset += stride * index;
191
+ place = place. project_constant_index ( bx, index) ;
192
+ }
171
193
_ => {
172
194
// Sanity check for `can_use_in_debuginfo`.
173
195
debug_assert ! ( !elem. can_use_in_debuginfo( ) ) ;
0 commit comments