@@ -16,7 +16,7 @@ use rustc_middle::ty::layout::{self, TyAndLayout};
16
16
use rustc_middle:: ty:: {
17
17
self , query:: TyCtxtAt , subst:: SubstsRef , ParamEnv , Ty , TyCtxt , TypeFoldable ,
18
18
} ;
19
- use rustc_span:: { source_map :: DUMMY_SP , Pos , Span } ;
19
+ use rustc_span:: { Pos , Span } ;
20
20
use rustc_target:: abi:: { Align , HasDataLayout , LayoutOf , Size , TargetDataLayout } ;
21
21
22
22
use super :: {
@@ -191,6 +191,10 @@ impl<'mir, 'tcx, Tag, Extra> Frame<'mir, 'tcx, Tag, Extra> {
191
191
pub fn current_source_info ( & self ) -> Option < & mir:: SourceInfo > {
192
192
self . loc . map ( |loc| self . body . source_info ( loc) )
193
193
}
194
+
195
+ pub fn current_span ( & self ) -> Span {
196
+ self . current_source_info ( ) . map ( |si| si. span ) . unwrap_or ( self . body . span )
197
+ }
194
198
}
195
199
196
200
impl < ' tcx > fmt:: Display for FrameInfo < ' tcx > {
@@ -324,11 +328,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
324
328
325
329
#[ inline( always) ]
326
330
pub fn cur_span ( & self ) -> Span {
327
- self . stack ( )
328
- . last ( )
329
- . and_then ( |f| f. current_source_info ( ) )
330
- . map ( |si| si. span )
331
- . unwrap_or ( self . tcx . span )
331
+ self . stack ( ) . last ( ) . map ( |f| f. current_span ( ) ) . unwrap_or ( self . tcx . span )
332
332
}
333
333
334
334
#[ inline( always) ]
@@ -921,14 +921,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
921
921
pub fn generate_stacktrace ( & self ) -> Vec < FrameInfo < ' tcx > > {
922
922
let mut frames = Vec :: new ( ) ;
923
923
for frame in self . stack ( ) . iter ( ) . rev ( ) {
924
- let source_info = frame. current_source_info ( ) ;
925
- let lint_root = source_info. and_then ( |source_info| {
924
+ let lint_root = frame. current_source_info ( ) . and_then ( |source_info| {
926
925
match & frame. body . source_scopes [ source_info. scope ] . local_data {
927
926
mir:: ClearCrossCrate :: Set ( data) => Some ( data. lint_root ) ,
928
927
mir:: ClearCrossCrate :: Clear => None ,
929
928
}
930
929
} ) ;
931
- let span = source_info . map_or ( DUMMY_SP , |source_info| source_info . span ) ;
930
+ let span = frame . current_span ( ) ;
932
931
933
932
frames. push ( FrameInfo { span, instance : frame. instance , lint_root } ) ;
934
933
}
0 commit comments