mirror of
https://github.com/rust-lang/rust.git
synced 2025-11-03 14:34:58 +00:00
19 lines
523 B
Rust
19 lines
523 B
Rust
//@revisions: noopt opt
|
|
//@[noopt] compile-flags: -Copt-level=0
|
|
//@[opt] compile-flags: -O
|
|
//@ dont-require-annotations: NOTE
|
|
|
|
//! Make sure we evaluate const fn calls even if they get promoted and their result ignored.
|
|
|
|
const unsafe fn ub() {
|
|
std::hint::unreachable_unchecked(); //~ NOTE inside `ub`
|
|
}
|
|
|
|
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(); //~ ERROR unreachable code
|
|
};
|
|
|
|
fn main() {}
|