Support allocation failures when interperting MIR
Note that this breaks Miri. Closes #79601
This commit is contained in:
parent
6e0b554619
commit
524e575bb4
19 changed files with 103 additions and 39 deletions
13
src/test/ui/consts/large_const_alloc.rs
Normal file
13
src/test/ui/consts/large_const_alloc.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// only-64bit
|
||||
// on 32bit and 16bit platforms it is plausible that the maximum allocation size will succeed
|
||||
|
||||
const FOO: () = {
|
||||
// 128 TiB, unlikely anyone has that much RAM
|
||||
let x = [0_u8; (1 << 47) - 1];
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
//~| WARNING this was previously accepted by the compiler but is being phased out
|
||||
};
|
||||
|
||||
fn main() {
|
||||
let _ = FOO;
|
||||
}
|
||||
18
src/test/ui/consts/large_const_alloc.stderr
Normal file
18
src/test/ui/consts/large_const_alloc.stderr
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
error: any use of this value will cause an error
|
||||
--> $DIR/large_const_alloc.rs:6:13
|
||||
|
|
||||
LL | / const FOO: () = {
|
||||
LL | | // 128 TiB, unlikely anyone has that much RAM
|
||||
LL | | let x = [0_u8; (1 << 47) - 1];
|
||||
| | ^^^^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | };
|
||||
| |__-
|
||||
|
|
||||
= note: `#[deny(const_err)]` on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue