File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
src/test/ui/consts/miri_unleashed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ // compile-flags: -Zunleash-the-miri-inside-of-you
2+ #![ warn( const_err) ]
3+
4+ // A test demonstrating that we prevent calling non-const fn during CTFE.
5+
6+ fn foo ( ) { }
7+
8+ const C : ( ) = foo ( ) ; //~ WARN: skipping const checks
9+ //~^ WARN any use of this value will cause an error
10+
11+ fn main ( ) {
12+ println ! ( "{:?}" , C ) ; //~ ERROR: evaluation of constant expression failed
13+ }
Original file line number Diff line number Diff line change 1+ warning: skipping const checks
2+ --> $DIR/non_const_fn.rs:8:15
3+ |
4+ LL | const C: () = foo();
5+ | ^^^^^
6+
7+ warning: any use of this value will cause an error
8+ --> $DIR/non_const_fn.rs:8:15
9+ |
10+ LL | const C: () = foo();
11+ | --------------^^^^^-
12+ | |
13+ | calling non-const function `foo`
14+ |
15+ note: lint level defined here
16+ --> $DIR/non_const_fn.rs:2:9
17+ |
18+ LL | #![warn(const_err)]
19+ | ^^^^^^^^^
20+
21+ error[E0080]: evaluation of constant expression failed
22+ --> $DIR/non_const_fn.rs:12:22
23+ |
24+ LL | println!("{:?}", C);
25+ | ^ referenced constant has errors
26+
27+ error: aborting due to previous error
28+
29+ For more information about this error, try `rustc --explain E0080`.
You can’t perform that action at this time.
0 commit comments