add test for calling non-const fn
This commit is contained in:
parent
e5b8c118a3
commit
7f1ce45140
2 changed files with 27 additions and 0 deletions
12
src/test/ui/consts/miri_unleashed/non_const_fn.rs
Normal file
12
src/test/ui/consts/miri_unleashed/non_const_fn.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// compile-flags: -Zunleash-the-miri-inside-of-you
|
||||
#![allow(const_err)]
|
||||
|
||||
// A test demonstrating that we prevent calling non-const fn during CTFE.
|
||||
|
||||
fn foo() {}
|
||||
|
||||
const C: () = foo(); //~ WARN: skipping const checks
|
||||
|
||||
fn main() {
|
||||
println!("{:?}", C); //~ ERROR: evaluation of constant expression failed
|
||||
}
|
||||
15
src/test/ui/consts/miri_unleashed/non_const_fn.stderr
Normal file
15
src/test/ui/consts/miri_unleashed/non_const_fn.stderr
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
warning: skipping const checks
|
||||
--> $DIR/non_const_fn.rs:8:15
|
||||
|
|
||||
LL | const C: () = foo();
|
||||
| ^^^^^
|
||||
|
||||
error[E0080]: evaluation of constant expression failed
|
||||
--> $DIR/non_const_fn.rs:11:22
|
||||
|
|
||||
LL | println!("{:?}", C);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue