1 #![feature(const_eval_select)]
2 #![feature(core_intrinsics)]
4 use std::intrinsics::const_eval_select;
6 const fn not_fn_items() {
7 const_eval_select((), || {}, || {});
8 //~^ ERROR this argument must be a function item
9 //~| ERROR this argument must be a function item
10 const_eval_select((), 42, 0xDEADBEEF);
11 //~^ ERROR expected a `FnOnce<()>` closure
12 //~| ERROR expected a `FnOnce<()>` closure
13 //~| ERROR this argument must be a function item
14 //~| ERROR this argument must be a function item
17 const fn foo(n: i32) -> i32 {
21 fn bar(n: i32) -> bool {
22 assert_eq!(n, 0, "{} must be equal to {}", n, 0);
26 fn baz(n: bool) -> i32 {
27 assert!(n, "{} must be true", n);
31 const fn return_ty_mismatch() {
32 const_eval_select((1,), foo, bar);
33 //~^ ERROR expected `fn(i32) -> bool {bar}` to be a fn item that returns `i32`, but it returns `bool`
36 const fn args_ty_mismatch() {
37 const_eval_select((true,), foo, baz);
38 //~^ ERROR type mismatch
41 const fn non_const_fn() {
42 const_eval_select((1,), bar, bar);
43 //~^ ERROR this argument must be a `const fn`