]> git.lizzy.rs Git - rust.git/blob - src/test/ui/intrinsics/const-eval-select-bad.rs
Improve selection errors for `~const` trait bounds
[rust.git] / src / test / ui / intrinsics / const-eval-select-bad.rs
1 #![feature(const_eval_select)]
2
3 use std::intrinsics::const_eval_select;
4
5 const fn not_fn_items() {
6     const_eval_select((), || {}, || {});
7     //~^ ERROR the trait bound
8     const_eval_select((), 42, 0xDEADBEEF);
9     //~^ ERROR the trait bound
10     //~| ERROR expected a `FnOnce<()>` closure
11 }
12
13 const fn foo(n: i32) -> i32 {
14     n
15 }
16
17 fn bar(n: i32) -> bool {
18     assert_eq!(n, 0, "{} must be equal to {}", n, 0);
19     n == 0
20 }
21
22 fn baz(n: bool) -> i32 {
23     assert!(n, "{} must be true", n);
24     n as i32
25 }
26
27 const fn return_ty_mismatch() {
28     const_eval_select((1,), foo, bar);
29     //~^ ERROR type mismatch
30 }
31
32 const fn args_ty_mismatch() {
33     const_eval_select((true,), foo, baz);
34     //~^ ERROR type mismatch
35 }
36
37 fn main() {}