@@ -53,9 +53,8 @@ pub struct ConstEvalErr<'tcx> {
5353
5454#[ derive( Debug ) ]
5555pub struct FrameInfo < ' tcx > {
56- /// This span is in the caller.
57- pub call_site : Span ,
5856 pub instance : ty:: Instance < ' tcx > ,
57+ pub span : Span ,
5958 pub lint_root : Option < hir:: HirId > ,
6059}
6160
@@ -65,12 +64,12 @@ impl<'tcx> fmt::Display for FrameInfo<'tcx> {
6564 if tcx. def_key ( self . instance . def_id ( ) ) . disambiguated_data . data
6665 == DefPathData :: ClosureExpr
6766 {
68- write ! ( f, "inside call to closure" ) ?;
67+ write ! ( f, "inside closure" ) ?;
6968 } else {
70- write ! ( f, "inside call to `{}`" , self . instance) ?;
69+ write ! ( f, "inside `{}`" , self . instance) ?;
7170 }
72- if !self . call_site . is_dummy ( ) {
73- let lo = tcx. sess . source_map ( ) . lookup_char_pos ( self . call_site . lo ( ) ) ;
71+ if !self . span . is_dummy ( ) {
72+ let lo = tcx. sess . source_map ( ) . lookup_char_pos ( self . span . lo ( ) ) ;
7473 write ! ( f, " at {}:{}:{}" , lo. file. name, lo. line, lo. col. to_usize( ) + 1 ) ?;
7574 }
7675 Ok ( ( ) )
@@ -169,13 +168,9 @@ impl<'tcx> ConstEvalErr<'tcx> {
169168 err. span_label ( self . span , span_msg) ;
170169 }
171170 // Add spans for the stacktrace.
172- // Skip the last, which is just the environment of the constant. The stacktrace
173- // is sometimes empty because we create "fake" eval contexts in CTFE to do work
174- // on constant values.
175- if !self . stacktrace . is_empty ( ) {
176- for frame_info in & self . stacktrace [ ..self . stacktrace . len ( ) - 1 ] {
177- err. span_label ( frame_info. call_site , frame_info. to_string ( ) ) ;
178- }
171+ // Skip the first, which is the place of the error.
172+ for frame_info in self . stacktrace . iter ( ) . skip ( 1 ) {
173+ err. span_label ( frame_info. span , frame_info. to_string ( ) ) ;
179174 }
180175 // Let the caller finish the job.
181176 emit ( err)
0 commit comments