@@ -425,8 +425,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
425425 }
426426
427427 fn eval_constant ( & mut self , c : & Constant < ' tcx > , source_info : SourceInfo ) -> Option < OpTy < ' tcx > > {
428- self . ecx . tcx . span = c. span ;
429-
430428 // FIXME we need to revisit this for #67176
431429 if c. needs_subst ( ) {
432430 return None ;
@@ -435,6 +433,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
435433 match self . ecx . eval_const_to_op ( c. literal , None ) {
436434 Ok ( op) => Some ( op) ,
437435 Err ( error) => {
436+ // Make sure errors point at the constant.
437+ self . ecx . set_span ( c. span ) ;
438438 let err = error_to_const_error ( & self . ecx , error) ;
439439 if let Some ( lint_root) = self . lint_root ( source_info) {
440440 let lint_only = match c. literal . val {
@@ -820,6 +820,7 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
820820 fn visit_statement ( & mut self , statement : & mut Statement < ' tcx > , location : Location ) {
821821 trace ! ( "visit_statement: {:?}" , statement) ;
822822 let source_info = statement. source_info ;
823+ self . ecx . set_span ( source_info. span ) ;
823824 self . source_info = Some ( source_info) ;
824825 if let StatementKind :: Assign ( box ( place, ref mut rval) ) = statement. kind {
825826 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> {
870871
871872 fn visit_terminator ( & mut self , terminator : & mut Terminator < ' tcx > , location : Location ) {
872873 let source_info = terminator. source_info ;
874+ self . ecx . set_span ( source_info. span ) ;
873875 self . source_info = Some ( source_info) ;
874876 self . super_terminator ( terminator, location) ;
875877 match & mut terminator. kind {
0 commit comments