Add a mir-opt test for an unneeded drop_in_place
This commit is contained in:
parent
07b7dc90ee
commit
9b107bed9f
2 changed files with 33 additions and 0 deletions
13
tests/mir-opt/remove_unneeded_drop_in_place.rs
Normal file
13
tests/mir-opt/remove_unneeded_drop_in_place.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
//@ test-mir-pass: RemoveUnneededDrops
|
||||
//@ needs-unwind
|
||||
|
||||
// EMIT_MIR remove_unneeded_drop_in_place.slice_in_place.RemoveUnneededDrops.diff
|
||||
unsafe fn slice_in_place(ptr: *mut [char]) {
|
||||
std::ptr::drop_in_place(ptr)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// CHECK-LABEL: fn main(
|
||||
let mut a = ['o', 'k'];
|
||||
unsafe { slice_in_place(&raw mut a) };
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
- // MIR for `slice_in_place` before RemoveUnneededDrops
|
||||
+ // MIR for `slice_in_place` after RemoveUnneededDrops
|
||||
|
||||
fn slice_in_place(_1: *mut [char]) -> () {
|
||||
debug ptr => _1;
|
||||
let mut _0: ();
|
||||
let mut _2: *mut [char];
|
||||
|
||||
bb0: {
|
||||
StorageLive(_2);
|
||||
_2 = copy _1;
|
||||
_0 = drop_in_place::<[char]>(move _2) -> [return: bb1, unwind continue];
|
||||
}
|
||||
|
||||
bb1: {
|
||||
StorageDead(_2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue