@@ -31,9 +31,9 @@ use rustc_trait_selection::traits;
3131use crate :: const_eval:: ConstEvalErr ;
3232use crate :: interpret:: {
3333 self , compile_time_machine, AllocId , Allocation , ConstValue , CtfeValidationMode , Frame , ImmTy ,
34- Immediate , InterpCx , InterpResult , LocalState , LocalValue , MemPlace , Memory , MemoryKind , OpTy ,
35- Operand as InterpOperand , PlaceTy , Pointer , Scalar , ScalarMaybeUninit , StackPopCleanup ,
36- StackPopUnwind ,
34+ Immediate , InterpCx , InterpError , InterpResult , LocalState , LocalValue , MemPlace , Memory ,
35+ MemoryKind , OpTy , Operand as InterpOperand , PlaceTy , Pointer , ResourceExhaustionInfo , Scalar ,
36+ ScalarMaybeUninit , StackPopCleanup , StackPopUnwind ,
3737} ;
3838use crate :: transform:: MirPass ;
3939
@@ -478,19 +478,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
478478 Ok ( op) => Some ( op) ,
479479 Err ( error) => {
480480 let tcx = self . ecx . tcx . at ( c. span ) ;
481- if error. kind ( ) . is_volatile ( ) {
482- // Volatile errors can't be ignored since otherwise the amount of available
483- // memory influences the result of optimization and the build. The error
484- // doesn't need to be fatal since no code will actually be generated anyways.
485- self . ecx
486- . tcx
487- . tcx
488- . sess
489- . struct_err ( "memory exhausted during optimization" )
490- . help ( "try increasing the amount of memory available to the compiler" )
491- . emit ( ) ;
492- return None ;
493- }
494481 let err = ConstEvalErr :: new ( & self . ecx , error, Some ( c. span ) ) ;
495482 if let Some ( lint_root) = self . lint_root ( source_info) {
496483 let lint_only = match c. literal {
@@ -507,7 +494,19 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
507494 } ,
508495 ConstantKind :: Val ( _, ty) => ty. needs_subst ( ) ,
509496 } ;
510- if lint_only {
497+ // Memory errors can't be ignored since otherwise the amount of available
498+ // memory influences the result of optimization and the build. The error
499+ // doesn't need to be fatal since no code will actually be generated anyways.
500+ // FIXME(#86255): use err.error.is_hard_err(), but beware of backwards
501+ // compatibility and interactions with promoteds
502+ if lint_only
503+ && !matches ! (
504+ err. error,
505+ InterpError :: ResourceExhaustion (
506+ ResourceExhaustionInfo :: MemoryExhausted ,
507+ ) ,
508+ )
509+ {
511510 // Out of backwards compatibility we cannot report hard errors in unused
512511 // generic functions using associated constants of the generic parameters.
513512 err. report_as_lint ( tcx, "erroneous constant used" , lint_root, Some ( c. span ) ) ;
0 commit comments