diff options
Diffstat (limited to 'tests/ui/consts/const-eval')
127 files changed, 1162 insertions, 1232 deletions
diff --git a/tests/ui/consts/const-eval/assign-to-static-within-other-static.rs b/tests/ui/consts/const-eval/assign-to-static-within-other-static.rs index 30e40bd8be1..7a7a2566940 100644 --- a/tests/ui/consts/const-eval/assign-to-static-within-other-static.rs +++ b/tests/ui/consts/const-eval/assign-to-static-within-other-static.rs @@ -6,7 +6,7 @@ use std::cell::UnsafeCell; static mut FOO: u32 = 42; static BOO: () = unsafe { FOO = 5; - //~^ ERROR could not evaluate static initializer [E0080] + //~^ ERROR modifying a static's initial value }; fn main() {} diff --git a/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr b/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr index 5300111a6b6..b19d0eaa116 100644 --- a/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr +++ b/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/assign-to-static-within-other-static.rs:8:5 | LL | FOO = 5; - | ^^^^^^^ modifying a static's initial value from another static's initializer + | ^^^^^^^ evaluation of static initializer failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/conditional_array_execution.rs b/tests/ui/consts/const-eval/conditional_array_execution.rs index 27d5383d6d4..1473efa7428 100644 --- a/tests/ui/consts/const-eval/conditional_array_execution.rs +++ b/tests/ui/consts/const-eval/conditional_array_execution.rs @@ -1,7 +1,7 @@ const X: u32 = 5; const Y: u32 = 6; const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; -//~^ ERROR constant +//~^ ERROR overflow fn main() { println!("{}", FOO); diff --git a/tests/ui/consts/const-eval/conditional_array_execution.stderr b/tests/ui/consts/const-eval/conditional_array_execution.stderr index 30034378079..65ae9a9fb8a 100644 --- a/tests/ui/consts/const-eval/conditional_array_execution.stderr +++ b/tests/ui/consts/const-eval/conditional_array_execution.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `5_u32 - 6_u32`, which would overflow --> $DIR/conditional_array_execution.rs:3:19 | LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; - | ^^^^^ attempt to compute `5_u32 - 6_u32`, which would overflow + | ^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/const-eval-overflow-2.rs b/tests/ui/consts/const-eval/const-eval-overflow-2.rs index bae8a7ce243..71ac655435b 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-2.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow-2.rs @@ -8,7 +8,7 @@ use std::{i8, i16, i32, i64, isize}; use std::{u8, u16, u32, u64, usize}; const NEG_128: i8 = -128; -const NEG_NEG_128: i8 = -NEG_128; //~ ERROR constant +const NEG_NEG_128: i8 = -NEG_128; //~ ERROR overflow fn main() { match -128i8 { diff --git a/tests/ui/consts/const-eval/const-eval-overflow-2.stderr b/tests/ui/consts/const-eval/const-eval-overflow-2.stderr index 5599ff931e8..90b94600aed 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-2.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-2.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to negate `i8::MIN`, which would overflow --> $DIR/const-eval-overflow-2.rs:11:25 | LL | const NEG_NEG_128: i8 = -NEG_128; - | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + | ^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/const-eval-overflow-3.rs b/tests/ui/consts/const-eval/const-eval-overflow-3.rs index bcc966dc962..bf7e791483a 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-3.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow-3.rs @@ -16,7 +16,7 @@ use std::fmt; const A_I8_I : [u32; (i8::MAX as usize) + 1] = [0; (i8::MAX + 1) as usize]; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflow fn main() { foo(&A_I8_I[..]); diff --git a/tests/ui/consts/const-eval/const-eval-overflow-3.stderr b/tests/ui/consts/const-eval/const-eval-overflow-3.stderr index 0437cd3adb4..5ad7d08bdb3 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-3.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-3.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i8::MAX + 1_i8`, which would overflow --> $DIR/const-eval-overflow-3.rs:18:11 | LL | = [0; (i8::MAX + 1) as usize]; - | ^^^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow + | ^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/const-eval-overflow-4.rs b/tests/ui/consts/const-eval/const-eval-overflow-4.rs index 762c7a968a8..d42c29249af 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-4.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow-4.rs @@ -9,7 +9,7 @@ use std::fmt; const A_I8_T : [u32; (i8::MAX as i8 + 1i8) as usize] - //~^ ERROR evaluation of constant value failed + //~^ ERROR overflow = [0; (i8::MAX as usize) + 1]; fn main() { diff --git a/tests/ui/consts/const-eval/const-eval-overflow-4.stderr b/tests/ui/consts/const-eval/const-eval-overflow-4.stderr index ce5e59901c1..c14a880849f 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-4.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-4.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i8::MAX + 1_i8`, which would overflow --> $DIR/const-eval-overflow-4.rs:11:13 | LL | : [u32; (i8::MAX as i8 + 1i8) as usize] - | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/const-eval-overflow2.rs b/tests/ui/consts/const-eval/const-eval-overflow2.rs index 1676f7c2af6..348c8e06f66 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow2.rs @@ -11,47 +11,47 @@ const VALS_I8: (i8,) = ( i8::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I16: (i16,) = ( i16::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I32: (i32,) = ( i32::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I64: (i64,) = ( i64::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U8: (u8,) = ( u8::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U16: (u16,) = ( u16::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U32: (u32,) = ( u32::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U64: (u64,) = ( u64::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow fn main() { foo(VALS_I8); diff --git a/tests/ui/consts/const-eval/const-eval-overflow2.stderr b/tests/ui/consts/const-eval/const-eval-overflow2.stderr index 341c15daf65..a705604e383 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow2.stderr @@ -1,50 +1,50 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i8::MIN - 1_i8`, which would overflow --> $DIR/const-eval-overflow2.rs:12:6 | LL | i8::MIN - 1, - | ^^^^^^^^^^^ attempt to compute `i8::MIN - 1_i8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i16::MIN - 1_i16`, which would overflow --> $DIR/const-eval-overflow2.rs:18:6 | LL | i16::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `i16::MIN - 1_i16`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i32::MIN - 1_i32`, which would overflow --> $DIR/const-eval-overflow2.rs:24:6 | LL | i32::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `i32::MIN - 1_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i64::MIN - 1_i64`, which would overflow --> $DIR/const-eval-overflow2.rs:30:6 | LL | i64::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `i64::MIN - 1_i64`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_u8 - 1_u8`, which would overflow --> $DIR/const-eval-overflow2.rs:36:6 | LL | u8::MIN - 1, - | ^^^^^^^^^^^ attempt to compute `0_u8 - 1_u8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_u16 - 1_u16`, which would overflow --> $DIR/const-eval-overflow2.rs:41:6 | LL | u16::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `0_u16 - 1_u16`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow --> $DIR/const-eval-overflow2.rs:46:6 | LL | u32::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_u64 - 1_u64`, which would overflow --> $DIR/const-eval-overflow2.rs:52:6 | LL | u64::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `0_u64 - 1_u64`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 8 previous errors diff --git a/tests/ui/consts/const-eval/const-eval-overflow2b.rs b/tests/ui/consts/const-eval/const-eval-overflow2b.rs index 59d1df5680d..b05b0b11105 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2b.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow2b.rs @@ -11,47 +11,47 @@ const VALS_I8: (i8,) = ( i8::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I16: (i16,) = ( i16::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I32: (i32,) = ( i32::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I64: (i64,) = ( i64::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U8: (u8,) = ( u8::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U16: (u16,) = ( u16::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U32: (u32,) = ( u32::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U64: (u64,) = ( u64::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow fn main() { foo(VALS_I8); diff --git a/tests/ui/consts/const-eval/const-eval-overflow2b.stderr b/tests/ui/consts/const-eval/const-eval-overflow2b.stderr index e661836b4b9..33de4b6ed32 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2b.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow2b.stderr @@ -1,50 +1,50 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i8::MAX + 1_i8`, which would overflow --> $DIR/const-eval-overflow2b.rs:12:6 | LL | i8::MAX + 1, - | ^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i16::MAX + 1_i16`, which would overflow --> $DIR/const-eval-overflow2b.rs:18:6 | LL | i16::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `i16::MAX + 1_i16`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i32::MAX + 1_i32`, which would overflow --> $DIR/const-eval-overflow2b.rs:24:6 | LL | i32::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i64::MAX + 1_i64`, which would overflow --> $DIR/const-eval-overflow2b.rs:30:6 | LL | i64::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `i64::MAX + 1_i64`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow --> $DIR/const-eval-overflow2b.rs:36:6 | LL | u8::MAX + 1, - | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u16::MAX + 1_u16`, which would overflow --> $DIR/const-eval-overflow2b.rs:41:6 | LL | u16::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `u16::MAX + 1_u16`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u32::MAX + 1_u32`, which would overflow --> $DIR/const-eval-overflow2b.rs:46:6 | LL | u32::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `u32::MAX + 1_u32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u64::MAX + 1_u64`, which would overflow --> $DIR/const-eval-overflow2b.rs:52:6 | LL | u64::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `u64::MAX + 1_u64`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 8 previous errors diff --git a/tests/ui/consts/const-eval/const-eval-overflow2c.rs b/tests/ui/consts/const-eval/const-eval-overflow2c.rs index 33b89260115..ec87f5e066c 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2c.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow2c.rs @@ -11,47 +11,47 @@ const VALS_I8: (i8,) = ( i8::MIN * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I16: (i16,) = ( i16::MIN * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I32: (i32,) = ( i32::MIN * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I64: (i64,) = ( i64::MIN * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U8: (u8,) = ( u8::MAX * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U16: (u16,) = ( u16::MAX * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U32: (u32,) = ( u32::MAX * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U64: (u64,) = ( u64::MAX * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow fn main() { foo(VALS_I8); diff --git a/tests/ui/consts/const-eval/const-eval-overflow2c.stderr b/tests/ui/consts/const-eval/const-eval-overflow2c.stderr index 1fad15492fb..69949b57904 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2c.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow2c.stderr @@ -1,50 +1,50 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i8::MIN * 2_i8`, which would overflow --> $DIR/const-eval-overflow2c.rs:12:6 | LL | i8::MIN * 2, - | ^^^^^^^^^^^ attempt to compute `i8::MIN * 2_i8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i16::MIN * 2_i16`, which would overflow --> $DIR/const-eval-overflow2c.rs:18:6 | LL | i16::MIN * 2, - | ^^^^^^^^^^^^ attempt to compute `i16::MIN * 2_i16`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i32::MIN * 2_i32`, which would overflow --> $DIR/const-eval-overflow2c.rs:24:6 | LL | i32::MIN * 2, - | ^^^^^^^^^^^^ attempt to compute `i32::MIN * 2_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i64::MIN * 2_i64`, which would overflow --> $DIR/const-eval-overflow2c.rs:30:6 | LL | i64::MIN * 2, - | ^^^^^^^^^^^^ attempt to compute `i64::MIN * 2_i64`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u8::MAX * 2_u8`, which would overflow --> $DIR/const-eval-overflow2c.rs:36:6 | LL | u8::MAX * 2, - | ^^^^^^^^^^^ attempt to compute `u8::MAX * 2_u8`, which would overflow + | ^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u16::MAX * 2_u16`, which would overflow --> $DIR/const-eval-overflow2c.rs:41:6 | LL | u16::MAX * 2, - | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 2_u16`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u32::MAX * 2_u32`, which would overflow --> $DIR/const-eval-overflow2c.rs:46:6 | LL | u32::MAX * 2, - | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 2_u32`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u64::MAX * 2_u64`, which would overflow --> $DIR/const-eval-overflow2c.rs:52:6 | LL | u64::MAX * 2, - | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 2_u64`, which would overflow + | ^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 8 previous errors diff --git a/tests/ui/consts/const-eval/const-eval-query-stack.rs b/tests/ui/consts/const-eval/const-eval-query-stack.rs index 8de398787b4..3728e2071d3 100644 --- a/tests/ui/consts/const-eval/const-eval-query-stack.rs +++ b/tests/ui/consts/const-eval/const-eval-query-stack.rs @@ -13,7 +13,7 @@ //@ normalize-stderr: ".*omitted \d{1,} frame.*\n" -> "" #![allow(unconditional_panic)] -const X: i32 = 1 / 0; //~ERROR constant +const X: i32 = 1 / 0; //~ERROR attempt to divide `1_i32` by zero fn main() { let x: &'static i32 = &X; diff --git a/tests/ui/consts/const-eval/const-eval-query-stack.stderr b/tests/ui/consts/const-eval/const-eval-query-stack.stderr index 5a71c770fdc..d5b7e67724d 100644 --- a/tests/ui/consts/const-eval/const-eval-query-stack.stderr +++ b/tests/ui/consts/const-eval/const-eval-query-stack.stderr @@ -1,8 +1,8 @@ -error: internal compiler error[E0080]: evaluation of constant value failed +error: internal compiler error[E0080]: attempt to divide `1_i32` by zero --> $DIR/const-eval-query-stack.rs:16:16 | LL | const X: i32 = 1 / 0; - | ^^^^^ attempt to divide `1_i32` by zero + | ^^^^^ evaluation of constant value failed here note: please make sure that you have updated to the latest nightly diff --git a/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr b/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr index 3eccd596274..3a1e8c734d4 100644 --- a/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr +++ b/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr @@ -1,254 +1,254 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:27:49 | LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:30:43 | LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:33:45 | LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:36:45 | LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:39:45 | LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/const-pointer-values-in-various-types.rs:42:47 | LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:46:43 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:45:43 | LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:49:45 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:48:45 | LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:52:45 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:51:45 | LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:55:45 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:54:45 | LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:58:47 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/const-pointer-values-in-various-types.rs:57:47 | LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:62:45 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:60:45 | LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:65:45 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:63:45 | LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:68:47 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:66:47 | LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:71:47 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:69:47 | LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:74:39 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:72:39 | LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:77:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:75:41 | LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:80:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:78:41 | LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:83:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:81:41 | LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:86:43 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:84:43 | LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:89:39 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:87:39 | LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:92:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:90:41 | LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:95:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:93:41 | LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:98:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:96:41 | LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:101:43 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:99:43 | LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:104:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:102:41 | LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:107:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:105:41 | LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:110:43 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:108:43 | LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:113:43 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:111:43 | LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/const-eval/const-pointer-values-in-various-types.rs b/tests/ui/consts/const-eval/const-pointer-values-in-various-types.rs index ce7380cd155..5720d6ea91e 100644 --- a/tests/ui/consts/const-eval/const-pointer-values-in-various-types.rs +++ b/tests/ui/consts/const-eval/const-pointer-values-in-various-types.rs @@ -25,91 +25,89 @@ union Nonsense { fn main() { const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 }; - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 }; - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer } diff --git a/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs b/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs index c6ae3af4427..03976a05b75 100644 --- a/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs +++ b/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs @@ -14,11 +14,11 @@ const fn bar(x: fn(usize) -> usize, y: usize) -> usize { } const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday -//~^ ERROR evaluation of constant value failed -//~| NOTE calling non-const function `double` +//~^ NOTE evaluation of constant value failed +//~| ERROR calling non-const function `double` const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday -//~^ ERROR evaluation of constant value failed -//~| NOTE calling non-const function `double` +//~^ NOTE evaluation of constant value failed +//~| ERROR calling non-const function `double` fn main() { assert_eq!(Y, 4); diff --git a/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr b/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr index a4d2e26c3af..6eddb72bae8 100644 --- a/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr +++ b/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: calling non-const function `double` --> $DIR/const_fn_ptr_fail2.rs:16:18 | LL | const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday - | ^^^^^^^^^ calling non-const function `double` + | ^^^^^^^^^ evaluation of constant value failed here | note: inside `bar` --> $DIR/const_fn_ptr_fail2.rs:9:5 @@ -10,11 +10,11 @@ note: inside `bar` LL | x(y) | ^^^^ the failure occurred here -error[E0080]: evaluation of constant value failed +error[E0080]: calling non-const function `double` --> $DIR/const_fn_ptr_fail2.rs:19:18 | LL | const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday - | ^^^^^^^^^^^^^^ calling non-const function `double` + | ^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `bar` --> $DIR/const_fn_ptr_fail2.rs:9:5 diff --git a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs index 0bf2f0e6669..45298df0243 100644 --- a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs +++ b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs @@ -1,5 +1,5 @@ #![crate_type = "lib"] struct Bug([u8; panic!{"\t"}]); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked //~| NOTE: in this expansion of panic! diff --git a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr index fae971c09f2..6e5e0e727fb 100644 --- a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr +++ b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: --> $DIR/const_panic-normalize-tabs-115498.rs:3:17 | LL | struct Bug([u8; panic!{"\t"}]); - | ^^^^^^^^^^^^ evaluation panicked: + | ^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/const_panic.rs b/tests/ui/consts/const-eval/const_panic.rs index 5b9a8f8e2a2..367396bab94 100644 --- a/tests/ui/consts/const-eval/const_panic.rs +++ b/tests/ui/consts/const-eval/const_panic.rs @@ -4,37 +4,37 @@ const MSG: &str = "hello"; const Z: () = std::panic!("cheese"); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const Z2: () = std::panic!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const Y: () = std::unreachable!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const X: () = std::unimplemented!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const W: () = std::panic!(MSG); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const W2: () = std::panic!("{}", MSG); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const Z_CORE: () = core::panic!("cheese"); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const Z2_CORE: () = core::panic!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const Y_CORE: () = core::unreachable!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const X_CORE: () = core::unimplemented!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const W_CORE: () = core::panic!(MSG); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const W2_CORE: () = core::panic!("{}", MSG); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked diff --git a/tests/ui/consts/const-eval/const_panic.stderr b/tests/ui/consts/const-eval/const_panic.stderr index 0874224e5f2..1b5421276c3 100644 --- a/tests/ui/consts/const-eval/const_panic.stderr +++ b/tests/ui/consts/const-eval/const_panic.stderr @@ -1,78 +1,78 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: cheese --> $DIR/const_panic.rs:6:15 | LL | const Z: () = std::panic!("cheese"); - | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: cheese + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/const_panic.rs:9:16 | LL | const Z2: () = std::panic!(); - | ^^^^^^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: internal error: entered unreachable code --> $DIR/const_panic.rs:12:15 | LL | const Y: () = std::unreachable!(); - | ^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: not implemented --> $DIR/const_panic.rs:15:15 | LL | const X: () = std::unimplemented!(); - | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = note: this error originates in the macro `std::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hello --> $DIR/const_panic.rs:18:15 | LL | const W: () = std::panic!(MSG); - | ^^^^^^^^^^^^^^^^ evaluation panicked: hello + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hello --> $DIR/const_panic.rs:21:16 | LL | const W2: () = std::panic!("{}", MSG); - | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: cheese --> $DIR/const_panic.rs:24:20 | LL | const Z_CORE: () = core::panic!("cheese"); - | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: cheese + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/const_panic.rs:27:21 | LL | const Z2_CORE: () = core::panic!(); - | ^^^^^^^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: internal error: entered unreachable code --> $DIR/const_panic.rs:30:20 | LL | const Y_CORE: () = core::unreachable!(); - | ^^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code + | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: not implemented --> $DIR/const_panic.rs:33:20 | LL | const X_CORE: () = core::unimplemented!(); - | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = note: this error originates in the macro `core::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hello --> $DIR/const_panic.rs:36:20 | LL | const W_CORE: () = core::panic!(MSG); - | ^^^^^^^^^^^^^^^^^ evaluation panicked: hello + | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hello --> $DIR/const_panic.rs:39:21 | LL | const W2_CORE: () = core::panic!("{}", MSG); - | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 12 previous errors diff --git a/tests/ui/consts/const-eval/const_panic_2021.rs b/tests/ui/consts/const-eval/const_panic_2021.rs index 31a80e71b7c..845f78beef9 100644 --- a/tests/ui/consts/const-eval/const_panic_2021.rs +++ b/tests/ui/consts/const-eval/const_panic_2021.rs @@ -4,31 +4,31 @@ const MSG: &str = "hello"; const A: () = std::panic!("blåhaj"); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const B: () = std::panic!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const C: () = std::unreachable!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const D: () = std::unimplemented!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const E: () = std::panic!("{}", MSG); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const A_CORE: () = core::panic!("shark"); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const B_CORE: () = core::panic!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const C_CORE: () = core::unreachable!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const D_CORE: () = core::unimplemented!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const E_CORE: () = core::panic!("{}", MSG); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked diff --git a/tests/ui/consts/const-eval/const_panic_2021.stderr b/tests/ui/consts/const-eval/const_panic_2021.stderr index 1496df4445a..15b173f9400 100644 --- a/tests/ui/consts/const-eval/const_panic_2021.stderr +++ b/tests/ui/consts/const-eval/const_panic_2021.stderr @@ -1,66 +1,66 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: blåhaj --> $DIR/const_panic_2021.rs:6:15 | LL | const A: () = std::panic!("blåhaj"); - | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: blåhaj + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/const_panic_2021.rs:9:15 | LL | const B: () = std::panic!(); - | ^^^^^^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: internal error: entered unreachable code --> $DIR/const_panic_2021.rs:12:15 | LL | const C: () = std::unreachable!(); - | ^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: not implemented --> $DIR/const_panic_2021.rs:15:15 | LL | const D: () = std::unimplemented!(); - | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = note: this error originates in the macro `std::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hello --> $DIR/const_panic_2021.rs:18:15 | LL | const E: () = std::panic!("{}", MSG); - | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: shark --> $DIR/const_panic_2021.rs:21:20 | LL | const A_CORE: () = core::panic!("shark"); - | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: shark + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/const_panic_2021.rs:24:20 | LL | const B_CORE: () = core::panic!(); - | ^^^^^^^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: internal error: entered unreachable code --> $DIR/const_panic_2021.rs:27:20 | LL | const C_CORE: () = core::unreachable!(); - | ^^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code + | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: not implemented --> $DIR/const_panic_2021.rs:30:20 | LL | const D_CORE: () = core::unimplemented!(); - | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = note: this error originates in the macro `core::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hello --> $DIR/const_panic_2021.rs:33:20 | LL | const E_CORE: () = core::panic!("{}", MSG); - | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 10 previous errors diff --git a/tests/ui/consts/const-eval/const_panic_libcore_bin.rs b/tests/ui/consts/const-eval/const_panic_libcore_bin.rs index d4dc1a51d73..90ae5165d23 100644 --- a/tests/ui/consts/const-eval/const_panic_libcore_bin.rs +++ b/tests/ui/consts/const-eval/const_panic_libcore_bin.rs @@ -6,13 +6,13 @@ use core::panic::PanicInfo; const Z: () = panic!("cheese"); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const Y: () = unreachable!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const X: () = unimplemented!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked #[lang = "eh_personality"] fn eh() {} diff --git a/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr b/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr index 2acab711290..3c308e38850 100644 --- a/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr +++ b/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr @@ -1,20 +1,20 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: cheese --> $DIR/const_panic_libcore_bin.rs:8:15 | LL | const Z: () = panic!("cheese"); - | ^^^^^^^^^^^^^^^^ evaluation panicked: cheese + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: internal error: entered unreachable code --> $DIR/const_panic_libcore_bin.rs:11:15 | LL | const Y: () = unreachable!(); - | ^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code + | ^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: not implemented --> $DIR/const_panic_libcore_bin.rs:14:15 | LL | const X: () = unimplemented!(); - | ^^^^^^^^^^^^^^^^ evaluation panicked: not implemented + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = note: this error originates in the macro `unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/const-eval/const_panic_track_caller.rs b/tests/ui/consts/const-eval/const_panic_track_caller.rs index 799a59d16ca..5f5d853eb97 100644 --- a/tests/ui/consts/const-eval/const_panic_track_caller.rs +++ b/tests/ui/consts/const-eval/const_panic_track_caller.rs @@ -17,5 +17,5 @@ const fn c() -> u32 { } const X: u32 = c(); -//~^ ERROR evaluation of constant value failed -//~| NOTE hey +//~^ NOTE evaluation of constant value failed +//~| ERROR hey diff --git a/tests/ui/consts/const-eval/const_panic_track_caller.stderr b/tests/ui/consts/const-eval/const_panic_track_caller.stderr index 8736a8c9409..b4017ccf8da 100644 --- a/tests/ui/consts/const-eval/const_panic_track_caller.stderr +++ b/tests/ui/consts/const-eval/const_panic_track_caller.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hey --> $DIR/const_panic_track_caller.rs:19:16 | LL | const X: u32 = c(); - | ^^^ evaluation panicked: hey + | ^^^ evaluation of constant value failed here | note: inside `c` --> $DIR/const_panic_track_caller.rs:15:5 diff --git a/tests/ui/consts/const-eval/const_raw_ptr_ops2.rs b/tests/ui/consts/const-eval/const_raw_ptr_ops2.rs index 0e88aa80c79..47998cf408c 100644 --- a/tests/ui/consts/const-eval/const_raw_ptr_ops2.rs +++ b/tests/ui/consts/const-eval/const_raw_ptr_ops2.rs @@ -4,7 +4,5 @@ fn main() {} const Z: i32 = unsafe { *(&1 as *const i32) }; // bad, will thus error in miri -const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR evaluation of constant value failed -//~| NOTE dangling pointer -const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR evaluation of constant value failed -//~| NOTE dangling pointer +const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR dangling pointer +const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR dangling pointer diff --git a/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr b/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr index a8a5560ccb9..6f096ee5ce7 100644 --- a/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr +++ b/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 4 bytes, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/const_raw_ptr_ops2.rs:7:26 | LL | const Z2: i32 = unsafe { *(42 as *const i32) }; - | ^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const_raw_ptr_ops2.rs:9:26 +error[E0080]: memory access failed: attempting to access 4 bytes, but got 0x2c[noalloc] which is a dangling pointer (it has no provenance) + --> $DIR/const_raw_ptr_ops2.rs:8:26 | LL | const Z3: i32 = unsafe { *(44 as *const i32) }; - | ^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got 0x2c[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs index b47e2b3c1ed..d6e5a69671b 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs @@ -4,7 +4,7 @@ #![feature(const_heap)] use std::intrinsics; -const FOO: i32 = foo(); //~ ERROR evaluation of constant value failed +const FOO: i32 = foo(); //~ ERROR 3 is not a power of 2 const fn foo() -> i32 { unsafe { let _ = intrinsics::const_allocate(4, 3) as *mut i32; //~ NOTE inside `foo` diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr index 9f7546df3a2..9132c7e9cd4 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: invalid align passed to `const_allocate`: 3 is not a power of 2 --> $DIR/alloc_intrinsic_errors.rs:7:18 | LL | const FOO: i32 = foo(); - | ^^^^^ invalid align passed to `const_allocate`: 3 is not a power of 2 + | ^^^^^ evaluation of constant value failed here | note: inside `foo` --> $DIR/alloc_intrinsic_errors.rs:10:17 diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr index 271c8611091..11ed0841a00 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>: encountered uninitialized memory, but expected an integer --> $DIR/alloc_intrinsic_uninit.rs:7:1 | LL | const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) }; - | ^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr index ec7cc7d4140..691bde87d2f 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>: encountered uninitialized memory, but expected an integer --> $DIR/alloc_intrinsic_uninit.rs:7:1 | LL | const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) }; - | ^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs index c283a5fae7d..ffc35ca1ddc 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs @@ -5,5 +5,5 @@ use std::intrinsics; const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) }; -//~^ error: it is undefined behavior to use this value +//~^ ERROR: uninitialized memory fn main() {} diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs index 509c872f609..de9fc5d0921 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs @@ -9,7 +9,7 @@ use std::intrinsics; const _X: &'static u8 = unsafe { - //~^ error: it is undefined behavior to use this value + //~^ ERROR: dangling reference (use-after-free) let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 4, 4); &*ptr @@ -20,7 +20,7 @@ const _Y: u8 = unsafe { let reference = &*ptr; intrinsics::const_deallocate(ptr, 4, 4); *reference - //~^ error: evaluation of constant value failed + //~^ ERROR: has been freed, so this pointer is dangling }; fn main() {} diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr index 0b0d2676dd3..cb419f2f739 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr @@ -1,19 +1,19 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a dangling reference (use-after-free) --> $DIR/dealloc_intrinsic_dangling.rs:11:1 | LL | const _X: &'static u8 = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (use-after-free) + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: ALLOC1 has been freed, so this pointer is dangling --> $DIR/dealloc_intrinsic_dangling.rs:22:5 | LL | *reference - | ^^^^^^^^^^ memory access failed: ALLOC1 has been freed, so this pointer is dangling + | ^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.rs b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.rs index 4010b476990..5b7cd039b9b 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.rs +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.rs @@ -7,7 +7,7 @@ const _X: () = unsafe { let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 4, 4); intrinsics::const_deallocate(ptr, 4, 4); - //~^ error: evaluation of constant value failed + //~^ ERROR: dangling }; fn main() {} diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr index d2d323e5a51..3038d60f202 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: ALLOC0 has been freed, so this pointer is dangling --> $DIR/dealloc_intrinsic_duplicate.rs:9:5 | LL | intrinsics::const_deallocate(ptr, 4, 4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC0 has been freed, so this pointer is dangling + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.rs b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.rs index 031d70fdc88..75c3601f216 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.rs +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.rs @@ -6,24 +6,24 @@ use std::intrinsics; const _X: () = unsafe { let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 4, 2); - //~^ error: evaluation of constant value failed + //~^ error: incorrect layout on deallocation }; const _Y: () = unsafe { let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 2, 4); - //~^ error: evaluation of constant value failed + //~^ error: incorrect layout on deallocation }; const _Z: () = unsafe { let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 3, 4); - //~^ error: evaluation of constant value failed + //~^ error: incorrect layout on deallocation }; const _W: () = unsafe { let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 4, 3); - //~^ error: evaluation of constant value failed + //~^ error: invalid align }; fn main() {} diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr index 4b1f0f686ca..dea55c6086e 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr @@ -1,26 +1,26 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: incorrect layout on deallocation: ALLOC0 has size 4 and alignment 4, but gave size 4 and alignment 2 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:8:5 | LL | intrinsics::const_deallocate(ptr, 4, 2); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC0 has size 4 and alignment 4, but gave size 4 and alignment 2 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: incorrect layout on deallocation: ALLOC1 has size 4 and alignment 4, but gave size 2 and alignment 4 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:13:5 | LL | intrinsics::const_deallocate(ptr, 2, 4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC1 has size 4 and alignment 4, but gave size 2 and alignment 4 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: incorrect layout on deallocation: ALLOC2 has size 4 and alignment 4, but gave size 3 and alignment 4 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:19:5 | LL | intrinsics::const_deallocate(ptr, 3, 4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC2 has size 4 and alignment 4, but gave size 3 and alignment 4 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: invalid align passed to `const_deallocate`: 3 is not a power of 2 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:25:5 | LL | intrinsics::const_deallocate(ptr, 4, 3); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid align passed to `const_deallocate`: 3 is not a power of 2 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 4 previous errors diff --git a/tests/ui/consts/const-eval/index-out-of-bounds-never-type.rs b/tests/ui/consts/const-eval/index-out-of-bounds-never-type.rs index 25ffc9cbdba..6777bee050a 100644 --- a/tests/ui/consts/const-eval/index-out-of-bounds-never-type.rs +++ b/tests/ui/consts/const-eval/index-out-of-bounds-never-type.rs @@ -8,7 +8,7 @@ struct PrintName<T>(T); impl<T> PrintName<T> { const VOID: ! = { let x = 0 * std::mem::size_of::<T>(); [][x] }; - //~^ ERROR evaluation of `PrintName::<()>::VOID` failed + //~^ ERROR index out of bounds: the length is 0 but the index is 0 } diff --git a/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr b/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr index 7facb2d1a5c..7e57e16aa4f 100644 --- a/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr +++ b/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `PrintName::<()>::VOID` failed +error[E0080]: index out of bounds: the length is 0 but the index is 0 --> $DIR/index-out-of-bounds-never-type.rs:10:61 | LL | const VOID: ! = { let x = 0 * std::mem::size_of::<T>(); [][x] }; - | ^^^^^ index out of bounds: the length is 0 but the index is 0 + | ^^^^^ evaluation of `PrintName::<()>::VOID` failed here note: erroneous constant encountered --> $DIR/index-out-of-bounds-never-type.rs:16:13 diff --git a/tests/ui/consts/const-eval/index_out_of_bounds.stderr b/tests/ui/consts/const-eval/index_out_of_bounds.stderr index d8df74fa010..f4ec4c516fd 100644 --- a/tests/ui/consts/const-eval/index_out_of_bounds.stderr +++ b/tests/ui/consts/const-eval/index_out_of_bounds.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: index out of bounds: the length is 0 but the index is 0 --> $DIR/index_out_of_bounds.rs:1:19 | LL | static FOO: i32 = [][0]; - | ^^^^^ index out of bounds: the length is 0 but the index is 0 + | ^^^^^ evaluation of static initializer failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/issue-43197.rs b/tests/ui/consts/const-eval/issue-43197.rs index 145463f0ae2..778a66facb8 100644 --- a/tests/ui/consts/const-eval/issue-43197.rs +++ b/tests/ui/consts/const-eval/issue-43197.rs @@ -4,8 +4,8 @@ const fn foo(x: u32) -> u32 { fn main() { const X: u32 = 0 - 1; - //~^ ERROR constant + //~^ ERROR overflow const Y: u32 = foo(0 - 1); - //~^ ERROR constant + //~^ ERROR overflow println!("{} {}", X, Y); } diff --git a/tests/ui/consts/const-eval/issue-43197.stderr b/tests/ui/consts/const-eval/issue-43197.stderr index c59f13e4888..cad23becff7 100644 --- a/tests/ui/consts/const-eval/issue-43197.stderr +++ b/tests/ui/consts/const-eval/issue-43197.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow --> $DIR/issue-43197.rs:6:20 | LL | const X: u32 = 0 - 1; - | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow + | ^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow --> $DIR/issue-43197.rs:8:24 | LL | const Y: u32 = foo(0 - 1); - | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow + | ^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/issue-44578.rs b/tests/ui/consts/const-eval/issue-44578.rs index 565e1d3825b..ebd54f4079c 100644 --- a/tests/ui/consts/const-eval/issue-44578.rs +++ b/tests/ui/consts/const-eval/issue-44578.rs @@ -11,7 +11,7 @@ enum Bar<A, B> { } impl<A: Foo, B: Foo> Foo for Bar<A, B> { - const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; //~ERROR evaluation of `<Bar<u16, u8> as Foo>::AMT` failed + const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; //~ERROR the length is 1 but the index is 1 } impl Foo for u8 { diff --git a/tests/ui/consts/const-eval/issue-44578.stderr b/tests/ui/consts/const-eval/issue-44578.stderr index 5093cec81c7..fd0b9ae1e17 100644 --- a/tests/ui/consts/const-eval/issue-44578.stderr +++ b/tests/ui/consts/const-eval/issue-44578.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `<Bar<u16, u8> as Foo>::AMT` failed +error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $DIR/issue-44578.rs:14:24 | LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `<Bar<u16, u8> as Foo>::AMT` failed here note: erroneous constant encountered --> $DIR/issue-44578.rs:26:20 diff --git a/tests/ui/consts/const-eval/issue-49296.rs b/tests/ui/consts/const-eval/issue-49296.rs index 917777a32ff..a427b642899 100644 --- a/tests/ui/consts/const-eval/issue-49296.rs +++ b/tests/ui/consts/const-eval/issue-49296.rs @@ -7,7 +7,7 @@ const fn wat(x: u64) -> &'static u64 { } const X: u64 = *wat(42); -//~^ ERROR evaluation of constant value failed +//~^ ERROR dangling fn main() { println!("{}", X); diff --git a/tests/ui/consts/const-eval/issue-49296.stderr b/tests/ui/consts/const-eval/issue-49296.stderr index 485a11d1f3c..4a66ec6c940 100644 --- a/tests/ui/consts/const-eval/issue-49296.stderr +++ b/tests/ui/consts/const-eval/issue-49296.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: ALLOC0 has been freed, so this pointer is dangling --> $DIR/issue-49296.rs:9:16 | LL | const X: u64 = *wat(42); - | ^^^^^^^^ memory access failed: ALLOC0 has been freed, so this pointer is dangling + | ^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr b/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr index 1f4f217b175..6c0d6cf8b21 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr +++ b/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `<A<()> as Foo<()>>::BAR` failed +error[E0080]: index out of bounds: the length is 3 but the index is 42 --> $DIR/issue-50814-2.rs:17:24 | LL | const BAR: usize = [5, 6, 7][T::BOO]; - | ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 + | ^^^^^^^^^^^^^^^^^ evaluation of `<A<()> as Foo<()>>::BAR` failed here note: erroneous constant encountered --> $DIR/issue-50814-2.rs:21:6 diff --git a/tests/ui/consts/const-eval/issue-50814-2.normal.stderr b/tests/ui/consts/const-eval/issue-50814-2.normal.stderr index f790862aef1..749c9dde1ce 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.normal.stderr +++ b/tests/ui/consts/const-eval/issue-50814-2.normal.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `<A<()> as Foo<()>>::BAR` failed +error[E0080]: index out of bounds: the length is 3 but the index is 42 --> $DIR/issue-50814-2.rs:17:24 | LL | const BAR: usize = [5, 6, 7][T::BOO]; - | ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 + | ^^^^^^^^^^^^^^^^^ evaluation of `<A<()> as Foo<()>>::BAR` failed here note: erroneous constant encountered --> $DIR/issue-50814-2.rs:21:6 diff --git a/tests/ui/consts/const-eval/issue-50814-2.rs b/tests/ui/consts/const-eval/issue-50814-2.rs index 261dcd3aa4c..1b917a0916d 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.rs +++ b/tests/ui/consts/const-eval/issue-50814-2.rs @@ -14,7 +14,7 @@ trait Foo<T> { struct A<T>(T); impl<T: C> Foo<T> for A<T> { - const BAR: usize = [5, 6, 7][T::BOO]; //~ ERROR evaluation of `<A<()> as Foo<()>>::BAR` failed + const BAR: usize = [5, 6, 7][T::BOO]; //~ ERROR index out of bounds: the length is 3 but the index is 42 } fn foo<T: C>() -> &'static usize { diff --git a/tests/ui/consts/const-eval/issue-50814.rs b/tests/ui/consts/const-eval/issue-50814.rs index 5495fb43bba..011f065ad81 100644 --- a/tests/ui/consts/const-eval/issue-50814.rs +++ b/tests/ui/consts/const-eval/issue-50814.rs @@ -14,8 +14,8 @@ struct Sum<A, B>(A, B); impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A, B> { const MAX: u8 = A::MAX + B::MAX; - //~^ ERROR evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed - //~| ERROR evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed + //~^ ERROR attempt to compute `u8::MAX + u8::MAX`, which would overflow + //~| ERROR attempt to compute `u8::MAX + u8::MAX`, which would overflow } fn foo<T>(_: T) -> &'static u8 { diff --git a/tests/ui/consts/const-eval/issue-50814.stderr b/tests/ui/consts/const-eval/issue-50814.stderr index 5b23c48e450..1287c83ae0f 100644 --- a/tests/ui/consts/const-eval/issue-50814.stderr +++ b/tests/ui/consts/const-eval/issue-50814.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed +error[E0080]: attempt to compute `u8::MAX + u8::MAX`, which would overflow --> $DIR/issue-50814.rs:16:21 | LL | const MAX: u8 = A::MAX + B::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed here note: erroneous constant encountered --> $DIR/issue-50814.rs:22:6 @@ -10,11 +10,11 @@ note: erroneous constant encountered LL | &Sum::<U8, U8>::MAX | ^^^^^^^^^^^^^^^^^^ -error[E0080]: evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed +error[E0080]: attempt to compute `u8::MAX + u8::MAX`, which would overflow --> $DIR/issue-50814.rs:16:21 | LL | const MAX: u8 = A::MAX + B::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed here | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/consts/const-eval/issue-85155.rs b/tests/ui/consts/const-eval/issue-85155.rs index cb5b3a08375..c47101d04c2 100644 --- a/tests/ui/consts/const-eval/issue-85155.rs +++ b/tests/ui/consts/const-eval/issue-85155.rs @@ -20,5 +20,5 @@ fn main() { //~^ NOTE the above error was encountered while instantiating } -//~? ERROR evaluation of `post_monomorphization_error::ValidateConstImm::<2, 0, 1>::VALID` failed +//~? ERROR attempt to divide `1_usize` by zero //~? NOTE erroneous constant encountered diff --git a/tests/ui/consts/const-eval/issue-85155.stderr b/tests/ui/consts/const-eval/issue-85155.stderr index 99836a3fac6..f7777bfac02 100644 --- a/tests/ui/consts/const-eval/issue-85155.stderr +++ b/tests/ui/consts/const-eval/issue-85155.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `post_monomorphization_error::ValidateConstImm::<2, 0, 1>::VALID` failed +error[E0080]: attempt to divide `1_usize` by zero --> $DIR/auxiliary/post_monomorphization_error.rs:7:17 | LL | let _ = 1 / ((IMM >= MIN && IMM <= MAX) as usize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to divide `1_usize` by zero + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `post_monomorphization_error::ValidateConstImm::<2, 0, 1>::VALID` failed here note: erroneous constant encountered --> $DIR/auxiliary/post_monomorphization_error.rs:19:5 diff --git a/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.rs b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.rs index 3a932343ddd..12effde1a9b 100644 --- a/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.rs +++ b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.rs @@ -36,8 +36,7 @@ const OFFSET: () = unsafe { // This needs to compute the field offset, but we don't know the type's alignment, so this // fails. let field = &x.a; - //~^ ERROR: evaluation of constant value failed - //~| NOTE does not have a known offset + //~^ ERROR: does not have a known offset }; fn main() {} diff --git a/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr index 54d45ee8ffb..ffff7594e3d 100644 --- a/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr +++ b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: `extern type` field does not have a known offset --> $DIR/issue-91827-extern-types-field-offset.rs:38:17 | LL | let field = &x.a; - | ^^^^ `extern type` field does not have a known offset + | ^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/mod-static-with-const-fn.rs b/tests/ui/consts/const-eval/mod-static-with-const-fn.rs index 7de9d44305d..ce2ecaa2638 100644 --- a/tests/ui/consts/const-eval/mod-static-with-const-fn.rs +++ b/tests/ui/consts/const-eval/mod-static-with-const-fn.rs @@ -12,7 +12,7 @@ static FOO: Foo = Foo(UnsafeCell::new(42)); static BAR: () = unsafe { *FOO.0.get() = 5; - //~^ ERROR could not evaluate static initializer + //~^ ERROR modifying a static's initial value }; fn main() { diff --git a/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr b/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr index 47bfc235a1a..f8cf6096095 100644 --- a/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr +++ b/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/mod-static-with-const-fn.rs:14:5 | LL | *FOO.0.get() = 5; - | ^^^^^^^^^^^^^^^^ modifying a static's initial value from another static's initializer + | ^^^^^^^^^^^^^^^^ evaluation of static initializer failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs b/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs index 19ab5239986..908833e6514 100644 --- a/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs +++ b/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs @@ -1,6 +1,6 @@ use std::ptr::NonNull; const NON_NULL: NonNull<u8> = unsafe { NonNull::dangling() }; -const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); //~ERROR: evaluation of constant value failed +const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); //~ERROR: dangling pointer (it has no provenance) fn main() {} diff --git a/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr b/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr index 1996cd2721e..32ae9475560 100644 --- a/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr +++ b/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/nonnull_as_ref_ub.rs:4:29 | LL | const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/panic-assoc-never-type.rs b/tests/ui/consts/const-eval/panic-assoc-never-type.rs index 79b5dafaf15..a0a5ba36bfe 100644 --- a/tests/ui/consts/const-eval/panic-assoc-never-type.rs +++ b/tests/ui/consts/const-eval/panic-assoc-never-type.rs @@ -8,7 +8,7 @@ struct PrintName; impl PrintName { const VOID: ! = panic!(); - //~^ ERROR evaluation of constant value failed + //~^ ERROR explicit panic } fn main() { diff --git a/tests/ui/consts/const-eval/panic-assoc-never-type.stderr b/tests/ui/consts/const-eval/panic-assoc-never-type.stderr index 03413f46b20..64c9f92d5ee 100644 --- a/tests/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/tests/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/panic-assoc-never-type.rs:10:21 | LL | const VOID: ! = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of constant value failed here note: erroneous constant encountered --> $DIR/panic-assoc-never-type.rs:15:13 diff --git a/tests/ui/consts/const-eval/panic-never-type.rs b/tests/ui/consts/const-eval/panic-never-type.rs index a9e9026d9bc..d9b46e70b35 100644 --- a/tests/ui/consts/const-eval/panic-never-type.rs +++ b/tests/ui/consts/const-eval/panic-never-type.rs @@ -2,7 +2,7 @@ #![feature(never_type)] const VOID: ! = panic!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR explicit panic fn main() { let _ = VOID; diff --git a/tests/ui/consts/const-eval/panic-never-type.stderr b/tests/ui/consts/const-eval/panic-never-type.stderr index 1d9bba9aea2..cacce93babe 100644 --- a/tests/ui/consts/const-eval/panic-never-type.stderr +++ b/tests/ui/consts/const-eval/panic-never-type.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/panic-never-type.rs:4:17 | LL | const VOID: ! = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/parse_ints.rs b/tests/ui/consts/const-eval/parse_ints.rs index 309b7ee5d27..409fae9e51d 100644 --- a/tests/ui/consts/const-eval/parse_ints.rs +++ b/tests/ui/consts/const-eval/parse_ints.rs @@ -2,7 +2,7 @@ const _OK: () = match i32::from_str_radix("-1234", 10) { Ok(x) => assert!(x == -1234), Err(_) => panic!(), }; -const _TOO_LOW: () = { u64::from_str_radix("12345ABCD", 1); }; //~ ERROR evaluation of constant value failed -const _TOO_HIGH: () = { u64::from_str_radix("12345ABCD", 37); }; //~ ERROR evaluation of constant value failed +const _TOO_LOW: () = { u64::from_str_radix("12345ABCD", 1); }; //~ ERROR radix must lie in the range `[2, 36]` +const _TOO_HIGH: () = { u64::from_str_radix("12345ABCD", 37); }; //~ ERROR radix must lie in the range `[2, 36]` fn main () {} diff --git a/tests/ui/consts/const-eval/parse_ints.stderr b/tests/ui/consts/const-eval/parse_ints.stderr index 7a855bb9e5c..99aad805a2d 100644 --- a/tests/ui/consts/const-eval/parse_ints.stderr +++ b/tests/ui/consts/const-eval/parse_ints.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: from_ascii_radix: radix must lie in the range `[2, 36]` --> $DIR/parse_ints.rs:5:24 | LL | const _TOO_LOW: () = { u64::from_str_radix("12345ABCD", 1); }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: from_ascii_radix: radix must lie in the range `[2, 36]` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `core::num::<impl u64>::from_str_radix` --> $SRC_DIR/core/src/num/mod.rs:LL:COL @@ -10,11 +10,11 @@ note: inside `core::num::<impl u64>::from_ascii_radix` --> $SRC_DIR/core/src/num/mod.rs:LL:COL = note: this error originates in the macro `from_str_int_impl` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: from_ascii_radix: radix must lie in the range `[2, 36]` --> $DIR/parse_ints.rs:6:25 | LL | const _TOO_HIGH: () = { u64::from_str_radix("12345ABCD", 37); }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: from_ascii_radix: radix must lie in the range `[2, 36]` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `core::num::<impl u64>::from_str_radix` --> $SRC_DIR/core/src/num/mod.rs:LL:COL diff --git a/tests/ui/consts/const-eval/partial_ptr_overwrite.rs b/tests/ui/consts/const-eval/partial_ptr_overwrite.rs index 9438de5e3fe..bd97bec0f71 100644 --- a/tests/ui/consts/const-eval/partial_ptr_overwrite.rs +++ b/tests/ui/consts/const-eval/partial_ptr_overwrite.rs @@ -4,8 +4,7 @@ const PARTIAL_OVERWRITE: () = { let mut p = &42; unsafe { let ptr: *mut _ = &mut p; - *(ptr as *mut u8) = 123; //~ ERROR constant - //~| NOTE unable to overwrite parts of a pointer + *(ptr as *mut u8) = 123; //~ ERROR unable to overwrite parts of a pointer } let x = *p; }; diff --git a/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr b/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr index 1443d353848..4d514495e73 100644 --- a/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr +++ b/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: unable to overwrite parts of a pointer in memory at ALLOC0 --> $DIR/partial_ptr_overwrite.rs:7:9 | LL | *(ptr as *mut u8) = 123; - | ^^^^^^^^^^^^^^^^^^^^^^^ unable to overwrite parts of a pointer in memory at ALLOC0 + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr index 120a08acc33..36183e28921 100644 --- a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr @@ -1,340 +1,340 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered 0x00000001, but expected a valid enum tag --> $DIR/raw-bytes.rs:23:1 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x00000001, but expected a valid enum tag + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 01 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered 0x00000000, but expected a valid enum tag --> $DIR/raw-bytes.rs:31:1 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x00000000, but expected a valid enum tag + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant --> $DIR/raw-bytes.rs:45:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 01 │ . } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant --> $DIR/raw-bytes.rs:47:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 03 │ . } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-variant(Some)>.0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) --> $DIR/raw-bytes.rs:53:1 | LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { 78 00 00 00 ff ff ff ff │ x....... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:58:1 | LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:61:1 | LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 00 │ . } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:63:1 | LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 42, but expected something in the range 10..=30 --> $DIR/raw-bytes.rs:69:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 2a 00 00 00 │ *... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 --> $DIR/raw-bytes.rs:75:1 | LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 14 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:78:1 | LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { 00 00 00 00 ╾ALLOC_ID╼ │ ....╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:86:1 +error[E0080]: constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) + --> $DIR/raw-bytes.rs:85:1 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { ╾ALLOC_ID╼ │ ╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:90:1 +error[E0080]: constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) + --> $DIR/raw-bytes.rs:88:1 | LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { ╾ALLOC_ID╼ │ ╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:94:1 +error[E0080]: constructing invalid value: encountered a null reference + --> $DIR/raw-bytes.rs:91:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:97:1 +error[E0080]: constructing invalid value: encountered a null box + --> $DIR/raw-bytes.rs:94:1 | LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:100:1 +error[E0080]: constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) + --> $DIR/raw-bytes.rs:97:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 39 05 00 00 │ 9... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:103:1 +error[E0080]: constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) + --> $DIR/raw-bytes.rs:100:1 | LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 39 05 00 00 │ 9... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:106:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a function pointer + --> $DIR/raw-bytes.rs:103:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:108:1 +error[E0080]: constructing invalid value: encountered 0xd[noalloc], but expected a function pointer + --> $DIR/raw-bytes.rs:105:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 0d 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:110:1 +error[E0080]: constructing invalid value: encountered ALLOC3<imm>, but expected a function pointer + --> $DIR/raw-bytes.rs:107:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3<imm>, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { ╾ALLOC_ID╼ │ ╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:116:1 +error[E0080]: constructing invalid value: encountered a reference pointing to uninhabited type Bar + --> $DIR/raw-bytes.rs:113:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 01 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:141:1 +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/raw-bytes.rs:137:1 | LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ e7 03 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:143:1 +error[E0080]: constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/raw-bytes.rs:139:1 | LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ff ff ff ff │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:145:1 +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/raw-bytes.rs:141:1 | LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ff ff ff ff │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:148:1 +error[E0080]: constructing invalid value at .<deref>: encountered uninitialized memory, but expected a string + --> $DIR/raw-bytes.rs:144:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized memory, but expected a string + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:150:1 +error[E0080]: constructing invalid value at .<deref>.0: encountered uninitialized memory, but expected a string + --> $DIR/raw-bytes.rs:146:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered uninitialized memory, but expected a string + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:152:1 +error[E0080]: constructing invalid value at .<deref>.0: encountered a pointer, but expected a string + --> $DIR/raw-bytes.rs:148:1 | LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered a pointer, but expected a string + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:156:1 +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/raw-bytes.rs:152:1 | LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ e7 03 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:158:1 +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/raw-bytes.rs:154:1 | LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ff ff ff 7f │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:161:1 +error[E0080]: constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) + --> $DIR/raw-bytes.rs:157:1 | LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ e7 03 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:164:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:160:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { @@ -342,16 +342,16 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:164:40 + --> $DIR/raw-bytes.rs:160:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:170:1 +error[E0080]: constructing invalid value at .<deref>.0: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:164:1 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { @@ -359,16 +359,16 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:170:42 + --> $DIR/raw-bytes.rs:164:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:174:1 +error[E0080]: constructing invalid value at .<deref>.1[0]: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:167:1 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.1[0]: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { @@ -376,196 +376,196 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:174:42 + --> $DIR/raw-bytes.rs:167:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:179:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC17<imm>, but expected a vtable pointer + --> $DIR/raw-bytes.rs:171:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC17<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:183:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC19<imm>, but expected a vtable pointer + --> $DIR/raw-bytes.rs:174:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC19<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:187:1 +error[E0080]: constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer + --> $DIR/raw-bytes.rs:177:1 | LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:190:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC22<imm>, but expected a vtable pointer + --> $DIR/raw-bytes.rs:179:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC22<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:194:1 +error[E0080]: constructing invalid value at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:182:1 | LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:198:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a vtable pointer + --> $DIR/raw-bytes.rs:185:1 | LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 00 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:201:1 +error[E0080]: constructing invalid value: encountered ALLOC27<imm>, but expected a vtable pointer + --> $DIR/raw-bytes.rs:187:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC27<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:206:1 +error[E0080]: constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] + --> $DIR/raw-bytes.rs:191:1 | LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 01 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:207:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered a value of the never type `!` + --> $DIR/raw-bytes.rs:192:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; - | ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!` + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { 01 00 00 00 01 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:208:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered a value of the never type `!` + --> $DIR/raw-bytes.rs:193:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; - | ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!` + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { 01 00 00 00 2a 00 00 00 │ ....*... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:212:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer + --> $DIR/raw-bytes.rs:196:1 | LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:215:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer + --> $DIR/raw-bytes.rs:199:1 | LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:218:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean + --> $DIR/raw-bytes.rs:202:1 | LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:222:1 +error[E0080]: constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer + --> $DIR/raw-bytes.rs:206:1 | LL | pub static S7: &[u16] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID+0x2╼ 04 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:229:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer + --> $DIR/raw-bytes.rs:213:1 | LL | pub static R4: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:234:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer + --> $DIR/raw-bytes.rs:218:1 | LL | pub static R5: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:239:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean + --> $DIR/raw-bytes.rs:223:1 | LL | pub static R6: &[bool] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { diff --git a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr index d54ad7c8546..c53326534fd 100644 --- a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr @@ -1,340 +1,340 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered 0x0000000000000001, but expected a valid enum tag --> $DIR/raw-bytes.rs:23:1 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x0000000000000001, but expected a valid enum tag + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 01 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered 0x0000000000000000, but expected a valid enum tag --> $DIR/raw-bytes.rs:31:1 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x0000000000000000, but expected a valid enum tag + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant --> $DIR/raw-bytes.rs:45:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 01 │ . } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant --> $DIR/raw-bytes.rs:47:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 03 │ . } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-variant(Some)>.0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) --> $DIR/raw-bytes.rs:53:1 | LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { 78 00 00 00 ff ff ff ff │ x....... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:58:1 | LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:61:1 | LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 00 │ . } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:63:1 | LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 42, but expected something in the range 10..=30 --> $DIR/raw-bytes.rs:69:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 2a 00 00 00 │ *... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 --> $DIR/raw-bytes.rs:75:1 | LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 14 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 --> $DIR/raw-bytes.rs:78:1 | LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { 00 00 00 00 00 00 00 00 ╾ALLOC_ID╼ │ ........╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:86:1 +error[E0080]: constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) + --> $DIR/raw-bytes.rs:85:1 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { ╾ALLOC_ID╼ │ ╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:90:1 +error[E0080]: constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) + --> $DIR/raw-bytes.rs:88:1 | LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { ╾ALLOC_ID╼ │ ╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:94:1 +error[E0080]: constructing invalid value: encountered a null reference + --> $DIR/raw-bytes.rs:91:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:97:1 +error[E0080]: constructing invalid value: encountered a null box + --> $DIR/raw-bytes.rs:94:1 | LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:100:1 +error[E0080]: constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) + --> $DIR/raw-bytes.rs:97:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 39 05 00 00 00 00 00 00 │ 9....... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:103:1 +error[E0080]: constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) + --> $DIR/raw-bytes.rs:100:1 | LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 39 05 00 00 00 00 00 00 │ 9....... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:106:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a function pointer + --> $DIR/raw-bytes.rs:103:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:108:1 +error[E0080]: constructing invalid value: encountered 0xd[noalloc], but expected a function pointer + --> $DIR/raw-bytes.rs:105:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 0d 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:110:1 +error[E0080]: constructing invalid value: encountered ALLOC3<imm>, but expected a function pointer + --> $DIR/raw-bytes.rs:107:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3<imm>, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { ╾ALLOC_ID╼ │ ╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:116:1 +error[E0080]: constructing invalid value: encountered a reference pointing to uninhabited type Bar + --> $DIR/raw-bytes.rs:113:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 01 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:141:1 +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/raw-bytes.rs:137:1 | LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:143:1 +error[E0080]: constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/raw-bytes.rs:139:1 | LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ff ff ff ff ff ff ff ff │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:145:1 +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/raw-bytes.rs:141:1 | LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ff ff ff ff ff ff ff ff │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:148:1 +error[E0080]: constructing invalid value at .<deref>: encountered uninitialized memory, but expected a string + --> $DIR/raw-bytes.rs:144:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized memory, but expected a string + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:150:1 +error[E0080]: constructing invalid value at .<deref>.0: encountered uninitialized memory, but expected a string + --> $DIR/raw-bytes.rs:146:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered uninitialized memory, but expected a string + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:152:1 +error[E0080]: constructing invalid value at .<deref>.0: encountered a pointer, but expected a string + --> $DIR/raw-bytes.rs:148:1 | LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered a pointer, but expected a string + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:156:1 +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/raw-bytes.rs:152:1 | LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:158:1 +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/raw-bytes.rs:154:1 | LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ff ff ff ff ff ff ff 7f │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:161:1 +error[E0080]: constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) + --> $DIR/raw-bytes.rs:157:1 | LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:164:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:160:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { @@ -342,16 +342,16 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:164:40 + --> $DIR/raw-bytes.rs:160:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:170:1 +error[E0080]: constructing invalid value at .<deref>.0: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:164:1 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { @@ -359,16 +359,16 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:170:42 + --> $DIR/raw-bytes.rs:164:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:174:1 +error[E0080]: constructing invalid value at .<deref>.1[0]: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:167:1 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.1[0]: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { @@ -376,196 +376,196 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:174:42 + --> $DIR/raw-bytes.rs:167:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:179:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC17<imm>, but expected a vtable pointer + --> $DIR/raw-bytes.rs:171:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC17<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:183:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC19<imm>, but expected a vtable pointer + --> $DIR/raw-bytes.rs:174:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC19<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:187:1 +error[E0080]: constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer + --> $DIR/raw-bytes.rs:177:1 | LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:190:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC22<imm>, but expected a vtable pointer + --> $DIR/raw-bytes.rs:179:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC22<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:194:1 +error[E0080]: constructing invalid value at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:182:1 | LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:198:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a vtable pointer + --> $DIR/raw-bytes.rs:185:1 | LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 00 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:201:1 +error[E0080]: constructing invalid value: encountered ALLOC27<imm>, but expected a vtable pointer + --> $DIR/raw-bytes.rs:187:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC27<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:206:1 +error[E0080]: constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] + --> $DIR/raw-bytes.rs:191:1 | LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 01 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:207:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered a value of the never type `!` + --> $DIR/raw-bytes.rs:192:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; - | ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!` + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 │ ................ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:208:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered a value of the never type `!` + --> $DIR/raw-bytes.rs:193:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; - | ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!` + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { 01 00 00 00 00 00 00 00 2a 00 00 00 00 00 00 00 │ ........*....... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:212:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer + --> $DIR/raw-bytes.rs:196:1 | LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:215:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer + --> $DIR/raw-bytes.rs:199:1 | LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........ } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:218:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean + --> $DIR/raw-bytes.rs:202:1 | LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:222:1 +error[E0080]: constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer + --> $DIR/raw-bytes.rs:206:1 | LL | pub static S7: &[u16] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID+0x2╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:229:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer + --> $DIR/raw-bytes.rs:213:1 | LL | pub static R4: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:234:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer + --> $DIR/raw-bytes.rs:218:1 | LL | pub static R5: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........ } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:239:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean + --> $DIR/raw-bytes.rs:223:1 | LL | pub static R6: &[bool] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { diff --git a/tests/ui/consts/const-eval/raw-bytes.rs b/tests/ui/consts/const-eval/raw-bytes.rs index 1a585d55a5f..58ae763e017 100644 --- a/tests/ui/consts/const-eval/raw-bytes.rs +++ b/tests/ui/consts/const-eval/raw-bytes.rs @@ -21,7 +21,7 @@ enum Enum { A = 0, } const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; -//~^ ERROR is undefined behavior +//~^ ERROR constructing invalid value #[repr(usize)] #[derive(Copy, Clone)] @@ -29,7 +29,7 @@ enum Enum2 { A = 2, } const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; -//~^ ERROR is undefined behavior +//~^ ERROR constructing invalid value #[derive(Copy, Clone)] enum Never {} @@ -43,79 +43,75 @@ enum UninhDiscriminant { D(Never), } const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; -//~^ ERROR is undefined behavior +//~^ ERROR constructing invalid value const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; -//~^ ERROR is undefined behavior +//~^ ERROR constructing invalid value // Invalid enum field content (mostly to test printing of paths for enum tuple // variants and tuples). // Need to create something which does not clash with enum layout optimizations. const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); -//~^ ERROR is undefined behavior +//~^ ERROR constructing invalid value // # Bad pointers and references const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value #[rustc_layout_scalar_valid_range_start(10)] #[rustc_layout_scalar_valid_range_end(30)] struct RestrictedRange1(u32); const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value #[rustc_layout_scalar_valid_range_start(30)] #[rustc_layout_scalar_valid_range_end(10)] struct RestrictedRange2(u32); const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { -//~^ ERROR it is undefined behavior to use this value + //~^ ERROR constructing invalid value let x: &dyn Send = &42; let meta = std::ptr::metadata(x); mem::transmute((0_usize, meta)) }; - const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) +//~^ ERROR constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) +//~^ ERROR constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) const NULL: &u16 = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value #[derive(Copy, Clone)] enum Bar {} const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; -//~^ ERROR it is undefined behavior to use this value - +//~^ ERROR constructing invalid value /// A newtype wrapper to prevent MIR generation from inserting reborrows that would affect the error /// message. @@ -139,105 +135,93 @@ struct MySlice<T: ?Sized>(bool, T); type MySliceBool = MySlice<[bool]>; const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value // # slice const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value // bad slice box: length too big const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value // bad data *inside* the slice const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constant - +//~^ ERROR encountered 0x03, but expected a boolean // bad: sized field is not okay const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constant +//~^ ERROR encountered 0x03, but expected a boolean // bad: unsized part is not okay const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constant +//~^ ERROR encountered 0x03, but expected a boolean // bad trait object const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE expected a vtable +//~^ ERROR expected a vtable // bad trait object const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE expected a vtable +//~^ ERROR expected a vtable // bad trait object const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE expected a vtable +//~^ ERROR expected a vtable const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE expected a vtable +//~^ ERROR expected a vtable // bad data *inside* the trait object const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE expected a boolean +//~^ ERROR expected a boolean const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE null pointer +//~^ ERROR null pointer const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR vtable // Uninhabited types -const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior -const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior -const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; //~ ERROR undefined behavior - +const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR constructing invalid value +const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR constructing invalid value +const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; //~ ERROR constructing invalid value // Reading uninitialized data pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value // Reinterpret pointers as integers (UB in CTFE.) pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value // Layout mismatch pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value // Reading padding is not ok pub static S7: &[u16] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: constructing invalid value let ptr = (&D2 as *const Struct as *const u16).add(1); from_raw_parts(ptr, 4) }; pub static R4: &[u8] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: constructing invalid value let ptr = (&D1) as *const mem::MaybeUninit<&u32> as *const u8; from_ptr_range(ptr..ptr.add(1)) }; pub static R5: &[u8] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: constructing invalid value let ptr = &D3 as *const &u32; from_ptr_range(ptr.cast()..ptr.add(1).cast()) }; pub static R6: &[bool] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: constructing invalid value let ptr = &D0 as *const u32 as *const bool; from_ptr_range(ptr..ptr.add(4)) }; diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.rs b/tests/ui/consts/const-eval/raw-pointer-ub.rs index 1e76104d515..c8d1e36e88b 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.rs +++ b/tests/ui/consts/const-eval/raw-pointer-ub.rs @@ -1,15 +1,15 @@ const MISALIGNED_LOAD: () = unsafe { let mem = [0u32; 8]; let ptr = mem.as_ptr().byte_add(1); - let _val = *ptr; //~ERROR: evaluation of constant value failed - //~^NOTE: based on pointer with alignment 1, but alignment 4 is required + let _val = *ptr; //~NOTE: evaluation of constant value failed + //~^ERROR: based on pointer with alignment 1, but alignment 4 is required }; const MISALIGNED_STORE: () = unsafe { let mut mem = [0u32; 8]; let ptr = mem.as_mut_ptr().byte_add(1); - *ptr = 0; //~ERROR: evaluation of constant value failed - //~^NOTE: based on pointer with alignment 1, but alignment 4 is required + *ptr = 0; //~NOTE: evaluation of constant value failed + //~^ERROR: based on pointer with alignment 1, but alignment 4 is required }; const MISALIGNED_COPY: () = unsafe { @@ -17,9 +17,9 @@ const MISALIGNED_COPY: () = unsafe { let y = x.as_ptr().cast::<u32>(); let mut z = 123; y.copy_to_nonoverlapping(&mut z, 1); - //~^ ERROR evaluation of constant value failed + //~^ NOTE evaluation of constant value failed //~| NOTE inside `std::ptr::copy_nonoverlapping::<u32>` - //~| NOTE accessing memory with alignment 1, but alignment 4 is required + //~| ERROR accessing memory with alignment 1, but alignment 4 is required // The actual error points into the implementation of `copy_to_nonoverlapping`. }; @@ -30,15 +30,15 @@ const MISALIGNED_FIELD: () = unsafe { let mem = [0f32; 8]; let ptr = mem.as_ptr().cast::<Aligned>(); // Accessing an f32 field but we still require the alignment of the pointer type. - let _val = (*ptr).0; //~ERROR: evaluation of constant value failed - //~^NOTE: based on pointer with alignment 4, but alignment 16 is required + let _val = (*ptr).0; //~NOTE: evaluation of constant value failed + //~^ERROR: based on pointer with alignment 4, but alignment 16 is required }; const OOB: () = unsafe { let mem = [0u32; 1]; let ptr = mem.as_ptr().cast::<u64>(); - let _val = *ptr; //~ERROR: evaluation of constant value failed - //~^NOTE: is only 4 bytes from the end of the allocation + let _val = *ptr; //~NOTE: evaluation of constant value failed + //~^ERROR: is only 4 bytes from the end of the allocation }; fn main() {} diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.stderr b/tests/ui/consts/const-eval/raw-pointer-ub.stderr index 01a8decc93b..e424924e14b 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.stderr +++ b/tests/ui/consts/const-eval/raw-pointer-ub.stderr @@ -1,35 +1,35 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required --> $DIR/raw-pointer-ub.rs:4:16 | LL | let _val = *ptr; - | ^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required + | ^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required --> $DIR/raw-pointer-ub.rs:11:5 | LL | *ptr = 0; - | ^^^^^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: accessing memory with alignment 1, but alignment 4 is required --> $DIR/raw-pointer-ub.rs:19:5 | LL | y.copy_to_nonoverlapping(&mut z, 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing memory with alignment 1, but alignment 4 is required + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `std::ptr::copy_nonoverlapping::<u32>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -error[E0080]: evaluation of constant value failed +error[E0080]: accessing memory based on pointer with alignment 4, but alignment 16 is required --> $DIR/raw-pointer-ub.rs:33:16 | LL | let _val = (*ptr).0; - | ^^^^^^^^ accessing memory based on pointer with alignment 4, but alignment 16 is required + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 8 bytes, but got ALLOC0 which is only 4 bytes from the end of the allocation --> $DIR/raw-pointer-ub.rs:40:16 | LL | let _val = *ptr; - | ^^^^ memory access failed: attempting to access 8 bytes, but got ALLOC0 which is only 4 bytes from the end of the allocation + | ^^^^ evaluation of constant value failed here error: aborting due to 5 previous errors diff --git a/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr b/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr index 18935626af1..be86541434b 100644 --- a/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr +++ b/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ref_to_int_match.rs:24:27 | LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; - | ^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr b/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr index 18935626af1..be86541434b 100644 --- a/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr +++ b/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ref_to_int_match.rs:24:27 | LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; - | ^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/const-eval/ref_to_int_match.rs b/tests/ui/consts/const-eval/ref_to_int_match.rs index be9420e0215..062df685f74 100644 --- a/tests/ui/consts/const-eval/ref_to_int_match.rs +++ b/tests/ui/consts/const-eval/ref_to_int_match.rs @@ -3,9 +3,9 @@ fn main() { let n: Int = 40; match n { - 0..=10 => {}, - 10..=BAR => {}, // ok, `const` error already emitted - _ => {}, + 0..=10 => {} + 10..=BAR => {} // ok, `const` error already emitted + _ => {} } } @@ -15,11 +15,11 @@ union Foo { r: &'static u32, } -#[cfg(target_pointer_width="64")] +#[cfg(target_pointer_width = "64")] type Int = u64; -#[cfg(target_pointer_width="32")] +#[cfg(target_pointer_width = "32")] type Int = u32; const BAR: Int = unsafe { Foo { r: &42 }.f }; -//~^ ERROR constant +//~^ ERROR unable to turn pointer into integer diff --git a/tests/ui/consts/const-eval/shift_overflow.stderr b/tests/ui/consts/const-eval/shift_overflow.stderr index 901bfa10ee8..e5703fb1d77 100644 --- a/tests/ui/consts/const-eval/shift_overflow.stderr +++ b/tests/ui/consts/const-eval/shift_overflow.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to shift left by `4294967296_u64`, which would overflow --> $DIR/shift_overflow.rs:3:9 | LL | X = 1 << ((u32::MAX as u64) + 1), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to shift left by `4294967296_u64`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/transmute-const.rs b/tests/ui/consts/const-eval/transmute-const.rs index fb6cb77675f..e67406a6563 100644 --- a/tests/ui/consts/const-eval/transmute-const.rs +++ b/tests/ui/consts/const-eval/transmute-const.rs @@ -2,6 +2,6 @@ use std::mem; static FOO: bool = unsafe { mem::transmute(3u8) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR 0x03, but expected a bool fn main() {} diff --git a/tests/ui/consts/const-eval/transmute-const.stderr b/tests/ui/consts/const-eval/transmute-const.stderr index 35a5cabaa67..ed3b3df70dd 100644 --- a/tests/ui/consts/const-eval/transmute-const.stderr +++ b/tests/ui/consts/const-eval/transmute-const.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0x03, but expected a boolean --> $DIR/transmute-const.rs:4:1 | LL | static FOO: bool = unsafe { mem::transmute(3u8) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { diff --git a/tests/ui/consts/const-eval/transmute-size-mismatch.rs b/tests/ui/consts/const-eval/transmute-size-mismatch.rs index 8a7fd8257b0..ea5cdceda88 100644 --- a/tests/ui/consts/const-eval/transmute-size-mismatch.rs +++ b/tests/ui/consts/const-eval/transmute-size-mismatch.rs @@ -19,10 +19,10 @@ const unsafe fn mir_transmute<T, U>(x: T) -> U { } } -const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) }; //~ ERROR evaluation of constant value failed -//~^ NOTE transmuting from 4-byte type to 2-byte type: `i32` -> `u16` +const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) }; //~ NOTE evaluation of constant value failed +//~^ ERROR transmuting from 4-byte type to 2-byte type: `i32` -> `u16` -const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) }; //~ ERROR evaluation of constant value failed -//~^ NOTE transmuting from 2-byte type to 4-byte type: `i16` -> `u32` +const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) }; //~ NOTE evaluation of constant value failed +//~^ ERROR transmuting from 2-byte type to 4-byte type: `i16` -> `u32` fn main() {} diff --git a/tests/ui/consts/const-eval/transmute-size-mismatch.stderr b/tests/ui/consts/const-eval/transmute-size-mismatch.stderr index 888df16ec4e..92088a4749a 100644 --- a/tests/ui/consts/const-eval/transmute-size-mismatch.stderr +++ b/tests/ui/consts/const-eval/transmute-size-mismatch.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: transmuting from 4-byte type to 2-byte type: `i32` -> `u16` --> $DIR/transmute-size-mismatch.rs:22:35 | LL | const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^ transmuting from 4-byte type to 2-byte type: `i32` -> `u16` + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `mir_transmute::<i32, u16>` --> $DIR/transmute-size-mismatch.rs:12:13 @@ -10,11 +10,11 @@ note: inside `mir_transmute::<i32, u16>` LL | RET = CastTransmute(x); | ^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here -error[E0080]: evaluation of constant value failed +error[E0080]: transmuting from 2-byte type to 4-byte type: `i16` -> `u32` --> $DIR/transmute-size-mismatch.rs:25:36 | LL | const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) }; - | ^^^^^^^^^^^^^^^^^^^^^^ transmuting from 2-byte type to 4-byte type: `i16` -> `u32` + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `mir_transmute::<i16, u32>` --> $DIR/transmute-size-mismatch.rs:12:13 diff --git a/tests/ui/consts/const-eval/ub-enum-overwrite.rs b/tests/ui/consts/const-eval/ub-enum-overwrite.rs index e37c25718f8..005f3c78c1d 100644 --- a/tests/ui/consts/const-eval/ub-enum-overwrite.rs +++ b/tests/ui/consts/const-eval/ub-enum-overwrite.rs @@ -9,8 +9,7 @@ const _: u8 = { // Make sure overwriting `e` uninitializes other bytes e = E::B; unsafe { *p } - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized }; fn main() {} diff --git a/tests/ui/consts/const-eval/ub-enum-overwrite.stderr b/tests/ui/consts/const-eval/ub-enum-overwrite.stderr index 315e865df93..0c1a606904c 100644 --- a/tests/ui/consts/const-eval/ub-enum-overwrite.stderr +++ b/tests/ui/consts/const-eval/ub-enum-overwrite.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/ub-enum-overwrite.rs:11:14 | LL | unsafe { *p } - | ^^ using uninitialized data, but this operation requires initialized memory + | ^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/ub-enum.rs b/tests/ui/consts/const-eval/ub-enum.rs index ac543430da9..52fc9945068 100644 --- a/tests/ui/consts/const-eval/ub-enum.rs +++ b/tests/ui/consts/const-eval/ub-enum.rs @@ -27,13 +27,13 @@ enum Enum { const GOOD_ENUM: Enum = unsafe { mem::transmute(0usize) }; const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; -//~^ ERROR is undefined behavior +//~^ ERROR expected a valid enum tag const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // # simple enum with discriminant 2 @@ -45,12 +45,12 @@ enum Enum2 { } const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; -//~^ ERROR is undefined behavior +//~^ ERROR expected a valid enum tag const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // something wrapping the enum so that we test layout first, not enum const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // Undef enum discriminant. #[repr(C)] @@ -58,13 +58,12 @@ union MaybeUninit<T: Copy> { uninit: (), init: T, } -const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +const BAD_ENUM2_UNDEF: Enum2 = unsafe { MaybeUninit { uninit: () }.init }; +//~^ ERROR uninitialized // Pointer value in an enum with a niche that is not just 0. const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // # valid discriminant for uninhabited variant @@ -81,9 +80,9 @@ const GOOD_INHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(0u8) const GOOD_INHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(2u8) }; // variant C const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; -//~^ ERROR is undefined behavior +//~^ ERROR uninhabited enum variant const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; -//~^ ERROR is undefined behavior +//~^ ERROR uninhabited enum variant // # other @@ -91,20 +90,21 @@ const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) // variants and tuples). // Need to create something which does not clash with enum layout optimizations. const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); -//~^ ERROR is undefined behavior +//~^ ERROR expected a valid unicode scalar // All variants are uninhabited but also have data. // Use `0` as constant to make behavior endianness-independent. const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR uninhabited enum variant const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR uninhabited enum variant const TEST_ICE_89765: () = { // This is a regression test for https://github.com/rust-lang/rust/issues/89765. - unsafe { std::mem::discriminant(&*(&() as *const () as *const Never)); }; - //~^ ERROR evaluation of constant value failed + unsafe { + std::mem::discriminant(&*(&() as *const () as *const Never)); + //~^ ERROR uninhabited enum variant + }; }; -fn main() { -} +fn main() {} diff --git a/tests/ui/consts/const-eval/ub-enum.stderr b/tests/ui/consts/const-eval/ub-enum.stderr index faec412b004..7015102a50a 100644 --- a/tests/ui/consts/const-eval/ub-enum.stderr +++ b/tests/ui/consts/const-eval/ub-enum.stderr @@ -1,126 +1,126 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered 0x01, but expected a valid enum tag --> $DIR/ub-enum.rs:29:1 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x01, but expected a valid enum tag + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ub-enum.rs:32:1 | LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ub-enum.rs:35:1 | LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered 0x0, but expected a valid enum tag --> $DIR/ub-enum.rs:47:1 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x0, but expected a valid enum tag + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ub-enum.rs:49:1 | LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ub-enum.rs:52:1 | LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:61:42 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/ub-enum.rs:61:41 | -LL | const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory +LL | const BAD_ENUM2_UNDEF: Enum2 = unsafe { MaybeUninit { uninit: () }.init }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:66:1 +error[E0080]: unable to turn pointer into integer + --> $DIR/ub-enum.rs:65:1 | LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:83:1 +error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + --> $DIR/ub-enum.rs:82:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:85:1 +error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + --> $DIR/ub-enum.rs:84:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:93:1 +error[E0080]: constructing invalid value at .<enum-variant(Some)>.0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) + --> $DIR/ub-enum.rs:92:1 | LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:98:77 +error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + --> $DIR/ub-enum.rs:97:77 | LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:100:77 +error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + --> $DIR/ub-enum.rs:99:77 | LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:105:14 +error[E0080]: read discriminant of an uninhabited enum variant + --> $DIR/ub-enum.rs:105:9 | -LL | unsafe { std::mem::discriminant(&*(&() as *const () as *const Never)); }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ read discriminant of an uninhabited enum variant +LL | std::mem::discriminant(&*(&() as *const () as *const Never)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `discriminant::<Never>` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL diff --git a/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr b/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr index 5c47cbfdf3b..86d6f8c52bc 100644 --- a/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr @@ -1,63 +1,63 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered ALLOC1<imm>, but expected a vtable pointer --> $DIR/ub-incorrect-vtable.rs:18:1 | LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC1<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC0<imm>╼ ╾ALLOC1<imm>╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:23:1 +error[E0080]: constructing invalid value: encountered ALLOC3<imm>, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:22:1 | LL | const INVALID_VTABLE_SIZE: &dyn Trait = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC2<imm>╼ ╾ALLOC3<imm>╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:33:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC5<imm>, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:31:1 | LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC5<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC4<imm>╼ ╾ALLOC5<imm>╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:38:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC7<imm>, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:35:1 | LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC7<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC6<imm>╼ ╾ALLOC7<imm>╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:44:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC9<imm>, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:40:1 | LL | const INVALID_VTABLE_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC9<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC8<imm>╼ ╾ALLOC9<imm>╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:91:1 +error[E0080]: constructing invalid value at .1: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/ub-incorrect-vtable.rs:86:1 | LL | const G: Wide = unsafe { Transmute { t: FOO }.u }; - | ^^^^^^^^^^^^^ constructing invalid value at .1: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { diff --git a/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr b/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr index f400073aca2..a9518216dbd 100644 --- a/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr +++ b/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr @@ -1,63 +1,63 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered ALLOC1<imm>, but expected a vtable pointer --> $DIR/ub-incorrect-vtable.rs:18:1 | LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC1<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC0<imm>╼ ╾ALLOC1<imm>╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:23:1 +error[E0080]: constructing invalid value: encountered ALLOC3<imm>, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:22:1 | LL | const INVALID_VTABLE_SIZE: &dyn Trait = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC2<imm>╼ ╾ALLOC3<imm>╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:33:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC5<imm>, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:31:1 | LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC5<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC4<imm>╼ ╾ALLOC5<imm>╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:38:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC7<imm>, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:35:1 | LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC7<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC6<imm>╼ ╾ALLOC7<imm>╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:44:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC9<imm>, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:40:1 | LL | const INVALID_VTABLE_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC9<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC8<imm>╼ ╾ALLOC9<imm>╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:91:1 +error[E0080]: constructing invalid value at .1: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/ub-incorrect-vtable.rs:86:1 | LL | const G: Wide = unsafe { Transmute { t: FOO }.u }; - | ^^^^^^^^^^^^^ constructing invalid value at .1: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { diff --git a/tests/ui/consts/const-eval/ub-incorrect-vtable.rs b/tests/ui/consts/const-eval/ub-incorrect-vtable.rs index 30c0ae3bb5a..4185b0261b2 100644 --- a/tests/ui/consts/const-eval/ub-incorrect-vtable.rs +++ b/tests/ui/consts/const-eval/ub-incorrect-vtable.rs @@ -17,13 +17,11 @@ trait Trait {} const INVALID_VTABLE_ALIGNMENT: &dyn Trait = unsafe { std::mem::transmute((&92u8, &[0usize, 1usize, 1000usize])) }; -//~^^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^^ ERROR vtable const INVALID_VTABLE_SIZE: &dyn Trait = unsafe { std::mem::transmute((&92u8, &[1usize, usize::MAX, 1usize])) }; -//~^^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^^ ERROR vtable #[repr(transparent)] struct W<T>(T); @@ -32,19 +30,16 @@ fn drop_me(_: *mut usize) {} const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), 1usize, 1000usize))) }; -//~^^ ERROR it is undefined behavior to use this value -//~| NOTE expected a vtable pointer +//~^^ ERROR expected a vtable pointer const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), usize::MAX, 1usize))) }; -//~^^ ERROR it is undefined behavior to use this value -//~| NOTE expected a vtable pointer +//~^^ ERROR expected a vtable pointer // Even if the vtable has a fn ptr and a reasonable size+align, it still does not work. const INVALID_VTABLE_UB: W<&dyn Trait> = unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), 1usize, 1usize))) }; -//~^^ ERROR it is undefined behavior to use this value -//~| NOTE expected a vtable pointer +//~^^ ERROR expected a vtable pointer // Trying to access the data in a vtable does not work, either. @@ -89,8 +84,7 @@ union Transmute<T: Copy, U: Copy> { const FOO: &dyn Bar = &Foo { foo: 128, bar: false }; const G: Wide = unsafe { Transmute { t: FOO }.u }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE encountered a dangling reference +//~^ ERROR encountered a dangling reference // (it is dangling because vtables do not contain memory that can be dereferenced) fn main() {} diff --git a/tests/ui/consts/const-eval/ub-int-array.rs b/tests/ui/consts/const-eval/ub-int-array.rs index 169ac7f1519..eebbccaa7c1 100644 --- a/tests/ui/consts/const-eval/ub-int-array.rs +++ b/tests/ui/consts/const-eval/ub-int-array.rs @@ -18,8 +18,7 @@ impl<T: Copy> MaybeUninit<T> { } const UNINIT_INT_0: [u32; 3] = unsafe { - //~^ ERROR it is undefined behavior to use this value - //~| NOTE invalid value at [0] + //~^ ERROR invalid value at [0] mem::transmute([ MaybeUninit { uninit: () }, // Constants chosen to achieve endianness-independent hex dump. @@ -28,8 +27,7 @@ const UNINIT_INT_0: [u32; 3] = unsafe { ]) }; const UNINIT_INT_1: [u32; 3] = unsafe { - //~^ ERROR it is undefined behavior to use this value - //~| NOTE invalid value at [1] + //~^ ERROR invalid value at [1] mem::transmute([ MaybeUninit::new(0u8), MaybeUninit::new(0u8), @@ -46,8 +44,7 @@ const UNINIT_INT_1: [u32; 3] = unsafe { ]) }; const UNINIT_INT_2: [u32; 3] = unsafe { - //~^ ERROR it is undefined behavior to use this value - //~| NOTE invalid value at [2] + //~^ ERROR invalid value at [2] mem::transmute([ MaybeUninit::new(0u8), MaybeUninit::new(0u8), diff --git a/tests/ui/consts/const-eval/ub-int-array.stderr b/tests/ui/consts/const-eval/ub-int-array.stderr index d6ef9bcfeba..10eb7c46c92 100644 --- a/tests/ui/consts/const-eval/ub-int-array.stderr +++ b/tests/ui/consts/const-eval/ub-int-array.stderr @@ -1,30 +1,30 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at [0]: encountered uninitialized memory, but expected an integer --> $DIR/ub-int-array.rs:20:1 | LL | const UNINIT_INT_0: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 12, align: 4) { __ __ __ __ 11 11 11 11 22 22 22 22 │ ░░░░...."""" } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:30:1 +error[E0080]: constructing invalid value at [1]: encountered uninitialized memory, but expected an integer + --> $DIR/ub-int-array.rs:29:1 | LL | const UNINIT_INT_1: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [1]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 12, align: 4) { 00 00 00 00 01 __ 01 01 02 02 __ 02 │ .....░....░. } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:48:1 +error[E0080]: constructing invalid value at [2]: encountered uninitialized memory, but expected an integer + --> $DIR/ub-int-array.rs:46:1 | LL | const UNINIT_INT_2: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [2]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 12, align: 4) { diff --git a/tests/ui/consts/const-eval/ub-invalid-values.rs b/tests/ui/consts/const-eval/ub-invalid-values.rs index c0b68d7619a..e5d387fa7cc 100644 --- a/tests/ui/consts/const-eval/ub-invalid-values.rs +++ b/tests/ui/consts/const-eval/ub-invalid-values.rs @@ -5,8 +5,8 @@ const fn bool_cast(ptr: *const bool) { unsafe { const _: () = { let v = 3_u8; - bool_cast(&v as *const u8 as *const bool); //~ ERROR: evaluation of constant value failed - //~^ NOTE interpreting an invalid 8-bit value as a bool + bool_cast(&v as *const u8 as *const bool); //~ NOTE: evaluation of constant value failed + //~^ ERROR interpreting an invalid 8-bit value as a bool }; fn main() {} diff --git a/tests/ui/consts/const-eval/ub-invalid-values.stderr b/tests/ui/consts/const-eval/ub-invalid-values.stderr index 76952c1f1a3..83879eeb716 100644 --- a/tests/ui/consts/const-eval/ub-invalid-values.stderr +++ b/tests/ui/consts/const-eval/ub-invalid-values.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: interpreting an invalid 8-bit value as a bool: 0x03 --> $DIR/ub-invalid-values.rs:8:5 | LL | bool_cast(&v as *const u8 as *const bool); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ interpreting an invalid 8-bit value as a bool: 0x03 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | note: inside `bool_cast` --> $DIR/ub-invalid-values.rs:2:16 diff --git a/tests/ui/consts/const-eval/ub-nonnull.rs b/tests/ui/consts/const-eval/ub-nonnull.rs index 8ae913db1e4..91646842624 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.rs +++ b/tests/ui/consts/const-eval/ub-nonnull.rs @@ -14,19 +14,19 @@ const NON_NULL: NonNull<u8> = unsafe { mem::transmute(1usize) }; const NON_NULL_PTR: NonNull<u8> = unsafe { mem::transmute(&1) }; const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const OUT_OF_BOUNDS_PTR: NonNull<u8> = { unsafe { let ptr: &[u8; 256] = mem::transmute(&0u8); // &0 gets promoted so it does not dangle // Use address-of-element for pointer arithmetic. This could wrap around to null! - let out_of_bounds_ptr = &ptr[255]; //~ ERROR evaluation of constant value failed + let out_of_bounds_ptr = &ptr[255]; //~ ERROR in-bounds pointer arithmetic failed mem::transmute(out_of_bounds_ptr) } }; const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value #[repr(C)] union MaybeUninit<T: Copy> { @@ -34,8 +34,7 @@ union MaybeUninit<T: Copy> { init: T, } const UNINIT: NonZero<u8> = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +//~^ ERROR uninitialized // Also test other uses of rustc_layout_scalar_valid_range_start @@ -43,16 +42,16 @@ const UNINIT: NonZero<u8> = unsafe { MaybeUninit { uninit: () }.init }; #[rustc_layout_scalar_valid_range_end(30)] struct RestrictedRange1(u32); const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value #[rustc_layout_scalar_valid_range_start(30)] #[rustc_layout_scalar_valid_range_end(10)] struct RestrictedRange2(u32); const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value let x: &dyn Send = &42; let meta = std::ptr::metadata(x); mem::transmute((0_usize, meta)) diff --git a/tests/ui/consts/const-eval/ub-nonnull.stderr b/tests/ui/consts/const-eval/ub-nonnull.stderr index 75dd0443ca4..0a02dbb16bf 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.stderr +++ b/tests/ui/consts/const-eval/ub-nonnull.stderr @@ -1,75 +1,75 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 --> $DIR/ub-nonnull.rs:16:1 | LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 255 bytes, but got ALLOC1 which is only 1 byte from the end of the allocation --> $DIR/ub-nonnull.rs:22:29 | LL | let out_of_bounds_ptr = &ptr[255]; - | ^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 255 bytes, but got ALLOC1 which is only 1 byte from the end of the allocation + | ^^^^^^^^^ evaluation of constant value failed here -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/ub-nonnull.rs:26:1 | LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/ub-nonnull.rs:28:1 | LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/ub-nonnull.rs:36:38 | LL | const UNINIT: NonZero<u8> = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:45:1 +error[E0080]: constructing invalid value: encountered 42, but expected something in the range 10..=30 + --> $DIR/ub-nonnull.rs:44:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:51:1 +error[E0080]: constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 + --> $DIR/ub-nonnull.rs:50:1 | LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:54:1 +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 + --> $DIR/ub-nonnull.rs:53:1 | LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.rs b/tests/ui/consts/const-eval/ub-ref-ptr.rs index 988e6c62e34..64b48939be6 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.rs +++ b/tests/ui/consts/const-eval/ub-ref-ptr.rs @@ -15,57 +15,53 @@ union MaybeUninit<T: Copy> { } const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) +//~^ ERROR constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) +//~^ ERROR constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) const NULL: &u16 = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value // It is very important that we reject this: We do promote `&(4 * REF_AS_USIZE)`, // but that would fail to compile; so we ended up breaking user code that would // have worked fine had we not promoted. const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +//~^ ERROR uninitialized const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +//~^ ERROR uninitialized const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const UNALIGNED_READ: () = unsafe { let x = &[0u8; 4]; let ptr = x.as_ptr().cast::<u32>(); - ptr.read(); //~ ERROR evaluation of constant value failed + ptr.read(); //~ ERROR accessing memory }; diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr index cfec1a42f28..e10f21b02af 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr @@ -1,158 +1,158 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) --> $DIR/ub-ref-ptr.rs:17:1 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:21:1 +error[E0080]: constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) + --> $DIR/ub-ref-ptr.rs:20:1 | LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:25:1 +error[E0080]: constructing invalid value: encountered a null reference + --> $DIR/ub-ref-ptr.rs:23:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:28:1 +error[E0080]: constructing invalid value: encountered a null box + --> $DIR/ub-ref-ptr.rs:26:1 | LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:35:1 +error[E0080]: unable to turn pointer into integer + --> $DIR/ub-ref-ptr.rs:33:1 | LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:38:39 +error[E0080]: unable to turn pointer into integer + --> $DIR/ub-ref-ptr.rs:36:39 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported note: erroneous constant encountered - --> $DIR/ub-ref-ptr.rs:38:38 + --> $DIR/ub-ref-ptr.rs:36:38 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:41:86 +error[E0080]: unable to turn pointer into integer + --> $DIR/ub-ref-ptr.rs:39:86 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported note: erroneous constant encountered - --> $DIR/ub-ref-ptr.rs:41:85 + --> $DIR/ub-ref-ptr.rs:39:85 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; | ^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:44:1 +error[E0080]: constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) + --> $DIR/ub-ref-ptr.rs:42:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:47:1 +error[E0080]: constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) + --> $DIR/ub-ref-ptr.rs:45:1 | LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:50:41 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/ub-ref-ptr.rs:48:41 | LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:54:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a function pointer + --> $DIR/ub-ref-ptr.rs:51:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:56:38 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/ub-ref-ptr.rs:53:38 | LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:59:1 +error[E0080]: constructing invalid value: encountered 0xd[noalloc], but expected a function pointer + --> $DIR/ub-ref-ptr.rs:55:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:61:1 +error[E0080]: constructing invalid value: encountered ALLOC2<imm>, but expected a function pointer + --> $DIR/ub-ref-ptr.rs:57:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC2<imm>, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:68:5 +error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required + --> $DIR/ub-ref-ptr.rs:64:5 | LL | ptr.read(); - | ^^^^^^^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required + | ^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 15 previous errors diff --git a/tests/ui/consts/const-eval/ub-uninhabit.rs b/tests/ui/consts/const-eval/ub-uninhabit.rs index 3a5e291d5df..188ad768a0e 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.rs +++ b/tests/ui/consts/const-eval/ub-uninhabit.rs @@ -6,8 +6,7 @@ #![feature(core_intrinsics)] #![feature(never_type)] -use std::intrinsics; -use std::mem; +use std::{intrinsics, mem}; #[derive(Copy, Clone)] enum Bar {} @@ -19,25 +18,19 @@ union MaybeUninit<T: Copy> { } const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR evaluation of constant value failed -//~| NOTE constructing invalid value +//~^ ERROR constructing invalid value const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constructing invalid value +//~^ ERROR constructing invalid value const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR evaluation of constant value failed -//~| NOTE constructing invalid value - +//~^ ERROR constructing invalid value const READ_NEVER: () = unsafe { let mem = [0u32; 8]; let ptr = mem.as_ptr().cast::<!>(); let _val = intrinsics::read_via_copy(ptr); - //~^ ERROR evaluation of constant value failed - //~| NOTE constructing invalid value + //~^ ERROR constructing invalid value }; - fn main() {} diff --git a/tests/ui/consts/const-eval/ub-uninhabit.stderr b/tests/ui/consts/const-eval/ub-uninhabit.stderr index 9d3f93279e5..582a7a07be9 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.stderr +++ b/tests/ui/consts/const-eval/ub-uninhabit.stderr @@ -1,31 +1,31 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/ub-uninhabit.rs:21:35 +error[E0080]: constructing invalid value: encountered a value of uninhabited type `Bar` + --> $DIR/ub-uninhabit.rs:20:35 | LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type `Bar` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:25:1 +error[E0080]: constructing invalid value: encountered a reference pointing to uninhabited type Bar + --> $DIR/ub-uninhabit.rs:23:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-uninhabit.rs:29:42 +error[E0080]: constructing invalid value at [0]: encountered a value of uninhabited type `Bar` + --> $DIR/ub-uninhabit.rs:26:42 | LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type `Bar` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/ub-uninhabit.rs:37:16 +error[E0080]: constructing invalid value: encountered a value of the never type `!` + --> $DIR/ub-uninhabit.rs:32:16 | LL | let _val = intrinsics::read_via_copy(ptr); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of the never type `!` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 4 previous errors diff --git a/tests/ui/consts/const-eval/ub-upvars.32bit.stderr b/tests/ui/consts/const-eval/ub-upvars.32bit.stderr index 5342fea66bd..ecd1c768c28 100644 --- a/tests/ui/consts/const-eval/ub-upvars.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-upvars.32bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>.<dyn-downcast>.<captured-var(bad_ref)>: encountered a null reference --> $DIR/ub-upvars.rs:6:1 | LL | const BAD_UPVAR: &dyn FnOnce() = &{ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>.<captured-var(bad_ref)>: encountered a null reference + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { diff --git a/tests/ui/consts/const-eval/ub-upvars.64bit.stderr b/tests/ui/consts/const-eval/ub-upvars.64bit.stderr index a2496dfc287..108dfe6b27b 100644 --- a/tests/ui/consts/const-eval/ub-upvars.64bit.stderr +++ b/tests/ui/consts/const-eval/ub-upvars.64bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>.<dyn-downcast>.<captured-var(bad_ref)>: encountered a null reference --> $DIR/ub-upvars.rs:6:1 | LL | const BAD_UPVAR: &dyn FnOnce() = &{ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>.<captured-var(bad_ref)>: encountered a null reference + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { diff --git a/tests/ui/consts/const-eval/ub-upvars.rs b/tests/ui/consts/const-eval/ub-upvars.rs index 817511180be..19722282984 100644 --- a/tests/ui/consts/const-eval/ub-upvars.rs +++ b/tests/ui/consts/const-eval/ub-upvars.rs @@ -3,7 +3,7 @@ use std::mem; -const BAD_UPVAR: &dyn FnOnce() = &{ //~ ERROR it is undefined behavior to use this value +const BAD_UPVAR: &dyn FnOnce() = &{ //~ ERROR null reference let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) }; let another_var = 13; move || { let _ = bad_ref; let _ = another_var; } diff --git a/tests/ui/consts/const-eval/ub-wide-ptr.rs b/tests/ui/consts/const-eval/ub-wide-ptr.rs index 4b9bbb8066d..86235897e7e 100644 --- a/tests/ui/consts/const-eval/ub-wide-ptr.rs +++ b/tests/ui/consts/const-eval/ub-wide-ptr.rs @@ -37,74 +37,69 @@ type MySliceBool = MySlice<[bool]>; const STR_VALID: &str = unsafe { mem::transmute((&42u8, 1usize)) }; // bad str const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR encountered a dangling reference (going beyond the bounds of its allocation) const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR slice is bigger than largest supported object // bad str const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // bad str in user-defined unsized type const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR slice is bigger than largest supported object // uninitialized byte const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR uninitialized memory, but expected a string // uninitialized byte in user-defined str-like const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR uninitialized memory, but expected a string // # slice // OK const SLICE_VALID: &[u8] = unsafe { mem::transmute((&42u8, 1usize)) }; // bad slice: length uninit const SLICE_LENGTH_UNINIT: &[u8] = unsafe { -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +//~^ ERROR uninitialized let uninit_len = MaybeUninit::<usize> { uninit: () }; mem::transmute((42, uninit_len)) }; // bad slice: length too big const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR dangling reference (going beyond the bounds of its allocation) // bad slice: length computation overflows const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR slice is bigger than largest supported object // bad slice: length not an int const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // bad slice box: length too big const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR dangling box (going beyond the bounds of its allocation) // bad slice box: length not an int const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // bad data *inside* the slice const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constant +//~^ ERROR 0x03, but expected a boolean // good MySliceBool const MYSLICE_GOOD: &MySliceBool = &MySlice(true, [false]); // bad: sized field is not okay const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constant +//~^ ERROR 0x03, but expected a boolean // bad: unsized part is not okay const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constant +//~^ ERROR 0x03, but expected a boolean // # raw slice const RAW_SLICE_VALID: *const [u8] = unsafe { mem::transmute((&42u8, 1usize)) }; // ok const RAW_SLICE_TOO_LONG: *const [u8] = unsafe { mem::transmute((&42u8, 999usize)) }; // ok because raw const RAW_SLICE_MUCH_TOO_LONG: *const [u8] = unsafe { mem::transmute((&42u8, usize::MAX)) }; // ok because raw const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +//~^ ERROR uninitialized let uninit_len = MaybeUninit::<usize> { uninit: () }; mem::transmute((42, uninit_len)) }; @@ -112,41 +107,31 @@ const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { // # trait object // bad trait object const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR vtable // bad trait object const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR vtable // bad trait object const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR vtable const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR vtable const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR vtable const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR vtable const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR vtable // bad data *inside* the trait object const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE expected a boolean +//~^ ERROR expected a boolean // # raw trait object const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE null pointer +//~^ ERROR null pointer const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR vtable const RAW_TRAIT_OBJ_CONTENT_INVALID: *const dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) } as *const dyn Trait; // ok because raw // Officially blessed way to get the vtable const DYN_METADATA: ptr::DynMetadata<dyn Send> = ptr::metadata::<dyn Send>(ptr::null::<i32>()); @@ -154,13 +139,11 @@ const DYN_METADATA: ptr::DynMetadata<dyn Send> = ptr::metadata::<dyn Send>(ptr:: static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe { mem::transmute::<_, &dyn Trait>((&92u8, 0usize)) - //~^^ ERROR it is undefined behavior to use this value - //~| NOTE null pointer + //~^^ ERROR null pointer }; static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = unsafe { mem::transmute::<_, &dyn Trait>((&92u8, &3u64)) - //~^^ ERROR it is undefined behavior to use this value - //~| NOTE vtable + //~^^ ERROR vtable }; fn main() {} diff --git a/tests/ui/consts/const-eval/ub-wide-ptr.stderr b/tests/ui/consts/const-eval/ub-wide-ptr.stderr index 92f0029a5b3..a586f154ca1 100644 --- a/tests/ui/consts/const-eval/ub-wide-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-wide-ptr.stderr @@ -1,138 +1,138 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) --> $DIR/ub-wide-ptr.rs:39:1 | LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object --> $DIR/ub-wide-ptr.rs:41:1 | LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ub-wide-ptr.rs:44:1 | LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ub-wide-ptr.rs:47:1 | LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object --> $DIR/ub-wide-ptr.rs:49:1 | LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>: encountered uninitialized memory, but expected a string --> $DIR/ub-wide-ptr.rs:53:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized memory, but expected a string + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>.0: encountered uninitialized memory, but expected a string --> $DIR/ub-wide-ptr.rs:56:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered uninitialized memory, but expected a string + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/ub-wide-ptr.rs:63:1 | LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:70:1 +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/ub-wide-ptr.rs:69:1 | LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:73:1 +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/ub-wide-ptr.rs:72:1 | LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:76:1 +error[E0080]: unable to turn pointer into integer + --> $DIR/ub-wide-ptr.rs:75:1 | LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:79:1 +error[E0080]: constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) + --> $DIR/ub-wide-ptr.rs:78:1 | LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:82:1 +error[E0080]: unable to turn pointer into integer + --> $DIR/ub-wide-ptr.rs:81:1 | LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:86:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean + --> $DIR/ub-wide-ptr.rs:85:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -140,16 +140,16 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; } note: erroneous constant encountered - --> $DIR/ub-wide-ptr.rs:86:40 + --> $DIR/ub-wide-ptr.rs:85:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:93:1 +error[E0080]: constructing invalid value at .<deref>.0: encountered 0x03, but expected a boolean + --> $DIR/ub-wide-ptr.rs:91:1 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -157,16 +157,16 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 } note: erroneous constant encountered - --> $DIR/ub-wide-ptr.rs:93:42 + --> $DIR/ub-wide-ptr.rs:91:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:97:1 +error[E0080]: constructing invalid value at .<deref>.1[0]: encountered 0x03, but expected a boolean + --> $DIR/ub-wide-ptr.rs:94:1 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.1[0]: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -174,143 +174,143 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran } note: erroneous constant encountered - --> $DIR/ub-wide-ptr.rs:97:42 + --> $DIR/ub-wide-ptr.rs:94:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:105:1 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/ub-wide-ptr.rs:101:1 | LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:114:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC12<imm>, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:109:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC12<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:118:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC14<imm>, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:112:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC14<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:122:1 +error[E0080]: constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:115:1 | LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:125:1 +error[E0080]: constructing invalid value: encountered ALLOC17<imm>, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:117:1 | LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC17<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:128:1 +error[E0080]: constructing invalid value: encountered ALLOC19<imm>, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:119:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC19<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:131:1 +error[E0080]: constructing invalid value: encountered ALLOC21<imm>, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:121:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC21<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:134:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC23<imm>, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:123:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC23<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:139:1 +error[E0080]: constructing invalid value at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean + --> $DIR/ub-wide-ptr.rs:127:1 | LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:144:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:131:1 | LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:147:1 +error[E0080]: constructing invalid value: encountered ALLOC28<imm>, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:133:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC28<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:155:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:140:1 | LL | static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:160:1 +error[E0080]: constructing invalid value: encountered ALLOC31<imm>, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:144:1 | LL | static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC31<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/consts/const-eval/ub-write-through-immutable.rs b/tests/ui/consts/const-eval/ub-write-through-immutable.rs index 795ac602a1c..28c7a617a4d 100644 --- a/tests/ui/consts/const-eval/ub-write-through-immutable.rs +++ b/tests/ui/consts/const-eval/ub-write-through-immutable.rs @@ -1,21 +1,19 @@ //! Ensure we catch UB due to writing through a shared reference. #![allow(invalid_reference_casting)] -use std::mem; use std::cell::UnsafeCell; +use std::mem; const WRITE_AFTER_CAST: () = unsafe { let mut x = 0; let ptr = &x as *const i32 as *mut i32; - *ptr = 0; //~ERROR: evaluation of constant value failed - //~| NOTE immutable + *ptr = 0; //~ERROR: immutable }; const WRITE_AFTER_TRANSMUTE: () = unsafe { let mut x = 0; let ptr: *mut i32 = mem::transmute(&x); - *ptr = 0; //~ERROR: evaluation of constant value failed - //~| NOTE immutable + *ptr = 0; //~ERROR: immutable }; // it's okay when there is interior mutability; diff --git a/tests/ui/consts/const-eval/ub-write-through-immutable.stderr b/tests/ui/consts/const-eval/ub-write-through-immutable.stderr index d30df33bc55..dbcd07110cc 100644 --- a/tests/ui/consts/const-eval/ub-write-through-immutable.stderr +++ b/tests/ui/consts/const-eval/ub-write-through-immutable.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: writing through a pointer that was derived from a shared (immutable) reference --> $DIR/ub-write-through-immutable.rs:10:5 | LL | *ptr = 0; - | ^^^^^^^^ writing through a pointer that was derived from a shared (immutable) reference + | ^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/ub-write-through-immutable.rs:17:5 +error[E0080]: writing through a pointer that was derived from a shared (immutable) reference + --> $DIR/ub-write-through-immutable.rs:16:5 | LL | *ptr = 0; - | ^^^^^^^^ writing through a pointer that was derived from a shared (immutable) reference + | ^^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/union-const-eval-field.rs b/tests/ui/consts/const-eval/union-const-eval-field.rs index 55e9abe72e0..0ad94eee7f4 100644 --- a/tests/ui/consts/const-eval/union-const-eval-field.rs +++ b/tests/ui/consts/const-eval/union-const-eval-field.rs @@ -26,8 +26,7 @@ const fn read_field2() -> Field2 { const fn read_field3() -> Field3 { const FIELD3: Field3 = unsafe { UNION.field3 }; - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized FIELD3 } diff --git a/tests/ui/consts/const-eval/union-const-eval-field.stderr b/tests/ui/consts/const-eval/union-const-eval-field.stderr index 4fd6b80381c..eb3906a4ecc 100644 --- a/tests/ui/consts/const-eval/union-const-eval-field.stderr +++ b/tests/ui/consts/const-eval/union-const-eval-field.stderr @@ -1,17 +1,17 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/union-const-eval-field.rs:28:37 | LL | const FIELD3: Field3 = unsafe { UNION.field3 }; - | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^ evaluation of constant value failed here note: erroneous constant encountered - --> $DIR/union-const-eval-field.rs:31:5 + --> $DIR/union-const-eval-field.rs:30:5 | LL | FIELD3 | ^^^^^^ note: erroneous constant encountered - --> $DIR/union-const-eval-field.rs:31:5 + --> $DIR/union-const-eval-field.rs:30:5 | LL | FIELD3 | ^^^^^^ diff --git a/tests/ui/consts/const-eval/union-ice.rs b/tests/ui/consts/const-eval/union-ice.rs index 8ce5f6d89a8..7a4909e8ce2 100644 --- a/tests/ui/consts/const-eval/union-ice.rs +++ b/tests/ui/consts/const-eval/union-ice.rs @@ -12,14 +12,12 @@ union DummyUnion { const UNION: DummyUnion = DummyUnion { field1: 1065353216 }; const FIELD3: Field3 = unsafe { UNION.field3 }; -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +//~^ ERROR uninitialized const FIELD_PATH: Struct = Struct { a: 42, b: unsafe { UNION.field3 }, - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized }; struct Struct { @@ -31,8 +29,7 @@ const FIELD_PATH2: Struct2 = Struct2 { b: [ 21, unsafe { UNION.field3 }, - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized 23, 24, ], @@ -44,5 +41,4 @@ struct Struct2 { a: u8, } -fn main() { -} +fn main() {} diff --git a/tests/ui/consts/const-eval/union-ice.stderr b/tests/ui/consts/const-eval/union-ice.stderr index bd39a05510b..86c42713095 100644 --- a/tests/ui/consts/const-eval/union-ice.stderr +++ b/tests/ui/consts/const-eval/union-ice.stderr @@ -1,20 +1,20 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/union-ice.rs:14:33 | LL | const FIELD3: Field3 = unsafe { UNION.field3 }; - | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/union-ice.rs:20:17 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/union-ice.rs:19:17 | LL | b: unsafe { UNION.field3 }, - | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^ evaluation of constant value failed here -error[E0080]: evaluation of constant value failed - --> $DIR/union-ice.rs:33:18 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/union-ice.rs:31:18 | LL | unsafe { UNION.field3 }, - | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 3 previous errors diff --git a/tests/ui/consts/const-eval/union-ub.32bit.stderr b/tests/ui/consts/const-eval/union-ub.32bit.stderr index 38ded4d65cf..7b263c20d33 100644 --- a/tests/ui/consts/const-eval/union-ub.32bit.stderr +++ b/tests/ui/consts/const-eval/union-ub.32bit.stderr @@ -1,19 +1,19 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0x2a, but expected a boolean --> $DIR/union-ub.rs:33:1 | -LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x2a, but expected a boolean +LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool }; + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 2a │ * } -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/union-ub.rs:35:36 | -LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory +LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/union-ub.64bit.stderr b/tests/ui/consts/const-eval/union-ub.64bit.stderr index 38ded4d65cf..7b263c20d33 100644 --- a/tests/ui/consts/const-eval/union-ub.64bit.stderr +++ b/tests/ui/consts/const-eval/union-ub.64bit.stderr @@ -1,19 +1,19 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0x2a, but expected a boolean --> $DIR/union-ub.rs:33:1 | -LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x2a, but expected a boolean +LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool }; + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 2a │ * } -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/union-ub.rs:35:36 | -LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory +LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/union-ub.rs b/tests/ui/consts/const-eval/union-ub.rs index 7d8fd7446a0..0fa5d312856 100644 --- a/tests/ui/consts/const-eval/union-ub.rs +++ b/tests/ui/consts/const-eval/union-ub.rs @@ -30,15 +30,13 @@ union Bar { } // the value is not valid for bools -const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; -//~^ ERROR it is undefined behavior to use this value -const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool}; -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool }; +//~^ ERROR invalid value +const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool }; +//~^ ERROR uninitialized // The value is not valid for any union variant, but that's fine // unions are just a convenient way to transmute bits around const BAD_UNION: Foo = unsafe { Bar { u8: 42 }.foo }; - fn main() {} diff --git a/tests/ui/consts/const-eval/unused-broken-const.rs b/tests/ui/consts/const-eval/unused-broken-const.rs index f7e229aa980..60206362665 100644 --- a/tests/ui/consts/const-eval/unused-broken-const.rs +++ b/tests/ui/consts/const-eval/unused-broken-const.rs @@ -3,6 +3,6 @@ //@ compile-flags: --emit=dep-info,metadata const FOO: i32 = [][0]; -//~^ ERROR evaluation of constant value failed +//~^ ERROR index out of bounds fn main() {} diff --git a/tests/ui/consts/const-eval/unused-broken-const.stderr b/tests/ui/consts/const-eval/unused-broken-const.stderr index fd0ee316fe2..5745539cb56 100644 --- a/tests/ui/consts/const-eval/unused-broken-const.stderr +++ b/tests/ui/consts/const-eval/unused-broken-const.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: index out of bounds: the length is 0 but the index is 0 --> $DIR/unused-broken-const.rs:5:18 | LL | const FOO: i32 = [][0]; - | ^^^^^ index out of bounds: the length is 0 but the index is 0 + | ^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/unwind-abort.rs b/tests/ui/consts/const-eval/unwind-abort.rs index b239dba0239..688bb085356 100644 --- a/tests/ui/consts/const-eval/unwind-abort.rs +++ b/tests/ui/consts/const-eval/unwind-abort.rs @@ -4,7 +4,7 @@ const extern "C" fn foo() { panic!() //~ NOTE inside `foo` } -const _: () = foo(); //~ ERROR evaluation of constant value failed +const _: () = foo(); //~ ERROR explicit panic // Ensure that the CTFE engine handles calls to `extern "C"` aborting gracefully fn main() { diff --git a/tests/ui/consts/const-eval/unwind-abort.stderr b/tests/ui/consts/const-eval/unwind-abort.stderr index 5ed7467e84b..94cf3acec45 100644 --- a/tests/ui/consts/const-eval/unwind-abort.stderr +++ b/tests/ui/consts/const-eval/unwind-abort.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/unwind-abort.rs:7:15 | LL | const _: () = foo(); - | ^^^^^ evaluation panicked: explicit panic + | ^^^^^ evaluation of constant value failed here | note: inside `foo` --> $DIR/unwind-abort.rs:4:5 diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs b/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs index 5f1d27b0de0..dbb165c64d9 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs @@ -15,10 +15,10 @@ pub mod empty { } const FOO: [empty::Empty; 3] = [foo(); 3]; -//~^ ERROR evaluation of constant value failed +//~^ ERROR value of the never type const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; -//~^ ERROR evaluation of constant value failed +//~^ ERROR value of uninhabited type fn main() { FOO; diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr b/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr index 0407ae5c323..4557b392907 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: constructing invalid value: encountered a value of the never type `!` --> $DIR/validate_uninhabited_zsts.rs:17:33 | LL | const FOO: [empty::Empty; 3] = [foo(); 3]; - | ^^^^^ constructing invalid value: encountered a value of the never type `!` + | ^^^^^ evaluation of constant value failed here | note: inside `foo` --> $DIR/validate_uninhabited_zsts.rs:4:14 @@ -10,11 +10,11 @@ note: inside `foo` LL | unsafe { std::mem::transmute(()) } | ^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here -error[E0080]: evaluation of constant value failed +error[E0080]: constructing invalid value at .0: encountered a value of uninhabited type `Void` --> $DIR/validate_uninhabited_zsts.rs:20:42 | LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type `Void` + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs b/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs index 8a32b170c40..3081689ee90 100644 --- a/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs +++ b/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs @@ -10,6 +10,6 @@ struct ThinDst { } const C1: &ThinDst = unsafe { std::mem::transmute(b"d".as_ptr()) }; -//~^ERROR: evaluation of constant value failed +//~^ERROR: `extern type` field does not have a known offset fn main() {} diff --git a/tests/ui/consts/const-eval/validation-ice-extern-type-field.stderr b/tests/ui/consts/const-eval/validation-ice-extern-type-field.stderr index 1ec36abc2ec..08d791f4953 100644 --- a/tests/ui/consts/const-eval/validation-ice-extern-type-field.stderr +++ b/tests/ui/consts/const-eval/validation-ice-extern-type-field.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: `extern type` field does not have a known offset --> $DIR/validation-ice-extern-type-field.rs:12:1 | LL | const C1: &ThinDst = unsafe { std::mem::transmute(b"d".as_ptr()) }; - | ^^^^^^^^^^^^^^^^^^ `extern type` field does not have a known offset + | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here error: aborting due to 1 previous error |
