@@ -31,9 +31,9 @@ use rustc_trait_selection::traits;
31
31
use crate :: const_eval:: ConstEvalErr ;
32
32
use crate :: interpret:: {
33
33
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 ,
37
37
} ;
38
38
use crate :: transform:: MirPass ;
39
39
@@ -478,19 +478,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
478
478
Ok ( op) => Some ( op) ,
479
479
Err ( error) => {
480
480
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
- }
494
481
let err = ConstEvalErr :: new ( & self . ecx , error, Some ( c. span ) ) ;
495
482
if let Some ( lint_root) = self . lint_root ( source_info) {
496
483
let lint_only = match c. literal {
@@ -507,7 +494,19 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
507
494
} ,
508
495
ConstantKind :: Val ( _, ty) => ty. needs_subst ( ) ,
509
496
} ;
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
+ {
511
510
// Out of backwards compatibility we cannot report hard errors in unused
512
511
// generic functions using associated constants of the generic parameters.
513
512
err. report_as_lint ( tcx, "erroneous constant used" , lint_root, Some ( c. span ) ) ;
0 commit comments