2024-05-20 16:50:31 -05:00
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
|
|
|
//@ compile-flags: -O
|
|
|
|
|
|
|
|
use std::mem;
|
|
|
|
|
|
|
|
fn foo<T>(a: &mut T, b: T) -> bool {
|
|
|
|
let b = Some(mem::replace(a, b));
|
|
|
|
let ret = b.is_some();
|
|
|
|
mem::forget(b);
|
2024-06-09 08:25:12 -05:00
|
|
|
return ret;
|
2024-05-20 16:50:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: @foo_u32
|
|
|
|
// CHECK: store i32
|
2024-06-09 08:25:12 -05:00
|
|
|
// CHECK-NEXT: ret i1 true
|
2024-05-20 16:50:31 -05:00
|
|
|
#[no_mangle]
|
|
|
|
pub fn foo_u32(a: &mut u32, b: u32) -> bool {
|
|
|
|
foo(a, b)
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: @foo_box
|
|
|
|
// CHECK: store ptr
|
2024-06-09 08:25:12 -05:00
|
|
|
// CHECK-NEXT: ret i1 true
|
2024-05-20 16:50:31 -05:00
|
|
|
#[no_mangle]
|
|
|
|
pub fn foo_box(a: &mut Box<u32>, b: Box<u32>) -> bool {
|
|
|
|
foo(a, b)
|
|
|
|
}
|