@@ -23,7 +23,7 @@ use rustc::hir::{self, def_id::DefId};
2323use rustc:: mir;
2424
2525use syntax:: attr;
26-
26+ use syntax :: source_map :: DUMMY_SP ;
2727
2828pub use rustc_mir:: interpret:: * ;
2929pub use rustc_mir:: interpret:: { self , AllocMap , PlaceTy } ; // resolve ambiguity
@@ -113,7 +113,7 @@ pub fn create_ecx<'a, 'mir: 'a, 'tcx: 'mir>(
113113 // Push our stack frame
114114 ecx. push_stack_frame (
115115 start_instance,
116- start_mir . span ,
116+ DUMMY_SP , // there is no call site, we want no span
117117 start_mir,
118118 Some ( ret_ptr. into ( ) ) ,
119119 StackPopCleanup :: None { cleanup : true } ,
@@ -146,7 +146,7 @@ pub fn create_ecx<'a, 'mir: 'a, 'tcx: 'mir>(
146146 let ret_place = MPlaceTy :: dangling ( ecx. layout_of ( tcx. mk_unit ( ) ) ?, & ecx) . into ( ) ;
147147 ecx. push_stack_frame (
148148 main_instance,
149- main_mir . span ,
149+ DUMMY_SP , // there is no call site, we want no span
150150 main_mir,
151151 Some ( ret_place) ,
152152 StackPopCleanup :: None { cleanup : true } ,
@@ -185,7 +185,7 @@ pub fn eval_main<'a, 'tcx: 'a>(
185185 match res {
186186 Ok ( ( ) ) => {
187187 let leaks = ecx. memory ( ) . leak_report ( ) ;
188- // Disable the leak test on some platforms where we likely do not
188+ // Disable the leak test on some platforms where we do not
189189 // correctly implement TLS destructors.
190190 let target_os = ecx. tcx . tcx . sess . target . target . target_os . to_lowercase ( ) ;
191191 let ignore_leaks = target_os == "windows" || target_os == "macos" ;
@@ -208,8 +208,16 @@ pub fn eval_main<'a, 'tcx: 'a>(
208208 let mut err = struct_error ( ecx. tcx . tcx . at ( span) , msg. as_str ( ) ) ;
209209 let frames = ecx. generate_stacktrace ( None ) ;
210210 err. span_label ( span, e) ;
211- for FrameInfo { span, location, .. } in frames {
212- err. span_note ( span, & format ! ( "inside call to `{}`" , location) ) ;
211+ // we iterate with indices because we need to look at the next frame (the caller)
212+ for idx in 0 ..frames. len ( ) {
213+ let frame_info = & frames[ idx] ;
214+ let call_site_is_local = frames. get ( idx+1 ) . map_or ( false ,
215+ |caller_info| caller_info. instance . def_id ( ) . is_local ( ) ) ;
216+ if call_site_is_local {
217+ err. span_note ( frame_info. call_site , & frame_info. to_string ( ) ) ;
218+ } else {
219+ err. note ( & frame_info. to_string ( ) ) ;
220+ }
213221 }
214222 err. emit ( ) ;
215223 } else {
0 commit comments