rust/tests/run-make/intrinsic-unreachable/rmake.rs
许杰友 Jieyou Xu (Joe) d69cc1ccbf tests: update for rfs rename
2024-07-17 13:34:18 +00:00

21 lines
814 B
Rust

// intrinsics::unreachable tells the compiler that a certain point in the code
// is not reachable by any means, which enables some useful optimizations.
// In this test, exit-unreachable contains this instruction and exit-ret does not,
// which means the emitted artifacts should be shorter in length.
// See https://github.com/rust-lang/rust/pull/16970
//@ needs-asm-support
//@ ignore-windows
// Reason: Because of Windows exception handling, the code is not necessarily any shorter.
use run_make_support::{rfs, rustc};
fn main() {
rustc().opt().emit("asm").input("exit-ret.rs").run();
rustc().opt().emit("asm").input("exit-unreachable.rs").run();
assert!(
rfs::read_to_string("exit-unreachable.s").lines().count()
< rfs::read_to_string("exit-ret.s").lines().count()
);
}