rust/tests/ui/consts/required-consts/interpret-in-promoted.rs
Ralf Jung 173d1bd36b properly fill a promoted's required_consts
then we can also make all_required_consts_are_checked a constant instead of a function
2024-04-23 23:02:54 +02:00

17 lines
462 B
Rust

//@revisions: noopt opt
//@[noopt] compile-flags: -Copt-level=0
//@[opt] compile-flags: -O
//! Make sure we evaluate const fn calls even if they get promoted and their result ignored.
const unsafe fn ub() {
std::hint::unreachable_unchecked();
}
pub const FOO: () = unsafe {
// Make sure that this gets promoted and then fails to evaluate, and we deal with that
// correctly.
let _x: &'static () = &ub(); //~ erroneous constant
};
fn main() {}