rust/tests/ui/consts/required-consts/interpret-in-promoted.rs

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

17 lines
462 B
Rust
Raw Normal View History

//@revisions: noopt opt
2024-03-18 11:54:48 -05:00
//@[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() {}