@@ -425,8 +425,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
425
425
}
426
426
427
427
fn eval_constant ( & mut self , c : & Constant < ' tcx > , source_info : SourceInfo ) -> Option < OpTy < ' tcx > > {
428
- self . ecx . tcx . span = c. span ;
429
-
430
428
// FIXME we need to revisit this for #67176
431
429
if c. needs_subst ( ) {
432
430
return None ;
@@ -435,6 +433,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
435
433
match self . ecx . eval_const_to_op ( c. literal , None ) {
436
434
Ok ( op) => Some ( op) ,
437
435
Err ( error) => {
436
+ // Make sure errors point at the constant.
437
+ self . ecx . set_span ( c. span ) ;
438
438
let err = error_to_const_error ( & self . ecx , error) ;
439
439
if let Some ( lint_root) = self . lint_root ( source_info) {
440
440
let lint_only = match c. literal . val {
@@ -820,6 +820,7 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
820
820
fn visit_statement ( & mut self , statement : & mut Statement < ' tcx > , location : Location ) {
821
821
trace ! ( "visit_statement: {:?}" , statement) ;
822
822
let source_info = statement. source_info ;
823
+ self . ecx . set_span ( source_info. span ) ;
823
824
self . source_info = Some ( source_info) ;
824
825
if let StatementKind :: Assign ( box ( place, ref mut rval) ) = statement. kind {
825
826
let place_ty: Ty < ' tcx > = place. ty ( & self . local_decls , self . tcx ) . ty ;
@@ -870,6 +871,7 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
870
871
871
872
fn visit_terminator ( & mut self , terminator : & mut Terminator < ' tcx > , location : Location ) {
872
873
let source_info = terminator. source_info ;
874
+ self . ecx . set_span ( source_info. span ) ;
873
875
self . source_info = Some ( source_info) ;
874
876
self . super_terminator ( terminator, location) ;
875
877
match & mut terminator. kind {
0 commit comments