diff --git a/src/test/ui/consts/miri_unleashed/non_const_fn.rs b/src/test/ui/consts/miri_unleashed/non_const_fn.rs new file mode 100644 index 000000000000..01ce6b904e37 --- /dev/null +++ b/src/test/ui/consts/miri_unleashed/non_const_fn.rs @@ -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 +} diff --git a/src/test/ui/consts/miri_unleashed/non_const_fn.stderr b/src/test/ui/consts/miri_unleashed/non_const_fn.stderr new file mode 100644 index 000000000000..ad8154bd2c68 --- /dev/null +++ b/src/test/ui/consts/miri_unleashed/non_const_fn.stderr @@ -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`.