Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for calling non-const fn #65593

Merged
merged 2 commits into from
Oct 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/test/ui/consts/miri_unleashed/non_const_fn.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 15 additions & 0 deletions src/test/ui/consts/miri_unleashed/non_const_fn.stderr
Original file line number Diff line number Diff line change
@@ -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
RalfJung marked this conversation as resolved.
Show resolved Hide resolved

error: aborting due to previous error

For more information about this error, try `rustc --explain E0080`.