@@ -23,7 +23,7 @@ use rustc::hir::{self, def_id::DefId};
23
23
use rustc:: mir;
24
24
25
25
use syntax:: attr;
26
-
26
+ use syntax :: source_map :: DUMMY_SP ;
27
27
28
28
pub use rustc_mir:: interpret:: * ;
29
29
pub use rustc_mir:: interpret:: { self , AllocMap , PlaceTy } ; // resolve ambiguity
@@ -113,7 +113,7 @@ pub fn create_ecx<'a, 'mir: 'a, 'tcx: 'mir>(
113
113
// Push our stack frame
114
114
ecx. push_stack_frame (
115
115
start_instance,
116
- start_mir . span ,
116
+ DUMMY_SP , // there is no call site, we want no span
117
117
start_mir,
118
118
Some ( ret_ptr. into ( ) ) ,
119
119
StackPopCleanup :: None { cleanup : true } ,
@@ -146,7 +146,7 @@ pub fn create_ecx<'a, 'mir: 'a, 'tcx: 'mir>(
146
146
let ret_place = MPlaceTy :: dangling ( ecx. layout_of ( tcx. mk_unit ( ) ) ?, & ecx) . into ( ) ;
147
147
ecx. push_stack_frame (
148
148
main_instance,
149
- main_mir . span ,
149
+ DUMMY_SP , // there is no call site, we want no span
150
150
main_mir,
151
151
Some ( ret_place) ,
152
152
StackPopCleanup :: None { cleanup : true } ,
@@ -185,7 +185,7 @@ pub fn eval_main<'a, 'tcx: 'a>(
185
185
match res {
186
186
Ok ( ( ) ) => {
187
187
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
189
189
// correctly implement TLS destructors.
190
190
let target_os = ecx. tcx . tcx . sess . target . target . target_os . to_lowercase ( ) ;
191
191
let ignore_leaks = target_os == "windows" || target_os == "macos" ;
@@ -208,8 +208,16 @@ pub fn eval_main<'a, 'tcx: 'a>(
208
208
let mut err = struct_error ( ecx. tcx . tcx . at ( span) , msg. as_str ( ) ) ;
209
209
let frames = ecx. generate_stacktrace ( None ) ;
210
210
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
+ }
213
221
}
214
222
err. emit ( ) ;
215
223
} else {
0 commit comments