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
|
|
|
|
}
|
|
|
|
|
2024-03-02 11:53:28 +00:00
|
|
|
// not allowed on stable; testing only
|
2021-10-12 05:06:37 +00:00
|
|
|
const fn is_const_eval() -> bool {
|
2024-03-02 11:53:28 +00:00
|
|
|
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);
|
|
|
|
}
|