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
443 B
Rust
Raw Normal View History

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