diff options
| author | Smitty <me@smitop.com> | 2021-06-19 10:48:44 -0400 |
|---|---|---|
| committer | Smitty <me@smitop.com> | 2021-06-29 19:08:30 -0400 |
| commit | a59fafeb13aa39991c3b8c704c66289fd8fd9253 (patch) | |
| tree | 2d5f02f0a41a1edcfbc8c9e0d640a893f753ba72 | |
| parent | 3e735a52febb098e1b541e89a6653adbcb134760 (diff) | |
| download | rust-a59fafeb13aa39991c3b8c704c66289fd8fd9253.tar.gz rust-a59fafeb13aa39991c3b8c704c66289fd8fd9253.zip | |
Test memory exhaustion in const evaluation
| -rw-r--r-- | src/test/ui/consts/large_const_alloc.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/consts/large_const_alloc.stderr | 8 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/test/ui/consts/large_const_alloc.rs b/src/test/ui/consts/large_const_alloc.rs index 2771af92d30..54abaab2247 100644 --- a/src/test/ui/consts/large_const_alloc.rs +++ b/src/test/ui/consts/large_const_alloc.rs @@ -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; } diff --git a/src/test/ui/consts/large_const_alloc.stderr b/src/test/ui/consts/large_const_alloc.stderr index 54d56a42061..25d660f1217 100644 --- a/src/test/ui/consts/large_const_alloc.stderr +++ b/src/test/ui/consts/large_const_alloc.stderr @@ -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`. |
