I tried this code:
const FOO: () = {
let x = [0_u8; 1000*1000*1000];
};
I expected to see this happen: An error about the constant evaluation using more memory than the compiler having available
Instead, this happened: The compiler triggered an abort
Meta
rustc --version --verbose:
Backtrace
- somewhere in the
Vec machinery...
|
bytes: vec![0; size.bytes_usize()], |
|
let alloc = Allocation::uninit(size, align); |
I think we'll need to stop using Vec and move to manually using AllocRef::alloc (and maybe Box<[u8]>? in order to allow bubbling up allocation errors during const eval back to the user via error messages.
cc @rust-lang/wg-const-eval
related: #23600
I tried this code:
I expected to see this happen: An error about the constant evaluation using more memory than the compiler having available
Instead, this happened: The compiler triggered an
abortMeta
rustc --version --verbose:Backtrace
Vecmachinery...rust/compiler/rustc_middle/src/mir/interpret/allocation.rs
Line 110 in 0fa9d31
rust/compiler/rustc_mir/src/interpret/memory.rs
Line 197 in 0fa9d31
I think we'll need to stop using
Vecand move to manually usingAllocRef::alloc(and maybeBox<[u8]>? in order to allow bubbling up allocation errors during const eval back to the user via error messages.cc @rust-lang/wg-const-eval
related: #23600