]>
Commit | Line | Data |
---|---|---|
c295e0f8 | 1 | #![feature(const_eval_select)] |
064997fb | 2 | #![feature(core_intrinsics)] |
c295e0f8 XL |
3 | |
4 | use std::intrinsics::const_eval_select; | |
5 | ||
6 | const fn not_fn_items() { | |
7 | const_eval_select((), || {}, || {}); | |
5099ac24 | 8 | //~^ ERROR the trait bound |
c295e0f8 | 9 | const_eval_select((), 42, 0xDEADBEEF); |
5099ac24 | 10 | //~^ ERROR the trait bound |
3c0e092e | 11 | //~| ERROR expected a `FnOnce<()>` closure |
c295e0f8 XL |
12 | } |
13 | ||
14 | const fn foo(n: i32) -> i32 { | |
15 | n | |
16 | } | |
17 | ||
18 | fn bar(n: i32) -> bool { | |
19 | assert_eq!(n, 0, "{} must be equal to {}", n, 0); | |
20 | n == 0 | |
21 | } | |
22 | ||
23 | fn baz(n: bool) -> i32 { | |
24 | assert!(n, "{} must be true", n); | |
25 | n as i32 | |
26 | } | |
27 | ||
28 | const fn return_ty_mismatch() { | |
29 | const_eval_select((1,), foo, bar); | |
30 | //~^ ERROR type mismatch | |
31 | } | |
32 | ||
33 | const fn args_ty_mismatch() { | |
34 | const_eval_select((true,), foo, baz); | |
35 | //~^ ERROR type mismatch | |
36 | } | |
37 | ||
38 | fn main() {} |