-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#![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); | ||
return ret | ||
} | ||
|
||
// CHECK-LABEL: @foo_u32 | ||
// CHECK: store i32 | ||
// CHECK-NEXT: ret i1 | ||
#[no_mangle] | ||
pub fn foo_u32(a: &mut u32, b: u32) -> bool { | ||
foo(a, b) | ||
} | ||
|
||
// CHECK-LABEL: @foo_box | ||
// CHECK: store ptr | ||
// CHECK-NEXT: ret i1 | ||
#[no_mangle] | ||
pub fn foo_box(a: &mut Box<u32>, b: Box<u32>) -> bool { | ||
foo(a, b) | ||
} | ||
|