show the proper diagnostics
This commit is contained in:
parent
7f1ce45140
commit
38fd74f22a
2 changed files with 17 additions and 2 deletions
|
@ -1,11 +1,12 @@
|
|||
// compile-flags: -Zunleash-the-miri-inside-of-you
|
||||
#![allow(const_err)]
|
||||
#![warn(const_err)]
|
||||
|
||||
// A test demonstrating that we prevent calling non-const fn during CTFE.
|
||||
|
||||
fn foo() {}
|
||||
|
||||
const C: () = foo(); //~ WARN: skipping const checks
|
||||
//~^ WARN any use of this value will cause an error
|
||||
|
||||
fn main() {
|
||||
println!("{:?}", C); //~ ERROR: evaluation of constant expression failed
|
||||
|
|
|
@ -4,8 +4,22 @@ warning: skipping const checks
|
|||
LL | const C: () = foo();
|
||||
| ^^^^^
|
||||
|
||||
warning: any use of this value will cause an error
|
||||
--> $DIR/non_const_fn.rs:8:15
|
||||
|
|
||||
LL | const C: () = foo();
|
||||
| --------------^^^^^-
|
||||
| |
|
||||
| calling non-const function `foo`
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/non_const_fn.rs:2:9
|
||||
|
|
||||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error[E0080]: evaluation of constant expression failed
|
||||
--> $DIR/non_const_fn.rs:11:22
|
||||
--> $DIR/non_const_fn.rs:12:22
|
||||
|
|
||||
LL | println!("{:?}", C);
|
||||
| ^ referenced constant has errors
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue