/src/test/run-make-fulldeps/intrinsic-unreachable/exit-unreachable.rs
https://gitlab.com/jianglu/rust · Rust · 27 lines · 11 code · 3 blank · 13 comment · 0 complexity · 94ae176b2a8fd9d1cbe3b689ed0eaad4 MD5 · raw file
- // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
- // file at the top-level directory of this distribution and at
- // http://rust-lang.org/COPYRIGHT.
- //
- // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
- // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
- // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
- // option. This file may not be copied, modified, or distributed
- // except according to those terms.
- #![feature(asm, core_intrinsics)]
- #![crate_type="lib"]
- use std::intrinsics;
- #[allow(unreachable_code)]
- pub fn exit(n: usize) -> i32 {
- unsafe {
- // Pretend this asm is an exit() syscall.
- asm!("" :: "r"(n) :: "volatile");
- intrinsics::unreachable()
- }
- // This return value is just here to generate some extra code for a return
- // value, making it easier for the test script to detect whether the
- // compiler deleted it.
- 42
- }