2021-10-12 05:06:37 +00:00
|
|
|
// run-pass
|
|
|
|
|
|
|
|
#![feature(const_eval_select)]
|
2022-04-12 01:12:26 +00:00
|
|
|
#![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 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);
|
|
|
|
}
|