Skip to content

Commit a59fafe

Browse files
committed
Test memory exhaustion in const evaluation
1 parent 3e735a5 commit a59fafe

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/test/ui/consts/large_const_alloc.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ const FOO: () = {
77
//~^ ERROR evaluation of constant value failed
88
};
99

10+
static FOO2: () = {
11+
let x = [0_u8; (1 << 47) - 1];
12+
//~^ ERROR could not evaluate static initializer
13+
};
14+
1015
fn main() {
1116
let _ = FOO;
17+
let _ = FOO2;
1218
}

src/test/ui/consts/large_const_alloc.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ error[E0080]: evaluation of constant value failed
44
LL | let x = [0_u8; (1 << 47) - 1];
55
| ^^^^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler
66

7-
error: aborting due to previous error
7+
error[E0080]: could not evaluate static initializer
8+
--> $DIR/large_const_alloc.rs:11:13
9+
|
10+
LL | let x = [0_u8; (1 << 47) - 1];
11+
| ^^^^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler
12+
13+
error: aborting due to 2 previous errors
814

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

0 commit comments

Comments
 (0)