diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:13:23 +0000 |
commit | 20431706a863f92cb37dc512fef6e48d192aaf2c (patch) | |
tree | 2867f13f5fd5437ba628c67d7f87309ccadcd286 /src/test/ui/consts/const-eval | |
parent | Releasing progress-linux version 1.65.0+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-20431706a863f92cb37dc512fef6e48d192aaf2c.tar.xz rustc-20431706a863f92cb37dc512fef6e48d192aaf2c.zip |
Merging upstream version 1.66.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
96 files changed, 608 insertions, 3098 deletions
diff --git a/src/test/ui/consts/const-eval/conditional_array_execution.rs b/src/test/ui/consts/const-eval/conditional_array_execution.rs index bd517e568..27d5383d6 100644 --- a/src/test/ui/consts/const-eval/conditional_array_execution.rs +++ b/src/test/ui/consts/const-eval/conditional_array_execution.rs @@ -1,16 +1,8 @@ -// build-fail - -#![warn(const_err)] - const X: u32 = 5; const Y: u32 = 6; const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; -//~^ WARN any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR constant fn main() { println!("{}", FOO); - //~^ ERROR evaluation of constant value failed - //~| WARN erroneous constant used [const_err] - //~| WARN this was previously accepted by the compiler but is being phased out } diff --git a/src/test/ui/consts/const-eval/conditional_array_execution.stderr b/src/test/ui/consts/const-eval/conditional_array_execution.stderr index 2953406ee..c3401fbae 100644 --- a/src/test/ui/consts/const-eval/conditional_array_execution.stderr +++ b/src/test/ui/consts/const-eval/conditional_array_execution.stderr @@ -1,64 +1,9 @@ -warning: any use of this value will cause an error - --> $DIR/conditional_array_execution.rs:7:19 - | -LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; - | -------------- ^^^^^ attempt to compute `5_u32 - 6_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/conditional_array_execution.rs:3:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - error[E0080]: evaluation of constant value failed - --> $DIR/conditional_array_execution.rs:12:20 - | -LL | println!("{}", FOO); - | ^^^ referenced constant has errors - -warning: erroneous constant used - --> $DIR/conditional_array_execution.rs:12:20 - | -LL | println!("{}", FOO); - | ^^^ referenced constant has errors - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = note: this warning originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to previous error; 2 warnings emitted - -For more information about this error, try `rustc --explain E0080`. -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/conditional_array_execution.rs:7:19 + --> $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 - | -note: the lint level is defined here - --> $DIR/conditional_array_execution.rs:3:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | ^^^^^ attempt to compute `5_u32 - 6_u32`, which would overflow -Future breakage diagnostic: -warning: erroneous constant used - --> $DIR/conditional_array_execution.rs:12:20 - | -LL | println!("{}", FOO); - | ^^^ referenced constant has errors - | -note: the lint level is defined here - --> $DIR/conditional_array_execution.rs:3:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = note: this warning originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +error: aborting due to previous error +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-2.rs b/src/test/ui/consts/const-eval/const-eval-overflow-2.rs index 9300d9576..535d91359 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-2.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow-2.rs @@ -1,14 +1,14 @@ // Evaluation of constants in refutable patterns goes through // different compiler control-flow paths. -#![allow(unused_imports, warnings, const_err)] +#![allow(unused_imports, warnings)] use std::fmt; 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; +const NEG_NEG_128: i8 = -NEG_128; //~ ERROR constant fn main() { match -128i8 { diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-2.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-2.stderr index cf50c19ca..7b1fe49d4 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-2.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-2.stderr @@ -1,3 +1,9 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow-2.rs:11:25 + | +LL | const NEG_NEG_128: i8 = -NEG_128; + | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + error: could not evaluate constant pattern --> $DIR/const-eval-overflow-2.rs:15:9 | @@ -10,20 +16,6 @@ error: could not evaluate constant pattern LL | NEG_NEG_128 => println!("A"), | ^^^^^^^^^^^ -error: aborting due to 2 previous errors - -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/const-eval-overflow-2.rs:11:25 - | -LL | const NEG_NEG_128: i8 = -NEG_128; - | --------------------- ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow-2.rs:4:36 - | -LL | #![allow(unused_imports, warnings, const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr index 0e6be6d01..c685922c4 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr @@ -4,13 +4,13 @@ error[E0308]: mismatched types LL | = [0; (i8::MAX + 1u8) as usize]; | ^^^ expected `i8`, found `u8` -error[E0277]: cannot add `u8` to `i8` +error[E0277]: cannot add `u8` to `i8` in const contexts --> $DIR/const-eval-overflow-3b.rs:16:20 | LL | = [0; (i8::MAX + 1u8) as usize]; | ^ no implementation for `i8 + u8` | - = help: the trait `Add<u8>` is not implemented for `i8` + = help: the trait `~const Add<u8>` is not implemented for `i8` = help: the following other types implement trait `Add<Rhs>`: <&'a f32 as Add<f32>> <&'a f64 as Add<f64>> diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr index 4fa017e04..b39607924 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr @@ -4,13 +4,13 @@ error[E0308]: mismatched types LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | ^^^ expected `i8`, found `u8` -error[E0277]: cannot add `u8` to `i8` +error[E0277]: cannot add `u8` to `i8` in const contexts --> $DIR/const-eval-overflow-4b.rs:9:28 | LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | ^ no implementation for `i8 + u8` | - = help: the trait `Add<u8>` is not implemented for `i8` + = help: the trait `~const Add<u8>` is not implemented for `i8` = help: the following other types implement trait `Add<Rhs>`: <&'a f32 as Add<f32>> <&'a f64 as Add<f64>> diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2.rs b/src/test/ui/consts/const-eval/const-eval-overflow2.rs index b11f7d698..1676f7c2a 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2.rs @@ -5,63 +5,53 @@ // change this warn to a deny, then the compiler will exit before // those errors are detected. -#![deny(const_err)] - use std::fmt; const VALS_I8: (i8,) = ( i8::MIN - 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_I16: (i16,) = ( i16::MIN - 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_I32: (i32,) = ( i32::MIN - 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_I64: (i64,) = ( i64::MIN - 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U8: (u8,) = ( u8::MIN - 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U16: (u16,) = ( u16::MIN - 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U32: (u32,) = ( u32::MIN - 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U64: (u64,) = ( u64::MIN - 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed fn main() { foo(VALS_I8); diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2.stderr index dab9a76c7..341c15daf 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2.stderr @@ -1,243 +1,51 @@ -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:14:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2.rs:12:6 | -LL | const VALS_I8: (i8,) = - | -------------------- -LL | ( LL | i8::MIN - 1, | ^^^^^^^^^^^ attempt to compute `i8::MIN - 1_i8`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:21:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2.rs:18:6 | -LL | const VALS_I16: (i16,) = - | ---------------------- -LL | ( LL | i16::MIN - 1, | ^^^^^^^^^^^^ attempt to compute `i16::MIN - 1_i16`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:28:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2.rs:24:6 | -LL | const VALS_I32: (i32,) = - | ---------------------- -LL | ( LL | i32::MIN - 1, | ^^^^^^^^^^^^ attempt to compute `i32::MIN - 1_i32`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:35:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2.rs:30:6 | -LL | const VALS_I64: (i64,) = - | ---------------------- -LL | ( LL | i64::MIN - 1, | ^^^^^^^^^^^^ attempt to compute `i64::MIN - 1_i64`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:42:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2.rs:36:6 | -LL | const VALS_U8: (u8,) = - | -------------------- -LL | ( LL | u8::MIN - 1, | ^^^^^^^^^^^ attempt to compute `0_u8 - 1_u8`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:48:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2.rs:41:6 | -LL | const VALS_U16: (u16,) = ( - | ---------------------- LL | u16::MIN - 1, | ^^^^^^^^^^^^ attempt to compute `0_u16 - 1_u16`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:54:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2.rs:46:6 | -LL | const VALS_U32: (u32,) = ( - | ---------------------- LL | u32::MIN - 1, | ^^^^^^^^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:61:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2.rs:52:6 | -LL | const VALS_U64: (u64,) = - | ---------------------- -LL | ( LL | u64::MIN - 1, | ^^^^^^^^^^^^ attempt to compute `0_u64 - 1_u64`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> error: aborting due to 8 previous errors -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:14:6 - | -LL | const VALS_I8: (i8,) = - | -------------------- -LL | ( -LL | i8::MIN - 1, - | ^^^^^^^^^^^ attempt to compute `i8::MIN - 1_i8`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:21:6 - | -LL | const VALS_I16: (i16,) = - | ---------------------- -LL | ( -LL | i16::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `i16::MIN - 1_i16`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:28:6 - | -LL | const VALS_I32: (i32,) = - | ---------------------- -LL | ( -LL | i32::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `i32::MIN - 1_i32`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:35:6 - | -LL | const VALS_I64: (i64,) = - | ---------------------- -LL | ( -LL | i64::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `i64::MIN - 1_i64`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:42:6 - | -LL | const VALS_U8: (u8,) = - | -------------------- -LL | ( -LL | u8::MIN - 1, - | ^^^^^^^^^^^ attempt to compute `0_u8 - 1_u8`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:48:6 - | -LL | const VALS_U16: (u16,) = ( - | ---------------------- -LL | u16::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `0_u16 - 1_u16`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:54:6 - | -LL | const VALS_U32: (u32,) = ( - | ---------------------- -LL | u32::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:61:6 - | -LL | const VALS_U64: (u64,) = - | ---------------------- -LL | ( -LL | u64::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `0_u64 - 1_u64`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2b.rs b/src/test/ui/consts/const-eval/const-eval-overflow2b.rs index 9c3ad8ef9..59d1df568 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2b.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.rs @@ -5,63 +5,53 @@ // change this warn to a deny, then the compiler will exit before // those errors are detected. -#![deny(const_err)] - use std::fmt; const VALS_I8: (i8,) = ( i8::MAX + 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_I16: (i16,) = ( i16::MAX + 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_I32: (i32,) = ( i32::MAX + 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_I64: (i64,) = ( i64::MAX + 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U8: (u8,) = ( u8::MAX + 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U16: (u16,) = ( u16::MAX + 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U32: (u32,) = ( u32::MAX + 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U64: (u64,) = ( u64::MAX + 1, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed fn main() { foo(VALS_I8); diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr index 5fe991743..e661836b4 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr @@ -1,243 +1,51 @@ -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:14:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2b.rs:12:6 | -LL | const VALS_I8: (i8,) = - | -------------------- -LL | ( LL | i8::MAX + 1, | ^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2b.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:21:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2b.rs:18:6 | -LL | const VALS_I16: (i16,) = - | ---------------------- -LL | ( LL | i16::MAX + 1, | ^^^^^^^^^^^^ attempt to compute `i16::MAX + 1_i16`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:28:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2b.rs:24:6 | -LL | const VALS_I32: (i32,) = - | ---------------------- -LL | ( LL | i32::MAX + 1, | ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:35:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2b.rs:30:6 | -LL | const VALS_I64: (i64,) = - | ---------------------- -LL | ( LL | i64::MAX + 1, | ^^^^^^^^^^^^ attempt to compute `i64::MAX + 1_i64`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:42:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2b.rs:36:6 | -LL | const VALS_U8: (u8,) = - | -------------------- -LL | ( LL | u8::MAX + 1, | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:48:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2b.rs:41:6 | -LL | const VALS_U16: (u16,) = ( - | ---------------------- LL | u16::MAX + 1, | ^^^^^^^^^^^^ attempt to compute `u16::MAX + 1_u16`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:54:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2b.rs:46:6 | -LL | const VALS_U32: (u32,) = ( - | ---------------------- LL | u32::MAX + 1, | ^^^^^^^^^^^^ attempt to compute `u32::MAX + 1_u32`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:61:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2b.rs:52:6 | -LL | const VALS_U64: (u64,) = - | ---------------------- -LL | ( LL | u64::MAX + 1, | ^^^^^^^^^^^^ attempt to compute `u64::MAX + 1_u64`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> error: aborting due to 8 previous errors -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:14:6 - | -LL | const VALS_I8: (i8,) = - | -------------------- -LL | ( -LL | i8::MAX + 1, - | ^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2b.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:21:6 - | -LL | const VALS_I16: (i16,) = - | ---------------------- -LL | ( -LL | i16::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `i16::MAX + 1_i16`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2b.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:28:6 - | -LL | const VALS_I32: (i32,) = - | ---------------------- -LL | ( -LL | i32::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2b.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:35:6 - | -LL | const VALS_I64: (i64,) = - | ---------------------- -LL | ( -LL | i64::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `i64::MAX + 1_i64`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2b.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:42:6 - | -LL | const VALS_U8: (u8,) = - | -------------------- -LL | ( -LL | u8::MAX + 1, - | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2b.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:48:6 - | -LL | const VALS_U16: (u16,) = ( - | ---------------------- -LL | u16::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `u16::MAX + 1_u16`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2b.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:54:6 - | -LL | const VALS_U32: (u32,) = ( - | ---------------------- -LL | u32::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `u32::MAX + 1_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2b.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:61:6 - | -LL | const VALS_U64: (u64,) = - | ---------------------- -LL | ( -LL | u64::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `u64::MAX + 1_u64`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2b.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2c.rs b/src/test/ui/consts/const-eval/const-eval-overflow2c.rs index bac4d042e..33b892601 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2c.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.rs @@ -5,63 +5,53 @@ // change this warn to a deny, then the compiler will exit before // those errors are detected. -#![deny(const_err)] - use std::fmt; const VALS_I8: (i8,) = ( i8::MIN * 2, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_I16: (i16,) = ( i16::MIN * 2, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_I32: (i32,) = ( i32::MIN * 2, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_I64: (i64,) = ( i64::MIN * 2, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U8: (u8,) = ( u8::MAX * 2, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U16: (u16,) = ( u16::MAX * 2, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U32: (u32,) = ( u32::MAX * 2, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed const VALS_U64: (u64,) = ( u64::MAX * 2, ); - //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^^ ERROR evaluation of constant value failed fn main() { foo(VALS_I8); diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr index d5f3a0fb1..1fad15492 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr @@ -1,243 +1,51 @@ -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:14:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2c.rs:12:6 | -LL | const VALS_I8: (i8,) = - | -------------------- -LL | ( LL | i8::MIN * 2, | ^^^^^^^^^^^ attempt to compute `i8::MIN * 2_i8`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2c.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:21:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2c.rs:18:6 | -LL | const VALS_I16: (i16,) = - | ---------------------- -LL | ( LL | i16::MIN * 2, | ^^^^^^^^^^^^ attempt to compute `i16::MIN * 2_i16`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:28:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2c.rs:24:6 | -LL | const VALS_I32: (i32,) = - | ---------------------- -LL | ( LL | i32::MIN * 2, | ^^^^^^^^^^^^ attempt to compute `i32::MIN * 2_i32`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:35:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2c.rs:30:6 | -LL | const VALS_I64: (i64,) = - | ---------------------- -LL | ( LL | i64::MIN * 2, | ^^^^^^^^^^^^ attempt to compute `i64::MIN * 2_i64`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:42:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2c.rs:36:6 | -LL | const VALS_U8: (u8,) = - | -------------------- -LL | ( LL | u8::MAX * 2, | ^^^^^^^^^^^ attempt to compute `u8::MAX * 2_u8`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:48:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2c.rs:41:6 | -LL | const VALS_U16: (u16,) = ( - | ---------------------- LL | u16::MAX * 2, | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 2_u16`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:54:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2c.rs:46:6 | -LL | const VALS_U32: (u32,) = ( - | ---------------------- LL | u32::MAX * 2, | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 2_u32`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:61:6 +error[E0080]: evaluation of constant value failed + --> $DIR/const-eval-overflow2c.rs:52:6 | -LL | const VALS_U64: (u64,) = - | ---------------------- -LL | ( LL | u64::MAX * 2, | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 2_u64`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> error: aborting due to 8 previous errors -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:14:6 - | -LL | const VALS_I8: (i8,) = - | -------------------- -LL | ( -LL | i8::MIN * 2, - | ^^^^^^^^^^^ attempt to compute `i8::MIN * 2_i8`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2c.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:21:6 - | -LL | const VALS_I16: (i16,) = - | ---------------------- -LL | ( -LL | i16::MIN * 2, - | ^^^^^^^^^^^^ attempt to compute `i16::MIN * 2_i16`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2c.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:28:6 - | -LL | const VALS_I32: (i32,) = - | ---------------------- -LL | ( -LL | i32::MIN * 2, - | ^^^^^^^^^^^^ attempt to compute `i32::MIN * 2_i32`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2c.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:35:6 - | -LL | const VALS_I64: (i64,) = - | ---------------------- -LL | ( -LL | i64::MIN * 2, - | ^^^^^^^^^^^^ attempt to compute `i64::MIN * 2_i64`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2c.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:42:6 - | -LL | const VALS_U8: (u8,) = - | -------------------- -LL | ( -LL | u8::MAX * 2, - | ^^^^^^^^^^^ attempt to compute `u8::MAX * 2_u8`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2c.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:48:6 - | -LL | const VALS_U16: (u16,) = ( - | ---------------------- -LL | u16::MAX * 2, - | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 2_u16`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2c.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:54:6 - | -LL | const VALS_U32: (u32,) = ( - | ---------------------- -LL | u32::MAX * 2, - | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 2_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2c.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:61:6 - | -LL | const VALS_U64: (u64,) = - | ---------------------- -LL | ( -LL | u64::MAX * 2, - | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 2_u64`, which would overflow - | -note: the lint level is defined here - --> $DIR/const-eval-overflow2c.rs:8:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/const-eval-query-stack.rs b/src/test/ui/consts/const-eval/const-eval-query-stack.rs index c94604989..8f8a8cee3 100644 --- a/src/test/ui/consts/const-eval/const-eval-query-stack.rs +++ b/src/test/ui/consts/const-eval/const-eval-query-stack.rs @@ -1,5 +1,4 @@ -// compile-flags: -Ztreat-err-as-bug=2 -// build-fail +// compile-flags: -Ztreat-err-as-bug=1 // failure-status: 101 // rustc-env:RUST_BACKTRACE=1 // normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> "" @@ -15,14 +14,9 @@ #![allow(unconditional_panic)] -#[warn(const_err)] -const X: i32 = 1 / 0; //~WARN any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +const X: i32 = 1 / 0; //~ERROR constant fn main() { let x: &'static i32 = &X; - //~^ ERROR evaluation of constant value failed - //~| ERROR erroneous constant used - //~| WARNING this was previously accepted by the compiler println!("x={}", x); } diff --git a/src/test/ui/consts/const-eval/const-eval-query-stack.stderr b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr index 0ae7bfa86..b97975c4c 100644 --- a/src/test/ui/consts/const-eval/const-eval-query-stack.stderr +++ b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr @@ -1,61 +1,13 @@ -warning: any use of this value will cause an error - --> $DIR/const-eval-query-stack.rs:19:16 - | -LL | const X: i32 = 1 / 0; - | ------------ ^^^^^ attempt to divide `1_i32` by zero - | -note: the lint level is defined here - --> $DIR/const-eval-query-stack.rs:18:8 - | -LL | #[warn(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - error[E0080]: evaluation of constant value failed - --> $DIR/const-eval-query-stack.rs:23:28 + --> $DIR/const-eval-query-stack.rs:17:16 | -LL | let x: &'static i32 = &X; - | ^ referenced constant has errors - -error: erroneous constant used - --> $DIR/const-eval-query-stack.rs:23:27 - | -LL | let x: &'static i32 = &X; - | ^^ referenced constant has errors - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> +LL | const X: i32 = 1 / 0; + | ^^^^^ attempt to divide `1_i32` by zero query stack during panic: -#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `main` -#1 [optimized_mir] optimizing MIR for `main` -#2 [collect_and_partition_mono_items] collect_and_partition_mono_items +#0 [eval_to_allocation_raw] const-evaluating + checking `X` +#1 [eval_to_const_value_raw] simplifying constant for the type system `X` +#2 [eval_to_const_value_raw] simplifying constant for the type system `X` +#3 [lint_mod] linting top-level module +#4 [analysis] running analysis passes on this crate end of query stack -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/const-eval-query-stack.rs:19:16 - | -LL | const X: i32 = 1 / 0; - | ------------ ^^^^^ attempt to divide `1_i32` by zero - | -note: the lint level is defined here - --> $DIR/const-eval-query-stack.rs:18:8 - | -LL | #[warn(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: erroneous constant used - --> $DIR/const-eval-query-stack.rs:23:27 - | -LL | let x: &'static i32 = &X; - | ^^ referenced constant has errors - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - diff --git a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr index 12d5b7bd6..bf98d0394 100644 --- a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr +++ b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr @@ -1,664 +1,258 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/const-pointer-values-in-various-types.rs:26:49 | LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; - | -------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:30:43 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:29:43 | LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:34:45 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:32:45 | LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:38:45 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:35:45 | LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:42:45 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:38:45 | LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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:46:47 + --> $DIR/const-pointer-values-in-various-types.rs:41: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 -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:50:43 +error[E0080]: evaluation of constant value failed + --> $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 raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:54:45 +error[E0080]: evaluation of constant value failed + --> $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 raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:58:45 +error[E0080]: evaluation of constant value failed + --> $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 raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:62:45 +error[E0080]: evaluation of constant value failed + --> $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 raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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:66:47 + --> $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 -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:70:45 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:61:45 | LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:74:45 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:64:45 | LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:78:47 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:67:47 | LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; - | ------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:82:47 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:70:47 | LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; - | ------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:86:39 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:73:39 | LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; - | ---------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:90:41 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:76:41 | LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:94:41 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:79:41 | LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:98:41 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:82:41 | LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:102:43 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:85:43 | LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:106:39 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:88:39 | LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; - | ---------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:110:41 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:91:41 | LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:114:41 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:94:41 | LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:118:41 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:97:41 | LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:122:43 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:100:43 | LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:126:41 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:103:41 | LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:130:41 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:106:41 | LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:134:43 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:109:43 | LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:138:43 +error[E0080]: evaluation of constant value failed + --> $DIR/const-pointer-values-in-various-types.rs:112:43 | LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: aborting due to 29 previous errors For more information about this error, try `rustc --explain E0080`. -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:26:49 - | -LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; - | -------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $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 raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:34:45 - | -LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:38:45 - | -LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:42:45 - | -LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:50:43 - | -LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:54:45 - | -LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:58:45 - | -LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:62:45 - | -LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:70:45 - | -LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:74:45 - | -LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; - | ---------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:78:47 - | -LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; - | ------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:82:47 - | -LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; - | ------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:86:39 - | -LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; - | ---------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:90:41 - | -LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:94:41 - | -LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:98:41 - | -LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:102:43 - | -LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:106:39 - | -LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; - | ---------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:110:41 - | -LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:114:41 - | -LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:118:41 - | -LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:122:43 - | -LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:126:41 - | -LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:130:41 - | -LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; - | ------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:134:43 - | -LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:138:43 - | -LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; - | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs index f6a5e4d3c..45eed9d84 100644 --- a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs +++ b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs @@ -24,118 +24,91 @@ union Nonsense { fn main() { const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 }; //~^ ERROR evaluation of constant value failed //~| uninitialized const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 }; //~^ ERROR evaluation of constant value failed //~| uninitialized const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; - //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of constant value failed } diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs index 804ebf660..b873940c4 100644 --- a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs +++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs @@ -1,8 +1,5 @@ -// build-fail // compile-flags: -Zunleash-the-miri-inside-of-you -#![allow(const_err)] - fn double(x: usize) -> usize { x * 2 } @@ -10,6 +7,8 @@ const X: fn(usize) -> usize = double; const fn bar(x: fn(usize) -> usize, y: usize) -> usize { x(y) + //~^ ERROR evaluation of constant value failed + //~| ERROR evaluation of constant value failed } const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday @@ -17,7 +16,5 @@ const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday fn main() { assert_eq!(Y, 4); - //~^ ERROR evaluation of constant value failed assert_eq!(Z, 4); - //~^ ERROR evaluation of constant value failed } diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr index f6ffa1ef2..3784a3861 100644 --- a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr +++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr @@ -1,99 +1,35 @@ error[E0080]: evaluation of constant value failed - --> $DIR/const_fn_ptr_fail2.rs:19:16 - | -LL | assert_eq!(Y, 4); - | ^ referenced constant has errors - -error[E0080]: evaluation of constant value failed - --> $DIR/const_fn_ptr_fail2.rs:21:16 - | -LL | assert_eq!(Z, 4); - | ^ referenced constant has errors - -warning: skipping const checks - | -help: skipping check that does not even have a feature gate - --> $DIR/const_fn_ptr_fail2.rs:12:5 - | -LL | x(y) - | ^^^^ - -error: aborting due to 2 previous errors; 1 warning emitted - -For more information about this error, try `rustc --explain E0080`. -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/const_fn_ptr_fail2.rs:12:5 + --> $DIR/const_fn_ptr_fail2.rs:9:5 | LL | x(y) | ^^^^ | | | calling non-const function `double` - | inside `bar` at $DIR/const_fn_ptr_fail2.rs:12:5 - | inside `Y` at $DIR/const_fn_ptr_fail2.rs:15:18 + | inside `bar` at $DIR/const_fn_ptr_fail2.rs:9:5 ... LL | const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday - | -------------- - | -note: the lint level is defined here - --> $DIR/const_fn_ptr_fail2.rs:4:10 - | -LL | #![allow(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | --------- inside `Y` at $DIR/const_fn_ptr_fail2.rs:14:18 -Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/const_fn_ptr_fail2.rs:12:5 +error[E0080]: evaluation of constant value failed + --> $DIR/const_fn_ptr_fail2.rs:9:5 | LL | x(y) | ^^^^ | | | calling non-const function `double` - | inside `bar` at $DIR/const_fn_ptr_fail2.rs:12:5 - | inside `Z` at $DIR/const_fn_ptr_fail2.rs:16:18 + | inside `bar` at $DIR/const_fn_ptr_fail2.rs:9:5 ... LL | const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday - | -------------- - | -note: the lint level is defined here - --> $DIR/const_fn_ptr_fail2.rs:4:10 - | -LL | #![allow(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | -------------- inside `Z` at $DIR/const_fn_ptr_fail2.rs:15:18 -Future breakage diagnostic: -warning: erroneous constant used - --> $DIR/const_fn_ptr_fail2.rs:19:5 - | -LL | assert_eq!(Y, 4); - | ^^^^^^^^^^^^^^^^ referenced constant has errors +warning: skipping const checks | -note: the lint level is defined here - --> $DIR/const_fn_ptr_fail2.rs:4:10 +help: skipping check that does not even have a feature gate + --> $DIR/const_fn_ptr_fail2.rs:9:5 | -LL | #![allow(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = note: this warning originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) +LL | x(y) + | ^^^^ -Future breakage diagnostic: -warning: erroneous constant used - --> $DIR/const_fn_ptr_fail2.rs:21:5 - | -LL | assert_eq!(Z, 4); - | ^^^^^^^^^^^^^^^^ referenced constant has errors - | -note: the lint level is defined here - --> $DIR/const_fn_ptr_fail2.rs:4:10 - | -LL | #![allow(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = note: this warning originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) +error: aborting due to 2 previous errors; 1 warning emitted +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/const_let.rs b/src/test/ui/consts/const-eval/const_let.rs index 18692dbce..1e2bcc55b 100644 --- a/src/test/ui/consts/const-eval/const_let.rs +++ b/src/test/ui/consts/const-eval/const_let.rs @@ -14,16 +14,16 @@ const X2: FakeNeedsDrop = { let x; x = FakeNeedsDrop; x }; // error const Y: FakeNeedsDrop = { let mut x = FakeNeedsDrop; x = FakeNeedsDrop; x }; -//~^ ERROR destructors cannot be evaluated at compile-time +//~^ ERROR destructor of // error const Y2: FakeNeedsDrop = { let mut x; x = FakeNeedsDrop; x = FakeNeedsDrop; x }; -//~^ ERROR destructors cannot be evaluated at compile-time +//~^ ERROR destructor of // error const Z: () = { let mut x = None; x = Some(FakeNeedsDrop); }; -//~^ ERROR destructors cannot be evaluated at compile-time +//~^ ERROR destructor of // error const Z2: () = { let mut x; x = None; x = Some(FakeNeedsDrop); }; -//~^ ERROR destructors cannot be evaluated at compile-time +//~^ ERROR destructor of diff --git a/src/test/ui/consts/const-eval/const_let.stderr b/src/test/ui/consts/const-eval/const_let.stderr index 47f39b703..63442f557 100644 --- a/src/test/ui/consts/const-eval/const_let.stderr +++ b/src/test/ui/consts/const-eval/const_let.stderr @@ -1,34 +1,34 @@ -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `FakeNeedsDrop` cannot be evaluated at compile-time --> $DIR/const_let.rs:16:32 | LL | const Y: FakeNeedsDrop = { let mut x = FakeNeedsDrop; x = FakeNeedsDrop; x }; | ^^^^^ - value is dropped here | | - | constants cannot evaluate destructors + | the destructor for this type cannot be evaluated in constants -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `FakeNeedsDrop` cannot be evaluated at compile-time --> $DIR/const_let.rs:20:33 | LL | const Y2: FakeNeedsDrop = { let mut x; x = FakeNeedsDrop; x = FakeNeedsDrop; x }; | ^^^^^ - value is dropped here | | - | constants cannot evaluate destructors + | the destructor for this type cannot be evaluated in constants -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Option<FakeNeedsDrop>` cannot be evaluated at compile-time --> $DIR/const_let.rs:24:21 | LL | const Z: () = { let mut x = None; x = Some(FakeNeedsDrop); }; | ^^^^^ - value is dropped here | | - | constants cannot evaluate destructors + | the destructor for this type cannot be evaluated in constants -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Option<FakeNeedsDrop>` cannot be evaluated at compile-time --> $DIR/const_let.rs:28:22 | LL | const Z2: () = { let mut x; x = None; x = Some(FakeNeedsDrop); }; | ^^^^^ - value is dropped here | | - | constants cannot evaluate destructors + | the destructor for this type cannot be evaluated in constants error: aborting due to 4 previous errors diff --git a/src/test/ui/consts/const-eval/const_panic_stability.e2018.stderr b/src/test/ui/consts/const-eval/const_panic_stability.e2018.stderr index f06dedc22..3553a18d3 100644 --- a/src/test/ui/consts/const-eval/const_panic_stability.e2018.stderr +++ b/src/test/ui/consts/const-eval/const_panic_stability.e2018.stderr @@ -4,9 +4,9 @@ warning: panic message is not a string literal LL | panic!({ "foo" }); | ^^^^^^^^^ | - = note: `#[warn(non_fmt_panics)]` on by default = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html> + = note: `#[warn(non_fmt_panics)]` on by default help: add a "{}" format string to `Display` the message | LL | panic!("{}", { "foo" }); diff --git a/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr b/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr index 168fa0ad0..12244450e 100644 --- a/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr +++ b/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr @@ -10,16 +10,6 @@ note: the trait `PartialEq<_>` is implemented for `*const i32`, but that impleme | LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; | ^^ - = help: the following other types implement trait `PartialEq<Rhs>`: - f32 - f64 - i128 - i16 - i32 - i64 - i8 - isize - and 6 others error[E0277]: can't compare `*const i32` with `_` in const contexts --> $DIR/const_raw_ptr_ops.rs:6:44 @@ -33,16 +23,6 @@ note: the trait `PartialEq<_>` is implemented for `*const i32`, but that impleme | LL | const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; | ^^ - = help: the following other types implement trait `PartialEq<Rhs>`: - f32 - f64 - i128 - i16 - i32 - i64 - i8 - isize - and 6 others error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/const-eval/erroneous-const.rs b/src/test/ui/consts/const-eval/erroneous-const.rs index bee5a7cb3..cf11531ba 100644 --- a/src/test/ui/consts/const-eval/erroneous-const.rs +++ b/src/test/ui/consts/const-eval/erroneous-const.rs @@ -1,11 +1,9 @@ //! Make sure we error on erroneous consts even if they are unused. -#![warn(const_err, unconditional_panic)] +#![allow(unconditional_panic)] struct PrintName<T>(T); impl<T> PrintName<T> { - const VOID: () = [()][2]; //~WARN any use of this value will cause an error - //~^ WARN this operation will panic at runtime - //~| WARN this was previously accepted by the compiler but is being phased out + const VOID: () = [()][2]; //~ERROR evaluation of `PrintName::<i32>::VOID` failed } const fn no_codegen<T>() { diff --git a/src/test/ui/consts/const-eval/erroneous-const.stderr b/src/test/ui/consts/const-eval/erroneous-const.stderr index adfb4cc61..33579135d 100644 --- a/src/test/ui/consts/const-eval/erroneous-const.stderr +++ b/src/test/ui/consts/const-eval/erroneous-const.stderr @@ -1,56 +1,21 @@ -warning: this operation will panic at runtime +error[E0080]: evaluation of `PrintName::<i32>::VOID` failed --> $DIR/erroneous-const.rs:6:22 | LL | const VOID: () = [()][2]; | ^^^^^^^ index out of bounds: the length is 1 but the index is 2 - | -note: the lint level is defined here - --> $DIR/erroneous-const.rs:2:20 - | -LL | #![warn(const_err, unconditional_panic)] - | ^^^^^^^^^^^^^^^^^^^ - -warning: any use of this value will cause an error - --> $DIR/erroneous-const.rs:6:22 - | -LL | const VOID: () = [()][2]; - | -------------- ^^^^^^^ index out of bounds: the length is 1 but the index is 2 - | -note: the lint level is defined here - --> $DIR/erroneous-const.rs:2:9 - | -LL | #![warn(const_err, unconditional_panic)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> error[E0080]: could not evaluate static initializer - --> $DIR/erroneous-const.rs:15:17 + --> $DIR/erroneous-const.rs:13:17 | LL | let _ = PrintName::<T>::VOID; | ^^^^^^^^^^^^^^^^^^^^ | | | referenced constant has errors - | inside `no_codegen::<i32>` at $DIR/erroneous-const.rs:15:17 + | inside `no_codegen::<i32>` at $DIR/erroneous-const.rs:13:17 ... LL | pub static FOO: () = no_codegen::<i32>(); - | ------------------- inside `FOO` at $DIR/erroneous-const.rs:19:22 + | ------------------- inside `FOO` at $DIR/erroneous-const.rs:17:22 -error: aborting due to previous error; 2 warnings emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/erroneous-const.rs:6:22 - | -LL | const VOID: () = [()][2]; - | -------------- ^^^^^^^ index out of bounds: the length is 1 but the index is 2 - | -note: the lint level is defined here - --> $DIR/erroneous-const.rs:2:9 - | -LL | #![warn(const_err, unconditional_panic)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - diff --git a/src/test/ui/consts/const-eval/erroneous-const2.rs b/src/test/ui/consts/const-eval/erroneous-const2.rs index aa0f093bf..2fbf7be88 100644 --- a/src/test/ui/consts/const-eval/erroneous-const2.rs +++ b/src/test/ui/consts/const-eval/erroneous-const2.rs @@ -1,11 +1,9 @@ //! Make sure we error on erroneous consts even if they are unused. -#![warn(const_err, unconditional_panic)] +#![allow(unconditional_panic)] struct PrintName<T>(T); impl<T> PrintName<T> { - const VOID: () = [()][2]; //~WARN any use of this value will cause an error - //~^ WARN this operation will panic at runtime - //~| WARN this was previously accepted by the compiler but is being phased out + const VOID: () = [()][2]; //~ERROR evaluation of `PrintName::<i32>::VOID` failed } pub static FOO: () = { diff --git a/src/test/ui/consts/const-eval/erroneous-const2.stderr b/src/test/ui/consts/const-eval/erroneous-const2.stderr index e947d93e4..630b1cf16 100644 --- a/src/test/ui/consts/const-eval/erroneous-const2.stderr +++ b/src/test/ui/consts/const-eval/erroneous-const2.stderr @@ -1,50 +1,15 @@ -warning: this operation will panic at runtime +error[E0080]: evaluation of `PrintName::<i32>::VOID` failed --> $DIR/erroneous-const2.rs:6:22 | LL | const VOID: () = [()][2]; | ^^^^^^^ index out of bounds: the length is 1 but the index is 2 - | -note: the lint level is defined here - --> $DIR/erroneous-const2.rs:2:20 - | -LL | #![warn(const_err, unconditional_panic)] - | ^^^^^^^^^^^^^^^^^^^ - -warning: any use of this value will cause an error - --> $DIR/erroneous-const2.rs:6:22 - | -LL | const VOID: () = [()][2]; - | -------------- ^^^^^^^ index out of bounds: the length is 1 but the index is 2 - | -note: the lint level is defined here - --> $DIR/erroneous-const2.rs:2:9 - | -LL | #![warn(const_err, unconditional_panic)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> error[E0080]: could not evaluate static initializer - --> $DIR/erroneous-const2.rs:15:17 + --> $DIR/erroneous-const2.rs:13:17 | LL | let _ = PrintName::<i32>::VOID; | ^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors -error: aborting due to previous error; 2 warnings emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/erroneous-const2.rs:6:22 - | -LL | const VOID: () = [()][2]; - | -------------- ^^^^^^^ index out of bounds: the length is 1 but the index is 2 - | -note: the lint level is defined here - --> $DIR/erroneous-const2.rs:2:9 - | -LL | #![warn(const_err, unconditional_panic)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - diff --git a/src/test/ui/consts/const-eval/format.rs b/src/test/ui/consts/const-eval/format.rs index e43633da3..3eef0d6c3 100644 --- a/src/test/ui/consts/const-eval/format.rs +++ b/src/test/ui/consts/const-eval/format.rs @@ -3,8 +3,6 @@ const fn failure() { //~^ ERROR cannot call non-const formatting macro in constant functions //~| ERROR erroneous constant used //~| ERROR erroneous constant used - //~| WARN this was previously accepted by the compiler - //~| WARN this was previously accepted by the compiler } const fn print() { @@ -14,8 +12,6 @@ const fn print() { //~| ERROR cannot call non-const fn `_print` in constant functions //~| ERROR erroneous constant used //~| ERROR erroneous constant used - //~| WARN this was previously accepted by the compiler - //~| WARN this was previously accepted by the compiler } fn main() {} diff --git a/src/test/ui/consts/const-eval/format.stderr b/src/test/ui/consts/const-eval/format.stderr index a476b0f58..64c769648 100644 --- a/src/test/ui/consts/const-eval/format.stderr +++ b/src/test/ui/consts/const-eval/format.stderr @@ -8,7 +8,7 @@ LL | panic!("{:?}", 0); = note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const formatting macro in constant functions - --> $DIR/format.rs:11:22 + --> $DIR/format.rs:9:22 | LL | println!("{:?}", 0); | ^ @@ -17,7 +17,7 @@ LL | println!("{:?}", 0); = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: `Arguments::<'a>::new_v1` is not yet stable as a const fn - --> $DIR/format.rs:11:5 + --> $DIR/format.rs:9:5 | LL | println!("{:?}", 0); | ^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | println!("{:?}", 0); = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const fn `_print` in constant functions - --> $DIR/format.rs:11:5 + --> $DIR/format.rs:9:5 | LL | println!("{:?}", 0); | ^^^^^^^^^^^^^^^^^^^ @@ -34,91 +34,35 @@ LL | println!("{:?}", 0); = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -error: erroneous constant used +error[E0080]: erroneous constant used --> $DIR/format.rs:2:12 | LL | panic!("{:?}", 0); | ^^^^^^ referenced constant has errors - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: erroneous constant used +error[E0080]: erroneous constant used --> $DIR/format.rs:2:20 | LL | panic!("{:?}", 0); | ^ referenced constant has errors | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error: erroneous constant used - --> $DIR/format.rs:11:14 +error[E0080]: erroneous constant used + --> $DIR/format.rs:9:14 | LL | println!("{:?}", 0); | ^^^^^^ referenced constant has errors - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -error: erroneous constant used - --> $DIR/format.rs:11:22 +error[E0080]: erroneous constant used + --> $DIR/format.rs:9:22 | LL | println!("{:?}", 0); | ^ referenced constant has errors | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 8 previous errors -For more information about this error, try `rustc --explain E0015`. -Future incompatibility report: Future breakage diagnostic: -error: erroneous constant used - --> $DIR/format.rs:2:12 - | -LL | panic!("{:?}", 0); - | ^^^^^^ referenced constant has errors - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: erroneous constant used - --> $DIR/format.rs:2:20 - | -LL | panic!("{:?}", 0); - | ^ referenced constant has errors - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) - -Future breakage diagnostic: -error: erroneous constant used - --> $DIR/format.rs:11:14 - | -LL | println!("{:?}", 0); - | ^^^^^^ referenced constant has errors - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: erroneous constant used - --> $DIR/format.rs:11:22 - | -LL | println!("{:?}", 0); - | ^ referenced constant has errors - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) - +Some errors have detailed explanations: E0015, E0080. +For more information about an error, try `rustc --explain E0015`. diff --git a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs index 8064cc493..bc2ea3f18 100644 --- a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs +++ b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs @@ -1,21 +1,19 @@ // build-fail // Regression test for #66975 -#![warn(const_err, unconditional_panic)] +#![warn(unconditional_panic)] #![feature(never_type)] struct PrintName<T>(T); impl<T> PrintName<T> { const VOID: ! = { let x = 0 * std::mem::size_of::<T>(); [][x] }; - //~^ WARN any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of `PrintName::<()>::VOID` failed } fn f<T>() { let _ = PrintName::<T>::VOID; - //~^ ERROR erroneous constant encountered } pub fn main() { diff --git a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr index da4a21e08..8bcd03005 100644 --- a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr +++ b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr @@ -1,37 +1,15 @@ -warning: any use of this value will cause an error +error[E0080]: evaluation of `PrintName::<()>::VOID` failed --> $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 - | -note: the lint level is defined here - --> $DIR/index-out-of-bounds-never-type.rs:4:9 - | -LL | #![warn(const_err, unconditional_panic)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | ^^^^^ index out of bounds: the length is 0 but the index is 0 -error: erroneous constant encountered - --> $DIR/index-out-of-bounds-never-type.rs:17:13 +note: the above error was encountered while instantiating `fn f::<()>` + --> $DIR/index-out-of-bounds-never-type.rs:20:5 | -LL | let _ = PrintName::<T>::VOID; - | ^^^^^^^^^^^^^^^^^^^^ +LL | f::<()>(); + | ^^^^^^^^^ -error: aborting due to previous error; 1 warning emitted - -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $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 - | -note: the lint level is defined here - --> $DIR/index-out-of-bounds-never-type.rs:4:9 - | -LL | #![warn(const_err, unconditional_panic)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> +error: aborting due to previous error +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/infinite_loop.rs b/src/test/ui/consts/const-eval/infinite_loop.rs index 14a573ccf..4babc9a28 100644 --- a/src/test/ui/consts/const-eval/infinite_loop.rs +++ b/src/test/ui/consts/const-eval/infinite_loop.rs @@ -4,8 +4,8 @@ fn main() { let _ = [(); { let mut n = 113383; // #20 in https://oeis.org/A006884 while n != 0 { - n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; //~^ ERROR evaluation of constant value failed + n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; } n }]; diff --git a/src/test/ui/consts/const-eval/infinite_loop.stderr b/src/test/ui/consts/const-eval/infinite_loop.stderr index 3b5a0f22f..8b58cb279 100644 --- a/src/test/ui/consts/const-eval/infinite_loop.stderr +++ b/src/test/ui/consts/const-eval/infinite_loop.stderr @@ -1,8 +1,8 @@ error[E0080]: evaluation of constant value failed - --> $DIR/infinite_loop.rs:7:20 + --> $DIR/infinite_loop.rs:6:15 | -LL | n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; - | ^^^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) +LL | while n != 0 { + | ^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/issue-100878.rs b/src/test/ui/consts/const-eval/issue-100878.rs new file mode 100644 index 000000000..353ce5050 --- /dev/null +++ b/src/test/ui/consts/const-eval/issue-100878.rs @@ -0,0 +1,8 @@ +// This checks that the const-eval ICE in issue #100878 does not recur. +// +// build-pass +pub fn bitshift_data(data: [u8; 1]) -> u8 { + data[0] << 8 +} + +fn main() {} diff --git a/src/test/ui/consts/const-eval/issue-43197.rs b/src/test/ui/consts/const-eval/issue-43197.rs index e15f8771d..145463f0a 100644 --- a/src/test/ui/consts/const-eval/issue-43197.rs +++ b/src/test/ui/consts/const-eval/issue-43197.rs @@ -1,23 +1,11 @@ -// build-fail - -#![warn(const_err)] - const fn foo(x: u32) -> u32 { x } fn main() { const X: u32 = 0 - 1; - //~^ WARN any use of this value will cause - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR constant const Y: u32 = foo(0 - 1); - //~^ WARN any use of this value will cause - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR constant println!("{} {}", X, Y); - //~^ ERROR evaluation of constant value failed - //~| ERROR evaluation of constant value failed - //~| WARN erroneous constant used [const_err] - //~| WARN erroneous constant used [const_err] - //~| WARN this was previously accepted by the compiler but is being phased out - //~| WARN this was previously accepted by the compiler but is being phased out } diff --git a/src/test/ui/consts/const-eval/issue-43197.stderr b/src/test/ui/consts/const-eval/issue-43197.stderr index 3f67c38f8..c59f13e48 100644 --- a/src/test/ui/consts/const-eval/issue-43197.stderr +++ b/src/test/ui/consts/const-eval/issue-43197.stderr @@ -1,120 +1,15 @@ -warning: any use of this value will cause an error - --> $DIR/issue-43197.rs:10:20 - | -LL | const X: u32 = 0 - 1; - | ------------ ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/issue-43197.rs:3:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -warning: any use of this value will cause an error - --> $DIR/issue-43197.rs:13:24 - | -LL | const Y: u32 = foo(0 - 1); - | ------------ ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - error[E0080]: evaluation of constant value failed - --> $DIR/issue-43197.rs:16:23 - | -LL | println!("{} {}", X, Y); - | ^ referenced constant has errors - -warning: erroneous constant used - --> $DIR/issue-43197.rs:16:23 - | -LL | println!("{} {}", X, Y); - | ^ referenced constant has errors - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = note: this warning originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0080]: evaluation of constant value failed - --> $DIR/issue-43197.rs:16:26 - | -LL | println!("{} {}", X, Y); - | ^ referenced constant has errors - -warning: erroneous constant used - --> $DIR/issue-43197.rs:16:26 - | -LL | println!("{} {}", X, Y); - | ^ referenced constant has errors - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = note: this warning originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 2 previous errors; 4 warnings emitted - -For more information about this error, try `rustc --explain E0080`. -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/issue-43197.rs:10:20 + --> $DIR/issue-43197.rs:6:20 | LL | const X: u32 = 0 - 1; - | ------------ ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/issue-43197.rs:3:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow -Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/issue-43197.rs:13:24 +error[E0080]: evaluation of constant value failed + --> $DIR/issue-43197.rs:8:24 | LL | const Y: u32 = foo(0 - 1); - | ------------ ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/issue-43197.rs:3:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow -Future breakage diagnostic: -warning: erroneous constant used - --> $DIR/issue-43197.rs:16:23 - | -LL | println!("{} {}", X, Y); - | ^ referenced constant has errors - | -note: the lint level is defined here - --> $DIR/issue-43197.rs:3:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = note: this warning originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) - -Future breakage diagnostic: -warning: erroneous constant used - --> $DIR/issue-43197.rs:16:26 - | -LL | println!("{} {}", X, Y); - | ^ referenced constant has errors - | -note: the lint level is defined here - --> $DIR/issue-43197.rs:3:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = note: this warning originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/issue-44578.rs b/src/test/ui/consts/const-eval/issue-44578.rs index a88e21970..2dbe1c2bd 100644 --- a/src/test/ui/consts/const-eval/issue-44578.rs +++ b/src/test/ui/consts/const-eval/issue-44578.rs @@ -1,7 +1,5 @@ // build-fail -#![allow(const_err)] - trait Foo { const AMT: usize; } @@ -12,7 +10,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]; + const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; //~ERROR evaluation of `<Bar<u16, u8> as Foo>::AMT` failed } impl Foo for u8 { @@ -26,4 +24,5 @@ impl Foo for u16 { fn main() { println!("{}", <Bar<u16, u8> as Foo>::AMT); //~^ ERROR evaluation of constant value failed + //~| ERROR erroneous constant used } diff --git a/src/test/ui/consts/const-eval/issue-44578.stderr b/src/test/ui/consts/const-eval/issue-44578.stderr index 4c27ceea1..963381b58 100644 --- a/src/test/ui/consts/const-eval/issue-44578.stderr +++ b/src/test/ui/consts/const-eval/issue-44578.stderr @@ -1,40 +1,23 @@ +error[E0080]: evaluation of `<Bar<u16, u8> as Foo>::AMT` failed + --> $DIR/issue-44578.rs:13: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 + error[E0080]: evaluation of constant value failed - --> $DIR/issue-44578.rs:27:20 + --> $DIR/issue-44578.rs:25:20 | LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0080`. -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/issue-44578.rs:15: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 - | -note: the lint level is defined here - --> $DIR/issue-44578.rs:3:10 - | -LL | #![allow(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -warning: erroneous constant used - --> $DIR/issue-44578.rs:27:20 +error[E0080]: erroneous constant used + --> $DIR/issue-44578.rs:25:20 | LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors | -note: the lint level is defined here - --> $DIR/issue-44578.rs:3:10 - | -LL | #![allow(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = note: this warning originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/issue-50814-2.rs b/src/test/ui/consts/const-eval/issue-50814-2.rs index 15f4de0ae..49d1d8ff0 100644 --- a/src/test/ui/consts/const-eval/issue-50814-2.rs +++ b/src/test/ui/consts/const-eval/issue-50814-2.rs @@ -11,8 +11,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 any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + const BAR: usize = [5, 6, 7][T::BOO]; //~ ERROR evaluation of `<A<()> as Foo<()>>::BAR` failed } fn foo<T: C>() -> &'static usize { diff --git a/src/test/ui/consts/const-eval/issue-50814-2.stderr b/src/test/ui/consts/const-eval/issue-50814-2.stderr index cc19caca7..6604f2b9f 100644 --- a/src/test/ui/consts/const-eval/issue-50814-2.stderr +++ b/src/test/ui/consts/const-eval/issue-50814-2.stderr @@ -1,21 +1,17 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of `<A<()> as Foo<()>>::BAR` failed --> $DIR/issue-50814-2.rs:14:24 | LL | const BAR: usize = [5, 6, 7][T::BOO]; - | ---------------- ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 error[E0080]: evaluation of `foo::<()>` failed - --> $DIR/issue-50814-2.rs:19:6 + --> $DIR/issue-50814-2.rs:18:6 | LL | &<A<T> as Foo<T>>::BAR | ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors note: the above error was encountered while instantiating `fn foo::<()>` - --> $DIR/issue-50814-2.rs:31:22 + --> $DIR/issue-50814-2.rs:30:22 | LL | println!("{:x}", foo::<()>() as *const usize as usize); | ^^^^^^^^^^^ @@ -23,14 +19,3 @@ LL | println!("{:x}", foo::<()>() as *const usize as usize); error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/issue-50814-2.rs:14:24 - | -LL | const BAR: usize = [5, 6, 7][T::BOO]; - | ---------------- ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - diff --git a/src/test/ui/consts/const-eval/issue-50814.rs b/src/test/ui/consts/const-eval/issue-50814.rs index 98229f919..5a587701f 100644 --- a/src/test/ui/consts/const-eval/issue-50814.rs +++ b/src/test/ui/consts/const-eval/issue-50814.rs @@ -13,8 +13,7 @@ struct Sum<A,B>(A,B); impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A,B> { const MAX: u8 = A::MAX + B::MAX; - //~^ ERROR any use of this value will cause an error [const_err] - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed } fn foo<T>(_: T) -> &'static u8 { diff --git a/src/test/ui/consts/const-eval/issue-50814.stderr b/src/test/ui/consts/const-eval/issue-50814.stderr index 6ceef91a0..46dd2b89f 100644 --- a/src/test/ui/consts/const-eval/issue-50814.stderr +++ b/src/test/ui/consts/const-eval/issue-50814.stderr @@ -1,21 +1,17 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed --> $DIR/issue-50814.rs:15:21 | LL | const MAX: u8 = A::MAX + B::MAX; - | ------------- ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow error[E0080]: evaluation of `foo::<i32>` failed - --> $DIR/issue-50814.rs:21:6 + --> $DIR/issue-50814.rs:20:6 | LL | &Sum::<U8,U8>::MAX | ^^^^^^^^^^^^^^^^^ referenced constant has errors note: the above error was encountered while instantiating `fn foo::<i32>` - --> $DIR/issue-50814.rs:26:5 + --> $DIR/issue-50814.rs:25:5 | LL | foo(0); | ^^^^^^ @@ -23,14 +19,3 @@ LL | foo(0); error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/issue-50814.rs:15:21 - | -LL | const MAX: u8 = A::MAX + B::MAX; - | ------------- ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - diff --git a/src/test/ui/consts/const-eval/issue-65394.rs b/src/test/ui/consts/const-eval/issue-65394.rs index 2518e4ed4..e6639826c 100644 --- a/src/test/ui/consts/const-eval/issue-65394.rs +++ b/src/test/ui/consts/const-eval/issue-65394.rs @@ -4,7 +4,7 @@ // We will likely have to change this behavior before we allow `&mut` in a `const`. const _: Vec<i32> = { - let mut x = Vec::<i32>::new(); //~ ERROR destructors cannot be evaluated at compile-time + let mut x = Vec::<i32>::new(); //~ ERROR destructor of let r = &mut x; //~ ERROR mutable references are not allowed in constants let y = x; y diff --git a/src/test/ui/consts/const-eval/issue-65394.stderr b/src/test/ui/consts/const-eval/issue-65394.stderr index ec229d7f5..ae6f0e937 100644 --- a/src/test/ui/consts/const-eval/issue-65394.stderr +++ b/src/test/ui/consts/const-eval/issue-65394.stderr @@ -7,11 +7,11 @@ LL | let r = &mut x; = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Vec<i32>` cannot be evaluated at compile-time --> $DIR/issue-65394.rs:7:9 | LL | let mut x = Vec::<i32>::new(); - | ^^^^^ constants cannot evaluate destructors + | ^^^^^ the destructor for this type cannot be evaluated in constants ... LL | }; | - value is dropped here diff --git a/src/test/ui/consts/const-eval/livedrop.rs b/src/test/ui/consts/const-eval/livedrop.rs index 66b7d0580..543f1f0ec 100644 --- a/src/test/ui/consts/const-eval/livedrop.rs +++ b/src/test/ui/consts/const-eval/livedrop.rs @@ -1,6 +1,6 @@ const _: Option<Vec<i32>> = { let mut never_returned = Some(Vec::new()); - let mut always_returned = None; //~ ERROR destructors cannot be evaluated at compile-time + let mut always_returned = None; //~ ERROR destructor of let mut i = 0; loop { diff --git a/src/test/ui/consts/const-eval/livedrop.stderr b/src/test/ui/consts/const-eval/livedrop.stderr index 1e8b4230c..d04fdb70e 100644 --- a/src/test/ui/consts/const-eval/livedrop.stderr +++ b/src/test/ui/consts/const-eval/livedrop.stderr @@ -1,8 +1,8 @@ -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `Option<Vec<i32>>` cannot be evaluated at compile-time --> $DIR/livedrop.rs:3:9 | LL | let mut always_returned = None; - | ^^^^^^^^^^^^^^^^^^^ constants cannot evaluate destructors + | ^^^^^^^^^^^^^^^^^^^ the destructor for this type cannot be evaluated in constants ... LL | always_returned = never_returned; | --------------- value is dropped here diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs index 80b0a1432..d2a840932 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs @@ -1,7 +1,6 @@ // build-fail // Regression test for #66975 -#![warn(const_err)] #![feature(never_type)] struct PrintName; diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr index b26286411..4204d302b 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -1,13 +1,13 @@ error[E0080]: evaluation of constant value failed - --> $DIR/panic-assoc-never-type.rs:10:21 + --> $DIR/panic-assoc-never-type.rs:9:21 | LL | const VOID: ! = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-assoc-never-type.rs:10:21 + | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-assoc-never-type.rs:9:21 | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: erroneous constant used - --> $DIR/panic-assoc-never-type.rs:15:13 + --> $DIR/panic-assoc-never-type.rs:14:13 | LL | let _ = PrintName::VOID; | ^^^^^^^^^^^^^^^ referenced constant has errors diff --git a/src/test/ui/consts/const-eval/panic-never-type.rs b/src/test/ui/consts/const-eval/panic-never-type.rs index a74d3ba29..a9e9026d9 100644 --- a/src/test/ui/consts/const-eval/panic-never-type.rs +++ b/src/test/ui/consts/const-eval/panic-never-type.rs @@ -1,5 +1,4 @@ // Regression test for #66975 -#![warn(const_err)] #![feature(never_type)] const VOID: ! = panic!(); diff --git a/src/test/ui/consts/const-eval/panic-never-type.stderr b/src/test/ui/consts/const-eval/panic-never-type.stderr index 9728aed07..6bff14a45 100644 --- a/src/test/ui/consts/const-eval/panic-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-never-type.stderr @@ -1,8 +1,8 @@ error[E0080]: evaluation of constant value failed - --> $DIR/panic-never-type.rs:5:17 + --> $DIR/panic-never-type.rs:4:17 | LL | const VOID: ! = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-never-type.rs:5:17 + | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-never-type.rs:4:17 | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/consts/const-eval/partial_ptr_overwrite.rs b/src/test/ui/consts/const-eval/partial_ptr_overwrite.rs index 07bca7d64..d6c768868 100644 --- a/src/test/ui/consts/const-eval/partial_ptr_overwrite.rs +++ b/src/test/ui/consts/const-eval/partial_ptr_overwrite.rs @@ -5,9 +5,8 @@ const PARTIAL_OVERWRITE: () = { let mut p = &42; unsafe { let ptr: *mut _ = &mut p; - *(ptr as *mut u8) = 123; //~ ERROR any use of this value + *(ptr as *mut u8) = 123; //~ ERROR constant //~| unable to overwrite parts of a pointer - //~| WARN previously accepted } let x = *p; }; diff --git a/src/test/ui/consts/const-eval/partial_ptr_overwrite.stderr b/src/test/ui/consts/const-eval/partial_ptr_overwrite.stderr index 75e50a27b..13ca4379b 100644 --- a/src/test/ui/consts/const-eval/partial_ptr_overwrite.stderr +++ b/src/test/ui/consts/const-eval/partial_ptr_overwrite.stderr @@ -1,33 +1,12 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/partial_ptr_overwrite.rs:8:9 | -LL | const PARTIAL_OVERWRITE: () = { - | --------------------------- -... LL | *(ptr as *mut u8) = 123; | ^^^^^^^^^^^^^^^^^^^^^^^ unable to overwrite parts of a pointer in memory at alloc4 | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: aborting due to previous error -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/partial_ptr_overwrite.rs:8:9 - | -LL | const PARTIAL_OVERWRITE: () = { - | --------------------------- -... -LL | *(ptr as *mut u8) = 123; - | ^^^^^^^^^^^^^^^^^^^^^^^ unable to overwrite parts of a pointer in memory at alloc4 - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs b/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs index 1fc7af637..656dd33e1 100644 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs +++ b/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs @@ -1,5 +1,3 @@ -#![allow(const_err)] - #[repr(C)] union Bar { a: &'static u8, diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr b/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr index c6ca30e09..596fa090d 100644 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr +++ b/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_fn_fail.rs:19:27 + --> $DIR/promoted_const_fn_fail.rs:17:27 | LL | let x: &'static u8 = &(bar() + 1); | ----------- ^^^^^^^^^^^ creates a temporary which is freed while still in use diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.rs b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.rs index c53424664..5009dbcb9 100644 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.rs +++ b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.rs @@ -1,5 +1,3 @@ -#![deny(const_err)] - #[repr(C)] union Bar { a: &'static u8, diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr index c6275a835..63dc43a41 100644 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr +++ b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_fn_fail_deny_const_err.rs:20:27 + --> $DIR/promoted_const_fn_fail_deny_const_err.rs:18:27 | LL | let x: &'static u8 = &(bar() + 1); | ----------- ^^^^^^^^^^^ creates a temporary which is freed while still in use diff --git a/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr b/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr index cfca8ef07..2a254bfde 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr @@ -5,111 +5,40 @@ LL | 0 - 1 | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow | note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:20 + --> $DIR/promoted_errors.rs:11:9 | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^^^^^^^^^^^ +LL | #![warn(arithmetic_overflow, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:21:5 + --> $DIR/promoted_errors.rs:19:5 | LL | 1 / 0 | ^^^^^ attempt to divide `1_i32` by zero | note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:41 + --> $DIR/promoted_errors.rs:11:30 | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^^^^^^^^^^^ +LL | #![warn(arithmetic_overflow, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:27:5 + --> $DIR/promoted_errors.rs:23:5 | LL | 1 / (1 - 1) | ^^^^^^^^^^^ attempt to divide `1_i32` by zero warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:31:5 + --> $DIR/promoted_errors.rs:27:5 | LL | 1 / (false as i32) | ^^^^^^^^^^^^^^^^^^ attempt to divide `1_i32` by zero warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:35:5 + --> $DIR/promoted_errors.rs:31:5 | LL | [1, 2, 3][4] | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:15:5 - | -LL | 0 - 1 - | ^^^^^ - | | - | attempt to compute `0_u32 - 1_u32`, which would overflow - | inside `overflow` at $DIR/promoted_errors.rs:15:5 - | inside `X` at $DIR/promoted_errors.rs:43:29 -... -LL | const X: () = { - | ----------- - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:9 - | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:43:28 - | -LL | const X: () = { - | ----------- -LL | let _x: &'static u32 = &overflow(); - | ^^^^^^^^^^^ referenced constant has errors - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -warning: 7 warnings emitted - -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:15:5 - | -LL | 0 - 1 - | ^^^^^ - | | - | attempt to compute `0_u32 - 1_u32`, which would overflow - | inside `overflow` at $DIR/promoted_errors.rs:15:5 - | inside `X` at $DIR/promoted_errors.rs:43:29 -... -LL | const X: () = { - | ----------- - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:9 - | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:43:28 - | -LL | const X: () = { - | ----------- -LL | let _x: &'static u32 = &overflow(); - | ^^^^^^^^^^^ referenced constant has errors - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:9 - | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> +warning: 5 warnings emitted diff --git a/src/test/ui/consts/const-eval/promoted_errors.opt.stderr b/src/test/ui/consts/const-eval/promoted_errors.opt.stderr index 984484a85..2a254bfde 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.opt.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.opt.stderr @@ -5,113 +5,40 @@ LL | 0 - 1 | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow | note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:20 + --> $DIR/promoted_errors.rs:11:9 | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^^^^^^^^^^^ +LL | #![warn(arithmetic_overflow, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:21:5 + --> $DIR/promoted_errors.rs:19:5 | LL | 1 / 0 | ^^^^^ attempt to divide `1_i32` by zero | note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:41 + --> $DIR/promoted_errors.rs:11:30 | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^^^^^^^^^^^ +LL | #![warn(arithmetic_overflow, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:27:5 + --> $DIR/promoted_errors.rs:23:5 | LL | 1 / (1 - 1) | ^^^^^^^^^^^ attempt to divide `1_i32` by zero warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:31:5 + --> $DIR/promoted_errors.rs:27:5 | LL | 1 / (false as i32) | ^^^^^^^^^^^^^^^^^^ attempt to divide `1_i32` by zero warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:35:5 + --> $DIR/promoted_errors.rs:31:5 | LL | [1, 2, 3][4] | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:21:5 - | -LL | 1 / 0 - | ^^^^^ - | | - | attempt to divide `1_i32` by zero - | inside `div_by_zero1` at $DIR/promoted_errors.rs:21:5 - | inside `X` at $DIR/promoted_errors.rs:46:29 -... -LL | const X: () = { - | ----------- - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:9 - | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:46:28 - | -LL | const X: () = { - | ----------- -... -LL | let _x: &'static i32 = &div_by_zero1(); - | ^^^^^^^^^^^^^^^ referenced constant has errors - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -warning: 7 warnings emitted - -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:21:5 - | -LL | 1 / 0 - | ^^^^^ - | | - | attempt to divide `1_i32` by zero - | inside `div_by_zero1` at $DIR/promoted_errors.rs:21:5 - | inside `X` at $DIR/promoted_errors.rs:46:29 -... -LL | const X: () = { - | ----------- - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:9 - | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:46:28 - | -LL | const X: () = { - | ----------- -... -LL | let _x: &'static i32 = &div_by_zero1(); - | ^^^^^^^^^^^^^^^ referenced constant has errors - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:9 - | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> +warning: 5 warnings emitted diff --git a/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr b/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr index cfca8ef07..2a254bfde 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr @@ -5,111 +5,40 @@ LL | 0 - 1 | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow | note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:20 + --> $DIR/promoted_errors.rs:11:9 | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^^^^^^^^^^^ +LL | #![warn(arithmetic_overflow, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:21:5 + --> $DIR/promoted_errors.rs:19:5 | LL | 1 / 0 | ^^^^^ attempt to divide `1_i32` by zero | note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:41 + --> $DIR/promoted_errors.rs:11:30 | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^^^^^^^^^^^ +LL | #![warn(arithmetic_overflow, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:27:5 + --> $DIR/promoted_errors.rs:23:5 | LL | 1 / (1 - 1) | ^^^^^^^^^^^ attempt to divide `1_i32` by zero warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:31:5 + --> $DIR/promoted_errors.rs:27:5 | LL | 1 / (false as i32) | ^^^^^^^^^^^^^^^^^^ attempt to divide `1_i32` by zero warning: this operation will panic at runtime - --> $DIR/promoted_errors.rs:35:5 + --> $DIR/promoted_errors.rs:31:5 | LL | [1, 2, 3][4] | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:15:5 - | -LL | 0 - 1 - | ^^^^^ - | | - | attempt to compute `0_u32 - 1_u32`, which would overflow - | inside `overflow` at $DIR/promoted_errors.rs:15:5 - | inside `X` at $DIR/promoted_errors.rs:43:29 -... -LL | const X: () = { - | ----------- - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:9 - | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:43:28 - | -LL | const X: () = { - | ----------- -LL | let _x: &'static u32 = &overflow(); - | ^^^^^^^^^^^ referenced constant has errors - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -warning: 7 warnings emitted - -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:15:5 - | -LL | 0 - 1 - | ^^^^^ - | | - | attempt to compute `0_u32 - 1_u32`, which would overflow - | inside `overflow` at $DIR/promoted_errors.rs:15:5 - | inside `X` at $DIR/promoted_errors.rs:43:29 -... -LL | const X: () = { - | ----------- - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:9 - | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:43:28 - | -LL | const X: () = { - | ----------- -LL | let _x: &'static u32 = &overflow(); - | ^^^^^^^^^^^ referenced constant has errors - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:11:9 - | -LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> +warning: 5 warnings emitted diff --git a/src/test/ui/consts/const-eval/promoted_errors.rs b/src/test/ui/consts/const-eval/promoted_errors.rs index eb891de33..2c42d0356 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.rs +++ b/src/test/ui/consts/const-eval/promoted_errors.rs @@ -8,20 +8,16 @@ //! This test ensures that when we promote code that fails to evaluate, the build still succeeds. -#![warn(const_err, arithmetic_overflow, unconditional_panic)] +#![warn(arithmetic_overflow, unconditional_panic)] // The only way to have promoteds that fail is in `const fn` called from `const`/`static`. const fn overflow() -> u32 { 0 - 1 - //[opt_with_overflow_checks,noopt]~^ WARN any use of this value will cause an error - //[opt_with_overflow_checks,noopt]~| WARN this was previously accepted by the compiler - //~^^^ WARN this arithmetic operation will overflow + //~^ WARN this arithmetic operation will overflow } const fn div_by_zero1() -> i32 { 1 / 0 - //[opt]~^ WARN any use of this value will cause an error - //[opt]~| WARN this was previously accepted by the compiler but is being phased out - //~^^^ WARN this operation will panic at runtime + //~^ WARN this operation will panic at runtime } const fn div_by_zero2() -> i32 { 1 / (1 - 1) @@ -36,21 +32,6 @@ const fn oob() -> i32 { //~^ WARN this operation will panic at runtime } -// An unused constant containing failing promoteds. -// This should work as long as `const_err` can be turned into just a warning; -// once it turns into a hard error, just remove `X`. -const X: () = { - let _x: &'static u32 = &overflow(); - //[opt_with_overflow_checks,noopt]~^ WARN any use of this value will cause an error - //[opt_with_overflow_checks,noopt]~| WARN this was previously accepted by the compiler - let _x: &'static i32 = &div_by_zero1(); - //[opt]~^ WARN any use of this value will cause an error - //[opt]~| WARN this was previously accepted by the compiler but is being phased out - let _x: &'static i32 = &div_by_zero2(); - let _x: &'static i32 = &div_by_zero3(); - let _x: &'static i32 = &oob(); -}; - const fn mk_false() -> bool { false } // An actually used constant referencing failing promoteds in dead code. diff --git a/src/test/ui/consts/const-eval/pub_const_err.rs b/src/test/ui/consts/const-eval/pub_const_err.rs deleted file mode 100644 index 5faacd556..000000000 --- a/src/test/ui/consts/const-eval/pub_const_err.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass -#![warn(const_err)] - -#![crate_type = "lib"] - -pub const Z: u32 = 0 - 1; -//~^ WARN any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out - -pub type Foo = [i32; 0 - 1]; diff --git a/src/test/ui/consts/const-eval/pub_const_err.stderr b/src/test/ui/consts/const-eval/pub_const_err.stderr deleted file mode 100644 index 36197a7ab..000000000 --- a/src/test/ui/consts/const-eval/pub_const_err.stderr +++ /dev/null @@ -1,31 +0,0 @@ -warning: any use of this value will cause an error - --> $DIR/pub_const_err.rs:6:20 - | -LL | pub const Z: u32 = 0 - 1; - | ---------------- ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/pub_const_err.rs:2:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -warning: 1 warning emitted - -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/pub_const_err.rs:6:20 - | -LL | pub const Z: u32 = 0 - 1; - | ---------------- ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/pub_const_err.rs:2:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - diff --git a/src/test/ui/consts/const-eval/pub_const_err_bin.rs b/src/test/ui/consts/const-eval/pub_const_err_bin.rs deleted file mode 100644 index 82eae2512..000000000 --- a/src/test/ui/consts/const-eval/pub_const_err_bin.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass -#![warn(const_err)] - -pub const Z: u32 = 0 - 1; -//~^ WARN any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out - -pub type Foo = [i32; 0 - 1]; - -fn main() {} diff --git a/src/test/ui/consts/const-eval/pub_const_err_bin.stderr b/src/test/ui/consts/const-eval/pub_const_err_bin.stderr deleted file mode 100644 index 2eef3b8f5..000000000 --- a/src/test/ui/consts/const-eval/pub_const_err_bin.stderr +++ /dev/null @@ -1,31 +0,0 @@ -warning: any use of this value will cause an error - --> $DIR/pub_const_err_bin.rs:4:20 - | -LL | pub const Z: u32 = 0 - 1; - | ---------------- ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/pub_const_err_bin.rs:2:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -warning: 1 warning emitted - -Future incompatibility report: Future breakage diagnostic: -warning: any use of this value will cause an error - --> $DIR/pub_const_err_bin.rs:4:20 - | -LL | pub const Z: u32 = 0 - 1; - | ---------------- ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - | -note: the lint level is defined here - --> $DIR/pub_const_err_bin.rs:2:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - diff --git a/src/test/ui/consts/const-eval/ref_to_int_match.32bit.stderr b/src/test/ui/consts/const-eval/ref_to_int_match.32bit.stderr index 30935e415..032ceb246 100644 --- a/src/test/ui/consts/const-eval/ref_to_int_match.32bit.stderr +++ b/src/test/ui/consts/const-eval/ref_to_int_match.32bit.stderr @@ -1,12 +1,9 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/ref_to_int_match.rs:25:27 | LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; - | -------------- ^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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 @@ -24,16 +21,4 @@ LL | 10..=BAR => {}, error: aborting due to 3 previous errors -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ref_to_int_match.rs:25:27 - | -LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; - | -------------- ^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/ref_to_int_match.64bit.stderr b/src/test/ui/consts/const-eval/ref_to_int_match.64bit.stderr index 30935e415..032ceb246 100644 --- a/src/test/ui/consts/const-eval/ref_to_int_match.64bit.stderr +++ b/src/test/ui/consts/const-eval/ref_to_int_match.64bit.stderr @@ -1,12 +1,9 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/ref_to_int_match.rs:25:27 | LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; - | -------------- ^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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 @@ -24,16 +21,4 @@ LL | 10..=BAR => {}, error: aborting due to 3 previous errors -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ref_to_int_match.rs:25:27 - | -LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; - | -------------- ^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/ref_to_int_match.rs b/src/test/ui/consts/const-eval/ref_to_int_match.rs index 3f342d916..70c6e7d94 100644 --- a/src/test/ui/consts/const-eval/ref_to_int_match.rs +++ b/src/test/ui/consts/const-eval/ref_to_int_match.rs @@ -23,5 +23,4 @@ type Int = u64; type Int = u32; const BAR: Int = unsafe { Foo { r: &42 }.f }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR constant diff --git a/src/test/ui/consts/const-eval/ub-enum.32bit.stderr b/src/test/ui/consts/const-eval/ub-enum.32bit.stderr index 752fd01f3..93bc96e67 100644 --- a/src/test/ui/consts/const-eval/ub-enum.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-enum.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:23:1 + --> $DIR/ub-enum.rs:24:1 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x00000001, but expected a valid enum tag @@ -9,31 +9,26 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; 01 00 00 00 │ .... } -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:26:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum.rs:27:1 | LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:30:1 | LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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:43:1 + --> $DIR/ub-enum.rs:42:1 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x00000000, but expected a valid enum tag @@ -43,47 +38,41 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; 00 00 00 00 │ .... } -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:45:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum.rs:44:1 | LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/ub-enum.rs:49:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum.rs:47:1 | LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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:59:42 + --> $DIR/ub-enum.rs:56:42 | LL | const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:64:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum.rs:61:1 | LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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:82:1 + --> $DIR/ub-enum.rs:78:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(B)>.0: encountered a value of the never type `!` @@ -94,7 +83,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:84:1 + --> $DIR/ub-enum.rs:80:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type Never @@ -105,7 +94,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:92:1 + --> $DIR/ub-enum.rs:88: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`) @@ -116,13 +105,13 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran } error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:97:77 + --> $DIR/ub-enum.rs:93:77 | LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; | ^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:99:77 + --> $DIR/ub-enum.rs:95:77 | LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; | ^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type @@ -130,68 +119,3 @@ LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { error: aborting due to 13 previous errors For more information about this error, try `rustc --explain E0080`. -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:26:1 - | -LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:30:1 - | -LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:45:1 - | -LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:49:1 - | -LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:64:1 - | -LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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/src/test/ui/consts/const-eval/ub-enum.64bit.stderr b/src/test/ui/consts/const-eval/ub-enum.64bit.stderr index 3f1546a27..280ba25a8 100644 --- a/src/test/ui/consts/const-eval/ub-enum.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-enum.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:23:1 + --> $DIR/ub-enum.rs:24:1 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x0000000000000001, but expected a valid enum tag @@ -9,31 +9,26 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; 01 00 00 00 00 00 00 00 │ ........ } -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:26:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum.rs:27:1 | LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:30:1 | LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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:43:1 + --> $DIR/ub-enum.rs:42:1 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x0000000000000000, but expected a valid enum tag @@ -43,47 +38,41 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; 00 00 00 00 00 00 00 00 │ ........ } -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:45:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum.rs:44:1 | LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/ub-enum.rs:49:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum.rs:47:1 | LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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:59:42 + --> $DIR/ub-enum.rs:56:42 | LL | const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:64:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-enum.rs:61:1 | LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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:82:1 + --> $DIR/ub-enum.rs:78:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(B)>.0: encountered a value of the never type `!` @@ -94,7 +83,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:84:1 + --> $DIR/ub-enum.rs:80:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type Never @@ -105,7 +94,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:92:1 + --> $DIR/ub-enum.rs:88: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`) @@ -116,13 +105,13 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran } error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:97:77 + --> $DIR/ub-enum.rs:93:77 | LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; | ^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:99:77 + --> $DIR/ub-enum.rs:95:77 | LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; | ^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type @@ -130,68 +119,3 @@ LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { error: aborting due to 13 previous errors For more information about this error, try `rustc --explain E0080`. -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:26:1 - | -LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:30:1 - | -LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:45:1 - | -LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:49:1 - | -LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-enum.rs:64:1 - | -LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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/src/test/ui/consts/const-eval/ub-enum.rs b/src/test/ui/consts/const-eval/ub-enum.rs index d8dc6d057..6935be2f9 100644 --- a/src/test/ui/consts/const-eval/ub-enum.rs +++ b/src/test/ui/consts/const-eval/ub-enum.rs @@ -1,5 +1,6 @@ // stderr-per-bitwidth #![feature(never_type)] +#![allow(invalid_value)] use std::mem; @@ -24,12 +25,10 @@ const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; //~^ ERROR is undefined behavior const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed // # simple enum with discriminant 2 @@ -43,12 +42,10 @@ enum Enum2 { const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; //~^ ERROR is undefined behavior const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed // something wrapping the enum so that we test layout first, not enum const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed // Undef enum discriminant. #[repr(C)] @@ -62,8 +59,7 @@ const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init }; // 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 any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed // # valid discriminant for uninhabited variant diff --git a/src/test/ui/consts/const-eval/ub-int-array.32bit.stderr b/src/test/ui/consts/const-eval/ub-int-array.32bit.stderr index 6100a98d1..edcde13b0 100644 --- a/src/test/ui/consts/const-eval/ub-int-array.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-int-array.32bit.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of constant value failed - --> $DIR/ub-int-array.rs:16:9 + --> $DIR/ub-int-array.rs:15:9 | LL | MaybeUninit { uninit: () }.init, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: evaluation of constant value failed - --> $DIR/ub-int-array.rs:31:13 + --> $DIR/ub-int-array.rs:30:13 | LL | MaybeUninit { uninit: () }.init, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: evaluation of constant value failed - --> $DIR/ub-int-array.rs:57:13 + --> $DIR/ub-int-array.rs:56:13 | LL | MaybeUninit { uninit: () }.init, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory diff --git a/src/test/ui/consts/const-eval/ub-int-array.64bit.stderr b/src/test/ui/consts/const-eval/ub-int-array.64bit.stderr index 6100a98d1..edcde13b0 100644 --- a/src/test/ui/consts/const-eval/ub-int-array.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-int-array.64bit.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of constant value failed - --> $DIR/ub-int-array.rs:16:9 + --> $DIR/ub-int-array.rs:15:9 | LL | MaybeUninit { uninit: () }.init, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: evaluation of constant value failed - --> $DIR/ub-int-array.rs:31:13 + --> $DIR/ub-int-array.rs:30:13 | LL | MaybeUninit { uninit: () }.init, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: evaluation of constant value failed - --> $DIR/ub-int-array.rs:57:13 + --> $DIR/ub-int-array.rs:56:13 | LL | MaybeUninit { uninit: () }.init, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory diff --git a/src/test/ui/consts/const-eval/ub-int-array.rs b/src/test/ui/consts/const-eval/ub-int-array.rs index cb85e3b01..a68d3fb17 100644 --- a/src/test/ui/consts/const-eval/ub-int-array.rs +++ b/src/test/ui/consts/const-eval/ub-int-array.rs @@ -1,4 +1,3 @@ -#![allow(const_err)] // make sure we cannot allow away the errors tested here // stderr-per-bitwidth //! Test the "array of int" fast path in validity checking, and in particular whether it //! points at the right array element. diff --git a/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr b/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr index 693c0e99b..dbd05b8f4 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-nonnull.32bit.stderr @@ -10,13 +10,13 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-nonnull.rs:19:30 + --> $DIR/ub-nonnull.rs:18:30 | LL | let out_of_bounds_ptr = &ptr[255]; | ^^^^^^^^ dereferencing pointer failed: alloc11 has size 1, so pointer to 256 bytes starting at offset 0 is out-of-bounds error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:23:1 + --> $DIR/ub-nonnull.rs:22:1 | LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 @@ -27,7 +27,7 @@ LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:25:1 + --> $DIR/ub-nonnull.rs:24:1 | LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 @@ -38,13 +38,13 @@ LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-nonnull.rs:33:36 + --> $DIR/ub-nonnull.rs:32:36 | LL | const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:42:1 + --> $DIR/ub-nonnull.rs:41:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30 @@ -55,7 +55,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:48:1 + --> $DIR/ub-nonnull.rs:47: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 diff --git a/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr b/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr index d22191213..5a1ac09bd 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-nonnull.64bit.stderr @@ -10,13 +10,13 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-nonnull.rs:19:30 + --> $DIR/ub-nonnull.rs:18:30 | LL | let out_of_bounds_ptr = &ptr[255]; | ^^^^^^^^ dereferencing pointer failed: alloc11 has size 1, so pointer to 256 bytes starting at offset 0 is out-of-bounds error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:23:1 + --> $DIR/ub-nonnull.rs:22:1 | LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 @@ -27,7 +27,7 @@ LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:25:1 + --> $DIR/ub-nonnull.rs:24:1 | LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 @@ -38,13 +38,13 @@ LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-nonnull.rs:33:36 + --> $DIR/ub-nonnull.rs:32:36 | LL | const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:42:1 + --> $DIR/ub-nonnull.rs:41:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30 @@ -55,7 +55,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:48:1 + --> $DIR/ub-nonnull.rs:47: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 diff --git a/src/test/ui/consts/const-eval/ub-nonnull.rs b/src/test/ui/consts/const-eval/ub-nonnull.rs index 777c6d988..d22a99cd0 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.rs +++ b/src/test/ui/consts/const-eval/ub-nonnull.rs @@ -1,6 +1,6 @@ // stderr-per-bitwidth #![feature(rustc_attrs)] -#![allow(const_err, invalid_value)] // make sure we cannot allow away the errors tested here +#![allow(invalid_value)] // make sure we cannot allow away the errors tested here use std::mem; use std::ptr::NonNull; @@ -12,7 +12,6 @@ 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 -#[deny(const_err)] // this triggers a `const_err` so validation does not even happen 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! diff --git a/src/test/ui/consts/const-eval/ub-ref-ptr.32bit.stderr b/src/test/ui/consts/const-eval/ub-ref-ptr.32bit.stderr index 3e93219c8..6f5c028cb 100644 --- a/src/test/ui/consts/const-eval/ub-ref-ptr.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-ref-ptr.32bit.stderr @@ -42,60 +42,47 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; 00 00 00 00 │ .... } -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/ub-ref-ptr.rs:31:1 | LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:35:39 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:34:39 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ---------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:35:38 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:34:38 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ---------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:41:86 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:38:86 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ------------------------------------------ ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:41:85 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:38:85 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ------------------------------------------ ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:47:1 + --> $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 (address 0x539 is unallocated) @@ -106,7 +93,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:50:1 + --> $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 (address 0x539 is unallocated) @@ -117,13 +104,13 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:53:41 + --> $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 error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:57:1 + --> $DIR/ub-ref-ptr.rs:52:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer @@ -134,13 +121,13 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:59:38 + --> $DIR/ub-ref-ptr.rs:54:38 | LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:62:1 + --> $DIR/ub-ref-ptr.rs:57:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer @@ -151,7 +138,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:64:1 + --> $DIR/ub-ref-ptr.rs:59:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered alloc41, but expected a function pointer @@ -164,64 +151,3 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; error: aborting due to 16 previous errors For more information about this error, try `rustc --explain E0080`. -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:31:1 - | -LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:35:39 - | -LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ---------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:35:38 - | -LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ---------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:41:86 - | -LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ------------------------------------------ ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:41:85 - | -LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ------------------------------------------ ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - diff --git a/src/test/ui/consts/const-eval/ub-ref-ptr.64bit.stderr b/src/test/ui/consts/const-eval/ub-ref-ptr.64bit.stderr index bc2aa12a2..5ffb710d4 100644 --- a/src/test/ui/consts/const-eval/ub-ref-ptr.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-ref-ptr.64bit.stderr @@ -42,60 +42,47 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; 00 00 00 00 00 00 00 00 │ ........ } -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $DIR/ub-ref-ptr.rs:31:1 | LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:35:39 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:34:39 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ---------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:35:38 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:34:38 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ---------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:41:86 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:38:86 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ------------------------------------------ ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes + | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:41:85 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-ref-ptr.rs:38:85 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ------------------------------------------ ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:47:1 + --> $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 (address 0x539 is unallocated) @@ -106,7 +93,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:50:1 + --> $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 (address 0x539 is unallocated) @@ -117,13 +104,13 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:53:41 + --> $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 error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:57:1 + --> $DIR/ub-ref-ptr.rs:52:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer @@ -134,13 +121,13 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:59:38 + --> $DIR/ub-ref-ptr.rs:54:38 | LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:62:1 + --> $DIR/ub-ref-ptr.rs:57:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer @@ -151,7 +138,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:64:1 + --> $DIR/ub-ref-ptr.rs:59:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered alloc41, but expected a function pointer @@ -164,64 +151,3 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; error: aborting due to 16 previous errors For more information about this error, try `rustc --explain E0080`. -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:31:1 - | -LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:35:39 - | -LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ---------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:35:38 - | -LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ---------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:41:86 - | -LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ------------------------------------------ ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-ref-ptr.rs:41:85 - | -LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ------------------------------------------ ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - diff --git a/src/test/ui/consts/const-eval/ub-ref-ptr.rs b/src/test/ui/consts/const-eval/ub-ref-ptr.rs index c62848f70..92049d4c1 100644 --- a/src/test/ui/consts/const-eval/ub-ref-ptr.rs +++ b/src/test/ui/consts/const-eval/ub-ref-ptr.rs @@ -29,20 +29,15 @@ const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; // 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 any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out -//~| ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed +//~| ERROR evaluation of constant value failed const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out -//~| ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed +//~| ERROR evaluation of constant value failed const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; //~^ ERROR it is undefined behavior to use this value diff --git a/src/test/ui/consts/const-eval/ub-uninhabit.32bit.stderr b/src/test/ui/consts/const-eval/ub-uninhabit.32bit.stderr index 7f0feb130..7d3232257 100644 --- a/src/test/ui/consts/const-eval/ub-uninhabit.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-uninhabit.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:15:1 + --> $DIR/ub-uninhabit.rs:14:1 | LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type Bar @@ -8,7 +8,7 @@ LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; = note: the raw bytes of the constant (size: 0, align: 1) {} error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:18:1 + --> $DIR/ub-uninhabit.rs:17:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar @@ -19,7 +19,7 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:21:1 + --> $DIR/ub-uninhabit.rs:20:1 | LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type Bar diff --git a/src/test/ui/consts/const-eval/ub-uninhabit.64bit.stderr b/src/test/ui/consts/const-eval/ub-uninhabit.64bit.stderr index 4dcbbc2f5..2b7659f5d 100644 --- a/src/test/ui/consts/const-eval/ub-uninhabit.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-uninhabit.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:15:1 + --> $DIR/ub-uninhabit.rs:14:1 | LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type Bar @@ -8,7 +8,7 @@ LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; = note: the raw bytes of the constant (size: 0, align: 1) {} error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:18:1 + --> $DIR/ub-uninhabit.rs:17:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar @@ -19,7 +19,7 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:21:1 + --> $DIR/ub-uninhabit.rs:20:1 | LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type Bar diff --git a/src/test/ui/consts/const-eval/ub-uninhabit.rs b/src/test/ui/consts/const-eval/ub-uninhabit.rs index 33fbd14c4..213f15b79 100644 --- a/src/test/ui/consts/const-eval/ub-uninhabit.rs +++ b/src/test/ui/consts/const-eval/ub-uninhabit.rs @@ -1,5 +1,4 @@ // stderr-per-bitwidth -#![allow(const_err)] // make sure we cannot allow away the errors tested here use std::mem; diff --git a/src/test/ui/consts/const-eval/ub-upvars.rs b/src/test/ui/consts/const-eval/ub-upvars.rs index 57dd7b9e5..ceac59870 100644 --- a/src/test/ui/consts/const-eval/ub-upvars.rs +++ b/src/test/ui/consts/const-eval/ub-upvars.rs @@ -1,5 +1,5 @@ // stderr-per-bitwidth -#![allow(const_err, invalid_value)] // make sure we cannot allow away the errors tested here +#![allow(invalid_value)] // make sure we cannot allow away the errors tested here use std::mem; diff --git a/src/test/ui/consts/const-eval/ub-wide-ptr.32bit.stderr b/src/test/ui/consts/const-eval/ub-wide-ptr.32bit.stderr index 4cd974e7b..c8b46608d 100644 --- a/src/test/ui/consts/const-eval/ub-wide-ptr.32bit.stderr +++ b/src/test/ui/consts/const-eval/ub-wide-ptr.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:37:1 + --> $DIR/ub-wide-ptr.rs:36: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) @@ -10,7 +10,7 @@ LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:39:1 + --> $DIR/ub-wide-ptr.rs:38: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 @@ -20,31 +20,26 @@ LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, us ╾─allocN─╼ ff ff ff ff │ ╾──╼.... } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:42:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:41:1 | LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:46:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:44:1 | LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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:49:1 + --> $DIR/ub-wide-ptr.rs:46: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 @@ -55,7 +50,7 @@ LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize: } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:53:1 + --> $DIR/ub-wide-ptr.rs:50:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized data in `str` @@ -66,7 +61,7 @@ LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit: } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:56:1 + --> $DIR/ub-wide-ptr.rs:53:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered uninitialized data in `str` @@ -77,13 +72,13 @@ LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUni } error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:63:1 + --> $DIR/ub-wide-ptr.rs:60:1 | LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:70:1 + --> $DIR/ub-wide-ptr.rs:67: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) @@ -94,7 +89,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:73:1 + --> $DIR/ub-wide-ptr.rs:70: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 @@ -104,19 +99,17 @@ LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, is ╾─allocN─╼ ff ff ff 7f │ ╾──╼.... } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:76:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:73:1 | LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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:80:1 + --> $DIR/ub-wide-ptr.rs:76: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) @@ -126,19 +119,17 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us ╾─allocN─╼ e7 03 00 00 │ ╾──╼.... } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:83:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:79:1 | LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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:88:1 + --> $DIR/ub-wide-ptr.rs:83:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean @@ -148,17 +139,14 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; ╾─allocN─╼ │ ╾──╼ } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:88:40 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:83:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ------------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:96:1 + --> $DIR/ub-wide-ptr.rs:90: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 @@ -168,17 +156,14 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 ╾allocN─╼ │ ╾──╼ } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:96:42 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:90:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); - | -------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:101:1 + --> $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 @@ -188,23 +173,20 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran ╾allocN─╼ │ ╾──╼ } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:101:42 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:94:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); - | -------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:110:1 + --> $DIR/ub-wide-ptr.rs:102:1 | LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:119:1 + --> $DIR/ub-wide-ptr.rs:111:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer @@ -215,7 +197,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W(( } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:123:1 + --> $DIR/ub-wide-ptr.rs:115:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer @@ -226,7 +208,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W(( } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:127:1 + --> $DIR/ub-wide-ptr.rs:119: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 @@ -237,25 +219,25 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u } error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:130:57 + --> $DIR/ub-wide-ptr.rs:122:57 | LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:133:57 + --> $DIR/ub-wide-ptr.rs:125:57 | LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:136:56 + --> $DIR/ub-wide-ptr.rs:128:56 | LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:139:1 + --> $DIR/ub-wide-ptr.rs:131: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 allocN, but expected a vtable pointer @@ -266,7 +248,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::trans } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:144:1 + --> $DIR/ub-wide-ptr.rs:136: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 @@ -277,7 +259,7 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:149:1 + --> $DIR/ub-wide-ptr.rs:141: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 @@ -288,7 +270,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:151:1 + --> $DIR/ub-wide-ptr.rs:143:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered allocN, but expected a vtable pointer @@ -299,13 +281,13 @@ LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transm } error[E0080]: could not evaluate static initializer - --> $DIR/ub-wide-ptr.rs:157:5 + --> $DIR/ub-wide-ptr.rs:149:5 | LL | mem::transmute::<_, &dyn Trait>((&92u8, 0usize)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) error[E0080]: could not evaluate static initializer - --> $DIR/ub-wide-ptr.rs:161:5 + --> $DIR/ub-wide-ptr.rs:153:5 | LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable @@ -313,88 +295,3 @@ LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64)) error: aborting due to 32 previous errors For more information about this error, try `rustc --explain E0080`. -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:42:1 - | -LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:46:1 - | -LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:76:1 - | -LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:83:1 - | -LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:88:40 - | -LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ------------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:96:42 - | -LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); - | -------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:101:42 - | -LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); - | -------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - diff --git a/src/test/ui/consts/const-eval/ub-wide-ptr.64bit.stderr b/src/test/ui/consts/const-eval/ub-wide-ptr.64bit.stderr index 1d84b7bce..70574d2dc 100644 --- a/src/test/ui/consts/const-eval/ub-wide-ptr.64bit.stderr +++ b/src/test/ui/consts/const-eval/ub-wide-ptr.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:37:1 + --> $DIR/ub-wide-ptr.rs:36: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) @@ -10,7 +10,7 @@ LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:39:1 + --> $DIR/ub-wide-ptr.rs:38: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 @@ -20,31 +20,26 @@ LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, us ╾───────allocN───────╼ ff ff ff ff ff ff ff ff │ ╾──────╼........ } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:42:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:41:1 | LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:46:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:44:1 | LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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:49:1 + --> $DIR/ub-wide-ptr.rs:46: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 @@ -55,7 +50,7 @@ LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize: } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:53:1 + --> $DIR/ub-wide-ptr.rs:50:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized data in `str` @@ -66,7 +61,7 @@ LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit: } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:56:1 + --> $DIR/ub-wide-ptr.rs:53:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered uninitialized data in `str` @@ -77,13 +72,13 @@ LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUni } error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:63:1 + --> $DIR/ub-wide-ptr.rs:60:1 | LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:70:1 + --> $DIR/ub-wide-ptr.rs:67: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) @@ -94,7 +89,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:73:1 + --> $DIR/ub-wide-ptr.rs:70: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 @@ -104,19 +99,17 @@ LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, is ╾───────allocN───────╼ ff ff ff ff ff ff ff 7f │ ╾──────╼........ } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:76:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:73:1 | LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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:80:1 + --> $DIR/ub-wide-ptr.rs:76: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) @@ -126,19 +119,17 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us ╾───────allocN───────╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........ } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:83:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:79:1 | LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = 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:88:1 + --> $DIR/ub-wide-ptr.rs:83:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean @@ -148,17 +139,14 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; ╾───────allocN───────╼ │ ╾──────╼ } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:88:40 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:83:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ------------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:96:1 + --> $DIR/ub-wide-ptr.rs:90: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 @@ -168,17 +156,14 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 ╾──────allocN───────╼ │ ╾──────╼ } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:96:42 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:90:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); - | -------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:101:1 + --> $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 @@ -188,23 +173,20 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran ╾──────allocN───────╼ │ ╾──────╼ } -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:101:42 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-wide-ptr.rs:94:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); - | -------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:110:1 + --> $DIR/ub-wide-ptr.rs:102:1 | LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:119:1 + --> $DIR/ub-wide-ptr.rs:111:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer @@ -215,7 +197,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W(( } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:123:1 + --> $DIR/ub-wide-ptr.rs:115:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered allocN, but expected a vtable pointer @@ -226,7 +208,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W(( } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:127:1 + --> $DIR/ub-wide-ptr.rs:119: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 @@ -237,25 +219,25 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u } error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:130:57 + --> $DIR/ub-wide-ptr.rs:122:57 | LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:133:57 + --> $DIR/ub-wide-ptr.rs:125:57 | LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:136:56 + --> $DIR/ub-wide-ptr.rs:128:56 | LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:139:1 + --> $DIR/ub-wide-ptr.rs:131: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 allocN, but expected a vtable pointer @@ -266,7 +248,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::trans } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:144:1 + --> $DIR/ub-wide-ptr.rs:136: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 @@ -277,7 +259,7 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:149:1 + --> $DIR/ub-wide-ptr.rs:141: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 @@ -288,7 +270,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:151:1 + --> $DIR/ub-wide-ptr.rs:143:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered allocN, but expected a vtable pointer @@ -299,13 +281,13 @@ LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transm } error[E0080]: could not evaluate static initializer - --> $DIR/ub-wide-ptr.rs:157:5 + --> $DIR/ub-wide-ptr.rs:149:5 | LL | mem::transmute::<_, &dyn Trait>((&92u8, 0usize)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) error[E0080]: could not evaluate static initializer - --> $DIR/ub-wide-ptr.rs:161:5 + --> $DIR/ub-wide-ptr.rs:153:5 | LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable @@ -313,88 +295,3 @@ LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64)) error: aborting due to 32 previous errors For more information about this error, try `rustc --explain E0080`. -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:42:1 - | -LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:46:1 - | -LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:76:1 - | -LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:83:1 - | -LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = 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 - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:88:40 - | -LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ------------------------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:96:42 - | -LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); - | -------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - -Future breakage diagnostic: -error: any use of this value will cause an error - --> $DIR/ub-wide-ptr.rs:101:42 - | -LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); - | -------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - diff --git a/src/test/ui/consts/const-eval/ub-wide-ptr.rs b/src/test/ui/consts/const-eval/ub-wide-ptr.rs index 788403a6d..65f6f0235 100644 --- a/src/test/ui/consts/const-eval/ub-wide-ptr.rs +++ b/src/test/ui/consts/const-eval/ub-wide-ptr.rs @@ -9,8 +9,7 @@ use std::mem; // normalize-stderr-test "size \d+" -> "size N" /// A newtype wrapper to prevent MIR generation from inserting reborrows that would affect the error -/// message. Use this whenever the message is "any use of this value will cause an error" instead of -/// "it is undefined behavior to use this value". +/// message. #[repr(transparent)] struct W<T>(T); @@ -40,12 +39,10 @@ const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize:: //~^ ERROR it is undefined behavior to use this value // bad str const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed // bad str in user-defined unsized type const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; //~^ ERROR it is undefined behavior to use this value @@ -74,34 +71,29 @@ const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize:: //~^ ERROR it is undefined behavior to use this value // bad slice: length not an int const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed // 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 // bad slice box: length not an int const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed // bad data *inside* the slice const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; //~^ ERROR it is undefined behavior to use this value -//~| ERROR any use of this value will cause an error -//~| WARNING this was previously accepted +//~| ERROR evaluation of constant value failed // 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 -//~| ERROR any use of this value will cause an error -//~| WARNING this was previously accepted +//~| ERROR evaluation of constant value failed // 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 -//~| ERROR any use of this value will cause an error -//~| WARNING this was previously accepted +//~| ERROR evaluation of constant value failed // # raw slice const RAW_SLICE_VALID: *const [u8] = unsafe { mem::transmute((&42u8, 1usize)) }; // ok diff --git a/src/test/ui/consts/const-eval/union-ub.32bit.stderr b/src/test/ui/consts/const-eval/union-ub.32bit.stderr index 38ded4d65..e5c8f88be 100644 --- a/src/test/ui/consts/const-eval/union-ub.32bit.stderr +++ b/src/test/ui/consts/const-eval/union-ub.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/union-ub.rs:33:1 + --> $DIR/union-ub.rs:32:1 | LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x2a, but expected a boolean @@ -10,7 +10,7 @@ LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; } error[E0080]: evaluation of constant value failed - --> $DIR/union-ub.rs:35:36 + --> $DIR/union-ub.rs:34:36 | LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory diff --git a/src/test/ui/consts/const-eval/union-ub.64bit.stderr b/src/test/ui/consts/const-eval/union-ub.64bit.stderr index 38ded4d65..e5c8f88be 100644 --- a/src/test/ui/consts/const-eval/union-ub.64bit.stderr +++ b/src/test/ui/consts/const-eval/union-ub.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/union-ub.rs:33:1 + --> $DIR/union-ub.rs:32:1 | LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x2a, but expected a boolean @@ -10,7 +10,7 @@ LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; } error[E0080]: evaluation of constant value failed - --> $DIR/union-ub.rs:35:36 + --> $DIR/union-ub.rs:34:36 | LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory diff --git a/src/test/ui/consts/const-eval/union-ub.rs b/src/test/ui/consts/const-eval/union-ub.rs index bb29edcf8..043870c9c 100644 --- a/src/test/ui/consts/const-eval/union-ub.rs +++ b/src/test/ui/consts/const-eval/union-ub.rs @@ -1,5 +1,4 @@ // stderr-per-bitwidth -#![allow(const_err)] // make sure we cannot allow away the errors tested here #[repr(C)] union DummyUnion { diff --git a/src/test/ui/consts/const-eval/union_promotion.rs b/src/test/ui/consts/const-eval/union_promotion.rs index 7167f88a1..18894c45f 100644 --- a/src/test/ui/consts/const-eval/union_promotion.rs +++ b/src/test/ui/consts/const-eval/union_promotion.rs @@ -1,5 +1,3 @@ -#![allow(const_err)] - #[repr(C)] union Foo { a: &'static u32, diff --git a/src/test/ui/consts/const-eval/union_promotion.stderr b/src/test/ui/consts/const-eval/union_promotion.stderr index ed186e3eb..70808c520 100644 --- a/src/test/ui/consts/const-eval/union_promotion.stderr +++ b/src/test/ui/consts/const-eval/union_promotion.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/union_promotion.rs:10:29 + --> $DIR/union_promotion.rs:8:29 | LL | let x: &'static bool = &unsafe { | ____________-------------____^ diff --git a/src/test/ui/consts/const-eval/unused-broken-const.rs b/src/test/ui/consts/const-eval/unused-broken-const.rs index 3b4523681..0d2776bc2 100644 --- a/src/test/ui/consts/const-eval/unused-broken-const.rs +++ b/src/test/ui/consts/const-eval/unused-broken-const.rs @@ -3,7 +3,6 @@ // compile-flags: --emit=dep-info,metadata const FOO: i32 = [][0]; -//~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR evaluation of constant value failed fn main() {} diff --git a/src/test/ui/consts/const-eval/unused-broken-const.stderr b/src/test/ui/consts/const-eval/unused-broken-const.stderr index df5bd524f..fbb10feb7 100644 --- a/src/test/ui/consts/const-eval/unused-broken-const.stderr +++ b/src/test/ui/consts/const-eval/unused-broken-const.stderr @@ -1,23 +1,9 @@ -error: any use of this value will cause an error +error[E0080]: evaluation of constant value failed --> $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 - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + | ^^^^^ index out of bounds: the length is 0 but the index is 0 error: aborting due to previous error -Future incompatibility report: Future breakage diagnostic: -error: any use of this value will cause an error - --> $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 - | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/valid-const.rs b/src/test/ui/consts/const-eval/valid-const.rs index 9e4707182..5f47d1c4f 100644 --- a/src/test/ui/consts/const-eval/valid-const.rs +++ b/src/test/ui/consts/const-eval/valid-const.rs @@ -1,7 +1,6 @@ // check-pass // Some constants that *are* valid -#![deny(const_err)] use std::mem; use std::ptr::NonNull; diff --git a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr index bdaeb4a0f..63639729a 100644 --- a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr +++ b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr @@ -7,8 +7,8 @@ LL | unsafe { std::mem::transmute(()) } | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | - = note: `#[warn(invalid_value)]` on by default = note: the `!` type has no valid value + = note: `#[warn(invalid_value)]` on by default error[E0080]: evaluation of constant value failed --> $DIR/validate_uninhabited_zsts.rs:4:14 @@ -20,10 +20,10 @@ LL | unsafe { std::mem::transmute(()) } | inside `foo` at $DIR/validate_uninhabited_zsts.rs:4:14 ... LL | const FOO: [empty::Empty; 3] = [foo(); 3]; - | ----- inside `FOO` at $DIR/validate_uninhabited_zsts.rs:20:33 + | ----- inside `FOO` at $DIR/validate_uninhabited_zsts.rs:19:33 error[E0080]: it is undefined behavior to use this value - --> $DIR/validate_uninhabited_zsts.rs:23:1 + --> $DIR/validate_uninhabited_zsts.rs:21:1 | LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0].0: encountered a value of uninhabited type empty::Void @@ -32,7 +32,7 @@ LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; = note: the raw bytes of the constant (size: 0, align: 1) {} warning: the type `empty::Empty` does not permit zero-initialization - --> $DIR/validate_uninhabited_zsts.rs:23:42 + --> $DIR/validate_uninhabited_zsts.rs:21:42 | LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,11 +40,11 @@ LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | -note: enums with no variants have no valid value (in this struct field) - --> $DIR/validate_uninhabited_zsts.rs:16:22 +note: enums with no inhabited variants have no valid value + --> $DIR/validate_uninhabited_zsts.rs:13:5 | -LL | pub struct Empty(Void); - | ^^^^ +LL | enum Void {} + | ^^^^^^^^^ error: aborting due to 2 previous errors; 2 warnings emitted diff --git a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr index bdaeb4a0f..63639729a 100644 --- a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr +++ b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr @@ -7,8 +7,8 @@ LL | unsafe { std::mem::transmute(()) } | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | - = note: `#[warn(invalid_value)]` on by default = note: the `!` type has no valid value + = note: `#[warn(invalid_value)]` on by default error[E0080]: evaluation of constant value failed --> $DIR/validate_uninhabited_zsts.rs:4:14 @@ -20,10 +20,10 @@ LL | unsafe { std::mem::transmute(()) } | inside `foo` at $DIR/validate_uninhabited_zsts.rs:4:14 ... LL | const FOO: [empty::Empty; 3] = [foo(); 3]; - | ----- inside `FOO` at $DIR/validate_uninhabited_zsts.rs:20:33 + | ----- inside `FOO` at $DIR/validate_uninhabited_zsts.rs:19:33 error[E0080]: it is undefined behavior to use this value - --> $DIR/validate_uninhabited_zsts.rs:23:1 + --> $DIR/validate_uninhabited_zsts.rs:21:1 | LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0].0: encountered a value of uninhabited type empty::Void @@ -32,7 +32,7 @@ LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; = note: the raw bytes of the constant (size: 0, align: 1) {} warning: the type `empty::Empty` does not permit zero-initialization - --> $DIR/validate_uninhabited_zsts.rs:23:42 + --> $DIR/validate_uninhabited_zsts.rs:21:42 | LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,11 +40,11 @@ LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | -note: enums with no variants have no valid value (in this struct field) - --> $DIR/validate_uninhabited_zsts.rs:16:22 +note: enums with no inhabited variants have no valid value + --> $DIR/validate_uninhabited_zsts.rs:13:5 | -LL | pub struct Empty(Void); - | ^^^^ +LL | enum Void {} + | ^^^^^^^^^ error: aborting due to 2 previous errors; 2 warnings emitted diff --git a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs index 96f331275..c0b326215 100644 --- a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs +++ b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs @@ -16,10 +16,8 @@ pub mod empty { pub struct Empty(Void); } -#[warn(const_err)] const FOO: [empty::Empty; 3] = [foo(); 3]; -#[warn(const_err)] const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; //~^ ERROR it is undefined behavior to use this value //~| WARN the type `empty::Empty` does not permit zero-initialization |