rust/tests/mir-opt/issue_62289.test.ElaborateDrops.after.panic-abort.mir
Ralf Jung 5e65109f21 add write_box_via_move intrinsic and use it for vec!
This allows us to get rid of box_new entirely
2026-02-16 17:27:40 +01:00

119 lines
2.8 KiB
Rust

// MIR for `test` after ElaborateDrops
fn test() -> Option<Vec<u32>> {
let mut _0: std::option::Option<std::vec::Vec<u32>>;
let mut _1: std::vec::Vec<u32>;
let mut _2: std::boxed::Box<std::mem::MaybeUninit<[u32; 1]>>;
let mut _3: std::boxed::Box<std::mem::MaybeUninit<[u32; 1]>>;
let mut _4: u32;
let mut _5: std::ops::ControlFlow<std::option::Option<std::convert::Infallible>, u32>;
let mut _6: std::option::Option<u32>;
let mut _7: isize;
let _8: std::option::Option<std::convert::Infallible>;
let mut _9: !;
let mut _10: std::option::Option<std::convert::Infallible>;
let _11: u32;
scope 1 {
debug residual => _8;
scope 2 {
}
}
scope 3 {
debug val => _11;
scope 4 {
}
}
bb0: {
StorageLive(_1);
StorageLive(_2);
StorageLive(_3);
_3 = Box::<[u32; 1]>::new_uninit() -> [return: bb1, unwind: bb14];
}
bb1: {
StorageLive(_4);
StorageLive(_5);
StorageLive(_6);
_6 = Option::<u32>::None;
_5 = <Option<u32> as Try>::branch(move _6) -> [return: bb2, unwind: bb13];
}
bb2: {
StorageDead(_6);
PlaceMention(_5);
_7 = discriminant(_5);
switchInt(move _7) -> [0: bb4, 1: bb5, otherwise: bb3];
}
bb3: {
unreachable;
}
bb4: {
StorageLive(_11);
_11 = copy ((_5 as Continue).0: u32);
_4 = copy _11;
StorageDead(_11);
((((*_3).1: std::mem::ManuallyDrop<[u32; 1]>).0: std::mem::MaybeDangling<[u32; 1]>).0: [u32; 1]) = [move _4];
StorageDead(_4);
_2 = move _3;
goto -> bb7;
}
bb5: {
StorageLive(_8);
_8 = copy ((_5 as Break).0: std::option::Option<std::convert::Infallible>);
StorageLive(_10);
_10 = copy _8;
_0 = <Option<Vec<u32>> as FromResidual<Option<Infallible>>>::from_residual(move _10) -> [return: bb6, unwind: bb13];
}
bb6: {
StorageDead(_10);
StorageDead(_8);
StorageDead(_4);
drop(_3) -> [return: bb10, unwind: bb14];
}
bb7: {
StorageDead(_3);
_1 = std::boxed::box_assume_init_into_vec_unsafe::<u32, 1>(move _2) -> [return: bb8, unwind: bb12];
}
bb8: {
StorageDead(_2);
_0 = Option::<Vec<u32>>::Some(move _1);
goto -> bb9;
}
bb9: {
StorageDead(_1);
StorageDead(_5);
goto -> bb11;
}
bb10: {
StorageDead(_3);
StorageDead(_2);
StorageDead(_1);
StorageDead(_5);
goto -> bb11;
}
bb11: {
return;
}
bb12 (cleanup): {
goto -> bb14;
}
bb13 (cleanup): {
drop(_3) -> [return: bb14, unwind terminate(cleanup)];
}
bb14 (cleanup): {
resume;
}
}