Skip to content

Commit dc1c6c3

Browse files
committed
Make memory exhaustion a hard error
1 parent b40f3c1 commit dc1c6c3

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

compiler/rustc_middle/src/mir/interpret/error.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,8 @@ impl InterpError<'_> {
530530
use InterpError::*;
531531
match *self {
532532
MachineStop(ref err) => err.is_hard_err(),
533-
InterpError::UndefinedBehavior(_) => true,
533+
UndefinedBehavior(_) => true,
534+
ResourceExhaustion(ResourceExhaustionInfo::MemoryExhausted) => true,
534535
_ => false,
535536
}
536537
}

src/test/ui/consts/large_const_alloc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
const FOO: () = {
55
// 128 TiB, unlikely anyone has that much RAM
66
let x = [0_u8; (1 << 47) - 1];
7-
//~^ ERROR any use of this value will cause an error
8-
//~| WARNING this was previously accepted by the compiler but is being phased out
7+
//~^ ERROR evaluation of constant value failed
98
};
109

1110
fn main() {
Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
1-
error: any use of this value will cause an error
1+
error[E0080]: evaluation of constant value failed
22
--> $DIR/large_const_alloc.rs:6:13
33
|
4-
LL | / const FOO: () = {
5-
LL | | // 128 TiB, unlikely anyone has that much RAM
6-
LL | | let x = [0_u8; (1 << 47) - 1];
7-
| | ^^^^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler
8-
LL | |
9-
LL | |
10-
LL | | };
11-
| |__-
12-
|
13-
= note: `#[deny(const_err)]` on by default
14-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
15-
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
4+
LL | let x = [0_u8; (1 << 47) - 1];
5+
| ^^^^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler
166

177
error: aborting due to previous error
188

9+
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)