mirror of
https://github.com/rust-lang/rust.git
synced 2026-07-25 09:01:37 -04:00
08d79a6ec9
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
29 lines
532 B
Rust
29 lines
532 B
Rust
// Regression test for preserving constant return values after a use of the
|
|
// same local through `black_box` or formatting.
|
|
|
|
//@ compile-flags: -Copt-level=3
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
use std::hint::black_box;
|
|
|
|
// CHECK-LABEL: @black_box_ref_constant
|
|
#[no_mangle]
|
|
pub fn black_box_ref_constant() -> i32 {
|
|
let x = 1;
|
|
black_box(&x);
|
|
|
|
// CHECK: ret i32 1
|
|
x
|
|
}
|
|
|
|
// CHECK-LABEL: @format_ref_constant
|
|
#[no_mangle]
|
|
pub fn format_ref_constant() -> i32 {
|
|
let x = 1;
|
|
println!("{}", x);
|
|
|
|
// CHECK: ret i32 1
|
|
x
|
|
}
|