@@ -16,7 +16,7 @@ use rustc_middle::ty::layout::{self, TyAndLayout};
1616use rustc_middle:: ty:: {
1717 self , query:: TyCtxtAt , subst:: SubstsRef , ParamEnv , Ty , TyCtxt , TypeFoldable ,
1818} ;
19- use rustc_span:: { source_map :: DUMMY_SP , Pos , Span } ;
19+ use rustc_span:: { Pos , Span } ;
2020use rustc_target:: abi:: { Align , HasDataLayout , LayoutOf , Size , TargetDataLayout } ;
2121
2222use super :: {
@@ -191,6 +191,10 @@ impl<'mir, 'tcx, Tag, Extra> Frame<'mir, 'tcx, Tag, Extra> {
191191 pub fn current_source_info ( & self ) -> Option < & mir:: SourceInfo > {
192192 self . loc . map ( |loc| self . body . source_info ( loc) )
193193 }
194+
195+ pub fn current_span ( & self ) -> Span {
196+ self . current_source_info ( ) . map ( |si| si. span ) . unwrap_or ( self . body . span )
197+ }
194198}
195199
196200impl < ' tcx > fmt:: Display for FrameInfo < ' tcx > {
@@ -324,11 +328,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
324328
325329 #[ inline( always) ]
326330 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 )
332332 }
333333
334334 #[ inline( always) ]
@@ -921,14 +921,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
921921 pub fn generate_stacktrace ( & self ) -> Vec < FrameInfo < ' tcx > > {
922922 let mut frames = Vec :: new ( ) ;
923923 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| {
926925 match & frame. body . source_scopes [ source_info. scope ] . local_data {
927926 mir:: ClearCrossCrate :: Set ( data) => Some ( data. lint_root ) ,
928927 mir:: ClearCrossCrate :: Clear => None ,
929928 }
930929 } ) ;
931- let span = source_info . map_or ( DUMMY_SP , |source_info| source_info . span ) ;
930+ let span = frame . current_span ( ) ;
932931
933932 frames. push ( FrameInfo { span, instance : frame. instance , lint_root } ) ;
934933 }
0 commit comments