Rollup merge of #81333 - RalfJung:const-err-simplify, r=oli-obk

clean up some const error reporting around promoteds

These are some error reporting simplifications enabled by https://github.com/rust-lang/rust/pull/80579.

Further simplifications are possible but could be blocked on making `const_err` a hard error.

r? ``````@oli-obk``````
This commit is contained in:
Yuki Okushi 2021-01-29 09:17:38 +09:00 committed by GitHub
commit 046a414c19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 66 additions and 144 deletions

View file

@ -31,7 +31,7 @@ impl Tr for u32 {
fn main() {
assert_eq!(<() as Tr>::A, 255);
assert_eq!(<() as Tr>::B, 0); // causes the error above
//~^ ERROR evaluation of constant expression failed
//~^ ERROR evaluation of constant value failed
//~| ERROR erroneous constant used
assert_eq!(<u8 as Tr>::A, 254);

View file

@ -8,15 +8,11 @@ LL | const B: u8 = Self::A + 1;
|
= note: `#[deny(const_err)]` on by default
error[E0080]: evaluation of constant expression failed
--> $DIR/defaults-not-assumed-fail.rs:33:5
error[E0080]: evaluation of constant value failed
--> $DIR/defaults-not-assumed-fail.rs:33:16
|
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
| ^^^^^^^^^^^-------------^^^^^
| |
| referenced constant has errors
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
| ^^^^^^^^^^^^^ referenced constant has errors
error: erroneous constant used
--> $DIR/defaults-not-assumed-fail.rs:33:5

View file

@ -12,7 +12,7 @@ note: the lint level is defined here
LL | #![warn(const_err)]
| ^^^^^^^^^
error[E0080]: evaluation of constant expression failed
error[E0080]: evaluation of constant value failed
--> $DIR/conditional_array_execution.rs:11:20
|
LL | println!("{}", FOO);

View file

@ -21,6 +21,6 @@ const X: i32 = 1 / 0; //~WARN any use of this value will cause an error
fn main() {
let x: &'static i32 = &X;
//~^ ERROR evaluation of constant expression failed
//~^ ERROR evaluation of constant value failed
println!("x={}", x);
}

View file

@ -12,13 +12,11 @@ note: the lint level is defined here
LL | #[warn(const_err)]
| ^^^^^^^^^
error[E0080]: evaluation of constant expression failed
--> $DIR/const-eval-query-stack.rs:23:27
error[E0080]: evaluation of constant value failed
--> $DIR/const-eval-query-stack.rs:23:28
|
LL | let x: &'static i32 = &X;
| ^-
| |
| referenced constant has errors
| ^ referenced constant has errors
query stack during panic:
#0 [normalize_generic_arg_after_erasing_regions] normalizing `main::promoted[1]`
#1 [optimized_mir] optimizing MIR for `main`

View file

@ -18,7 +18,7 @@ const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday
fn main() {
assert_eq!(Y, 4);
//~^ ERROR evaluation of constant expression failed
//~^ ERROR evaluation of constant value failed
assert_eq!(Z, 4);
//~^ ERROR evaluation of constant expression failed
//~^ ERROR evaluation of constant value failed
}

View file

@ -1,22 +1,14 @@
error[E0080]: evaluation of constant expression failed
--> $DIR/const_fn_ptr_fail2.rs:20:5
error[E0080]: evaluation of constant value failed
--> $DIR/const_fn_ptr_fail2.rs:20:16
|
LL | assert_eq!(Y, 4);
| ^^^^^^^^^^^-^^^^^
| |
| referenced constant has errors
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
| ^ referenced constant has errors
error[E0080]: evaluation of constant expression failed
--> $DIR/const_fn_ptr_fail2.rs:22:5
error[E0080]: evaluation of constant value failed
--> $DIR/const_fn_ptr_fail2.rs:22:16
|
LL | assert_eq!(Z, 4);
| ^^^^^^^^^^^-^^^^^
| |
| referenced constant has errors
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
| ^ referenced constant has errors
warning: skipping const checks
|

View file

@ -12,8 +12,8 @@ fn main() {
const Y: u32 = foo(0 - 1);
//~^ WARN any use of this value will cause
println!("{} {}", X, Y);
//~^ ERROR evaluation of constant expression failed
//~| ERROR evaluation of constant expression failed
//~^ ERROR evaluation of constant value failed
//~| ERROR evaluation of constant value failed
//~| WARN erroneous constant used [const_err]
//~| WARN erroneous constant used [const_err]
}

View file

@ -20,7 +20,7 @@ LL | const Y: u32 = foo(0 - 1);
| |
| attempt to compute `0_u32 - 1_u32`, which would overflow
error[E0080]: evaluation of constant expression failed
error[E0080]: evaluation of constant value failed
--> $DIR/issue-43197.rs:14:23
|
LL | println!("{} {}", X, Y);
@ -32,7 +32,7 @@ warning: erroneous constant used
LL | println!("{} {}", X, Y);
| ^ referenced constant has errors
error[E0080]: evaluation of constant expression failed
error[E0080]: evaluation of constant value failed
--> $DIR/issue-43197.rs:14:26
|
LL | println!("{} {}", X, Y);

View file

@ -25,5 +25,5 @@ impl Foo for u16 {
fn main() {
println!("{}", <Bar<u16, u8> as Foo>::AMT);
//~^ ERROR evaluation of constant expression failed [E0080]
//~^ ERROR evaluation of constant value failed [E0080]
}

View file

@ -1,4 +1,4 @@
error[E0080]: evaluation of constant expression failed
error[E0080]: evaluation of constant value failed
--> $DIR/issue-44578.rs:27:20
|
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT);

View file

@ -8,13 +8,11 @@ LL | const BAR: usize = [5, 6, 7][T::BOO];
|
= note: `#[deny(const_err)]` on by default
error[E0080]: evaluation of constant expression failed
--> $DIR/issue-50814-2.rs:18:5
error[E0080]: evaluation of constant value failed
--> $DIR/issue-50814-2.rs:18:6
|
LL | &<A<T> as Foo<T>>::BAR
| ^---------------------
| |
| referenced constant has errors
| ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
error: aborting due to 2 previous errors

View file

@ -8,13 +8,11 @@ LL | const MAX: u8 = A::MAX + B::MAX;
|
= note: `#[deny(const_err)]` on by default
error[E0080]: evaluation of constant expression failed
--> $DIR/issue-50814.rs:20:5
error[E0080]: evaluation of constant value failed
--> $DIR/issue-50814.rs:20:6
|
LL | &Sum::<U8,U8>::MAX
| ^-----------------
| |
| referenced constant has errors
| ^^^^^^^^^^^^^^^^^ referenced constant has errors
error: aborting due to 2 previous errors

View file

@ -20,15 +20,11 @@ note: the lint level is defined here
LL | #[warn(const_err)]
| ^^^^^^^^^
error[E0080]: evaluation of constant expression failed
--> $DIR/const_unsafe_unreachable_ub.rs:17:3
error[E0080]: evaluation of constant value failed
--> $DIR/const_unsafe_unreachable_ub.rs:17:14
|
LL | assert_eq!(BAR, true);
| ^^^^^^^^^^^---^^^^^^^^
| |
| referenced constant has errors
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
| ^^^ referenced constant has errors
error: erroneous constant used
--> $DIR/const_unsafe_unreachable_ub.rs:17:3

View file

@ -2,15 +2,12 @@ error[E0080]: values of the type `[u8; SIZE]` are too big for the current archit
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
LL | intrinsics::size_of::<T>()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| inside `std::mem::size_of::<[u8; SIZE]>` at $SRC_DIR/core/src/mem/mod.rs:LL:COL
| inside `main` at $DIR/issue-55878.rs:7:26
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ inside `std::mem::size_of::<[u8; SIZE]>` at $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
::: $DIR/issue-55878.rs:7:26
|
LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>());
| ----------------------------------------------
| ---------------------------------------------- inside `main` at $DIR/issue-55878.rs:7:26
error: erroneous constant used
--> $DIR/issue-55878.rs:7:26