Always error on SizeOverflow
during mir evaluation
This commit is contained in:
parent
1df512fcae
commit
83b5eb9615
@ -141,7 +141,6 @@ impl<'tcx> ConstEvalErr<'tcx> {
|
||||
err_inval!(Layout(LayoutError::Unknown(_))) |
|
||||
err_inval!(TooGeneric) =>
|
||||
return Err(ErrorHandled::TooGeneric),
|
||||
err_inval!(Layout(LayoutError::SizeOverflow(_))) |
|
||||
err_inval!(TypeckError) =>
|
||||
return Err(ErrorHandled::Reported),
|
||||
_ => {},
|
||||
|
4
src/test/ui/consts/issue-55878.rs
Normal file
4
src/test/ui/consts/issue-55878.rs
Normal file
@ -0,0 +1,4 @@
|
||||
// error-pattern: reaching this expression at runtime will panic or abort
|
||||
fn main() {
|
||||
println!("Size: {}", std::mem::size_of::<[u8; std::u64::MAX as usize]>());
|
||||
}
|
15
src/test/ui/consts/issue-55878.stderr
Normal file
15
src/test/ui/consts/issue-55878.stderr
Normal file
@ -0,0 +1,15 @@
|
||||
error: reaching this expression at runtime will panic or abort
|
||||
--> $SRC_DIR/libcore/mem/mod.rs:LL:COL
|
||||
|
|
||||
LL | intrinsics::size_of::<T>()
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ rustc layout computation failed: SizeOverflow([u8; 18446744073709551615])
|
||||
|
|
||||
::: $DIR/issue-55878.rs:3:26
|
||||
|
|
||||
LL | println!("Size: {}", std::mem::size_of::<[u8; std::u64::MAX as usize]>());
|
||||
| ---------------------------------------------------
|
||||
|
|
||||
= note: `#[deny(const_err)]` on by default
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -17,6 +17,8 @@ impl TooBigArray {
|
||||
}
|
||||
|
||||
static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new();
|
||||
//~^ ERROR could not evaluate static initializer
|
||||
static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE];
|
||||
//~^ ERROR could not evaluate static initializer
|
||||
|
||||
fn main() { }
|
||||
|
@ -1,4 +1,15 @@
|
||||
error: the type `[u8; 2305843009213693951]` is too big for the current architecture
|
||||
error[E0080]: could not evaluate static initializer
|
||||
--> $DIR/issue-56762.rs:19:1
|
||||
|
|
||||
LL | static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ rustc layout computation failed: SizeOverflow([u8; 2305843009213693951])
|
||||
|
||||
error: aborting due to previous error
|
||||
error[E0080]: could not evaluate static initializer
|
||||
--> $DIR/issue-56762.rs:21:1
|
||||
|
|
||||
LL | static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ rustc layout computation failed: SizeOverflow([u8; 2305843009213693951])
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
Loading…
Reference in New Issue
Block a user