os-rust/src/test/ui/intrinsics/const-eval-select-bad.rs

37 lines
711 B
Rust
Raw Normal View History

2021-10-12 05:06:37 +00:00
#![feature(const_eval_select)]
use std::intrinsics::const_eval_select;
const fn not_fn_items() {
2021-10-14 06:18:53 +00:00
const_eval_select((), || {}, || {});
//~^ ERROR expected a `FnOnce<()>` closure
2021-10-12 05:06:37 +00:00
const_eval_select((), 42, 0xDEADBEEF);
2021-10-14 06:18:53 +00:00
//~^ ERROR expected a `FnOnce<()>` closure
2021-10-12 05:06:37 +00:00
}
2021-10-14 06:18:53 +00:00
const fn foo(n: i32) -> i32 {
2021-10-12 05:06:37 +00:00
n
}
2021-10-14 06:18:53 +00:00
fn bar(n: i32) -> bool {
2021-10-12 05:06:37 +00:00
assert_eq!(n, 0, "{} must be equal to {}", n, 0);
n == 0
}
2021-10-14 06:18:53 +00:00
fn baz(n: bool) -> i32 {
2021-10-12 05:06:37 +00:00
assert!(n, "{} must be true", n);
n as i32
}
const fn return_ty_mismatch() {
const_eval_select((1,), foo, bar);
//~^ ERROR type mismatch
}
const fn args_ty_mismatch() {
const_eval_select((true,), foo, baz);
//~^ ERROR type mismatch
}
fn main() {}