@@ -279,6 +279,32 @@ impl<'mir, 'tcx, Prov: Provenance, Extra> Frame<'mir, 'tcx, Prov, Extra> {
279
279
}
280
280
} )
281
281
}
282
+
283
+ #[ must_use]
284
+ pub fn generate_stacktrace_from_stack ( stack : & [ Self ] ) -> Vec < FrameInfo < ' tcx > > {
285
+ let mut frames = Vec :: new ( ) ;
286
+ // This deliberately does *not* honor `requires_caller_location` since it is used for much
287
+ // more than just panics.
288
+ for frame in stack. iter ( ) . rev ( ) {
289
+ let span = match frame. loc {
290
+ Left ( loc) => {
291
+ // If the stacktrace passes through MIR-inlined source scopes, add them.
292
+ let mir:: SourceInfo { mut span, scope } = * frame. body . source_info ( loc) ;
293
+ let mut scope_data = & frame. body . source_scopes [ scope] ;
294
+ while let Some ( ( instance, call_span) ) = scope_data. inlined {
295
+ frames. push ( FrameInfo { span, instance } ) ;
296
+ span = call_span;
297
+ scope_data = & frame. body . source_scopes [ scope_data. parent_scope . unwrap ( ) ] ;
298
+ }
299
+ span
300
+ }
301
+ Right ( span) => span,
302
+ } ;
303
+ frames. push ( FrameInfo { span, instance : frame. instance } ) ;
304
+ }
305
+ trace ! ( "generate stacktrace: {:#?}" , frames) ;
306
+ frames
307
+ }
282
308
}
283
309
284
310
// FIXME: only used by miri, should be removed once translatable.
@@ -1166,37 +1192,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
1166
1192
PlacePrinter { ecx : self , place : * place. place ( ) }
1167
1193
}
1168
1194
1169
- #[ must_use]
1170
- pub fn generate_stacktrace_from_stack (
1171
- stack : & [ Frame < ' mir , ' tcx , M :: Provenance , M :: FrameExtra > ] ,
1172
- ) -> Vec < FrameInfo < ' tcx > > {
1173
- let mut frames = Vec :: new ( ) ;
1174
- // This deliberately does *not* honor `requires_caller_location` since it is used for much
1175
- // more than just panics.
1176
- for frame in stack. iter ( ) . rev ( ) {
1177
- let span = match frame. loc {
1178
- Left ( loc) => {
1179
- // If the stacktrace passes through MIR-inlined source scopes, add them.
1180
- let mir:: SourceInfo { mut span, scope } = * frame. body . source_info ( loc) ;
1181
- let mut scope_data = & frame. body . source_scopes [ scope] ;
1182
- while let Some ( ( instance, call_span) ) = scope_data. inlined {
1183
- frames. push ( FrameInfo { span, instance } ) ;
1184
- span = call_span;
1185
- scope_data = & frame. body . source_scopes [ scope_data. parent_scope . unwrap ( ) ] ;
1186
- }
1187
- span
1188
- }
1189
- Right ( span) => span,
1190
- } ;
1191
- frames. push ( FrameInfo { span, instance : frame. instance } ) ;
1192
- }
1193
- trace ! ( "generate stacktrace: {:#?}" , frames) ;
1194
- frames
1195
- }
1196
-
1197
1195
#[ must_use]
1198
1196
pub fn generate_stacktrace ( & self ) -> Vec < FrameInfo < ' tcx > > {
1199
- Self :: generate_stacktrace_from_stack ( self . stack ( ) )
1197
+ Frame :: generate_stacktrace_from_stack ( self . stack ( ) )
1200
1198
}
1201
1199
}
1202
1200
0 commit comments