rust/tests/ui/intrinsics/const-eval-select.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
434 B
Rust
Raw Normal View History

2021-10-12 05:06:37 +00:00
//@ run-pass
#![feature(const_eval_select)]
#![feature(core_intrinsics)]
2021-10-12 05:06:37 +00:00
use std::intrinsics::const_eval_select;
2021-10-14 06:18:53 +00:00
const fn yes() -> bool {
2021-10-12 05:06:37 +00:00
true
}
2021-10-14 06:18:53 +00:00
fn no() -> bool {
2021-10-12 05:06:37 +00:00
false
}
// not allowed on stable; testing only
2021-10-12 05:06:37 +00:00
const fn is_const_eval() -> bool {
const_eval_select((), yes, no)
2021-10-12 05:06:37 +00:00
}
fn main() {
const YES: bool = is_const_eval();
let no = is_const_eval();
assert_eq!(true, YES);
assert_eq!(false, no);
}