more precise span for erroneous consts during CTFE/Miri

This commit is contained in:
Ralf Jung 2020-08-11 14:54:02 +02:00
parent 4b4d43fe6a
commit d21e0118d0
5 changed files with 46 additions and 31 deletions

View file

@ -13,22 +13,28 @@ LL | #![deny(const_err)]
| ^^^^^^^^^
error: any use of this value will cause an error
--> $DIR/const-err-multi.rs:5:1
--> $DIR/const-err-multi.rs:5:19
|
LL | pub const B: i8 = A;
| ^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
| ------------------^-
| |
| referenced constant has errors
error: any use of this value will cause an error
--> $DIR/const-err-multi.rs:7:1
--> $DIR/const-err-multi.rs:7:19
|
LL | pub const C: u8 = A as u8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
| ------------------^-------
| |
| referenced constant has errors
error: any use of this value will cause an error
--> $DIR/const-err-multi.rs:9:1
--> $DIR/const-err-multi.rs:9:24
|
LL | pub const D: i8 = 50 - A;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
| -----------------------^-
| |
| referenced constant has errors
error: aborting due to 4 previous errors

View file

@ -7,9 +7,9 @@ impl<T> PrintName<T> {
//~^ WARN this operation will panic at runtime
}
const fn no_codegen<T>() { //~ERROR evaluation of constant value failed
const fn no_codegen<T>() {
if false {
let _ = PrintName::<T>::VOID;
let _ = PrintName::<T>::VOID; //~ERROR evaluation of constant value failed
}
}

View file

@ -25,14 +25,10 @@ LL | #![warn(const_err, unconditional_panic)]
| ^^^^^^^^^
error[E0080]: evaluation of constant value failed
--> $DIR/erroneous-const.rs:10:1
--> $DIR/erroneous-const.rs:12:17
|
LL | / const fn no_codegen<T>() {
LL | | if false {
LL | | let _ = PrintName::<T>::VOID;
LL | | }
LL | | }
| |_^ referenced constant has errors
LL | let _ = PrintName::<T>::VOID;
| ^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
error[E0080]: could not evaluate static initializer
--> $DIR/erroneous-const.rs:16:22