Test memory exhaustion in const evaluation

This commit is contained in:
Smitty 2021-06-19 10:48:44 -04:00
parent 3e735a52fe
commit a59fafeb13
2 changed files with 13 additions and 1 deletions

View File

@ -7,6 +7,12 @@ const FOO: () = {
//~^ ERROR evaluation of constant value failed
};
static FOO2: () = {
let x = [0_u8; (1 << 47) - 1];
//~^ ERROR could not evaluate static initializer
};
fn main() {
let _ = FOO;
let _ = FOO2;
}

View File

@ -4,6 +4,12 @@ error[E0080]: evaluation of constant value failed
LL | let x = [0_u8; (1 << 47) - 1];
| ^^^^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler
error: aborting due to previous error
error[E0080]: could not evaluate static initializer
--> $DIR/large_const_alloc.rs:11:13
|
LL | let x = [0_u8; (1 << 47) - 1];
| ^^^^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0080`.