MIR lowering for `if let` expressions is now more complicated now that `if let` exists in HIR. This PR adds a scope for the variables bound in an `if let` expression and then uses an approach similar to how we handle loops to ensure that we reliably drop the correct variables.
87 lines
4.5 KiB
Diff
87 lines
4.5 KiB
Diff
- // MIR for `foo` before MatchBranchSimplification
|
|
+ // MIR for `foo` after MatchBranchSimplification
|
|
|
|
fn foo(_1: [u8; 16]) -> Option<[u8; 4]> {
|
|
debug bytes => _1; // in scope 0 at $DIR/issue-75439.rs:5:12: 5:17
|
|
let mut _0: std::option::Option<[u8; 4]>; // return place in scope 0 at $DIR/issue-75439.rs:5:32: 5:47
|
|
let _2: [u32; 4]; // in scope 0 at $DIR/issue-75439.rs:7:9: 7:15
|
|
let mut _3: [u8; 16]; // in scope 0 at $DIR/issue-75439.rs:7:47: 7:52
|
|
let mut _5: [u8; 4]; // in scope 0 at $DIR/issue-75439.rs:10:14: 10:38
|
|
let mut _6: u32; // in scope 0 at $DIR/issue-75439.rs:10:33: 10:35
|
|
scope 1 {
|
|
debug dwords => _2; // in scope 1 at $DIR/issue-75439.rs:7:9: 7:15
|
|
let _4: u32; // in scope 1 at $DIR/issue-75439.rs:9:27: 9:29
|
|
scope 3 {
|
|
debug ip => _4; // in scope 3 at $DIR/issue-75439.rs:9:27: 9:29
|
|
}
|
|
scope 4 {
|
|
}
|
|
}
|
|
scope 2 {
|
|
}
|
|
|
|
bb0: {
|
|
StorageLive(_2); // scope 0 at $DIR/issue-75439.rs:7:9: 7:15
|
|
StorageLive(_3); // scope 2 at $DIR/issue-75439.rs:7:47: 7:52
|
|
_3 = _1; // scope 2 at $DIR/issue-75439.rs:7:47: 7:52
|
|
_2 = transmute::<[u8; 16], [u32; 4]>(move _3) -> bb1; // scope 2 at $DIR/issue-75439.rs:7:37: 7:53
|
|
// mir::Constant
|
|
// + span: $DIR/issue-75439.rs:7:37: 7:46
|
|
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn([u8; 16]) -> [u32; 4] {std::intrinsics::transmute::<[u8; 16], [u32; 4]>}, val: Value(Scalar(<ZST>)) }
|
|
}
|
|
|
|
bb1: {
|
|
StorageDead(_3); // scope 2 at $DIR/issue-75439.rs:7:52: 7:53
|
|
switchInt(_2[0 of 4]) -> [0_u32: bb2, otherwise: bb8]; // scope 1 at $DIR/issue-75439.rs:9:12: 9:30
|
|
}
|
|
|
|
bb2: {
|
|
switchInt(_2[1 of 4]) -> [0_u32: bb3, otherwise: bb8]; // scope 1 at $DIR/issue-75439.rs:9:12: 9:30
|
|
}
|
|
|
|
bb3: {
|
|
switchInt(_2[2 of 4]) -> [0_u32: bb5, 4294901760_u32: bb6, otherwise: bb8]; // scope 1 at $DIR/issue-75439.rs:9:12: 9:30
|
|
}
|
|
|
|
bb4: {
|
|
StorageLive(_5); // scope 1 at $DIR/issue-75439.rs:10:14: 10:38
|
|
StorageLive(_6); // scope 4 at $DIR/issue-75439.rs:10:33: 10:35
|
|
_6 = _4; // scope 4 at $DIR/issue-75439.rs:10:33: 10:35
|
|
_5 = transmute::<u32, [u8; 4]>(move _6) -> bb7; // scope 4 at $DIR/issue-75439.rs:10:23: 10:36
|
|
// mir::Constant
|
|
// + span: $DIR/issue-75439.rs:10:23: 10:32
|
|
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u32) -> [u8; 4] {std::intrinsics::transmute::<u32, [u8; 4]>}, val: Value(Scalar(<ZST>)) }
|
|
}
|
|
|
|
bb5: {
|
|
StorageLive(_4); // scope 1 at $DIR/issue-75439.rs:9:27: 9:29
|
|
_4 = _2[3 of 4]; // scope 1 at $DIR/issue-75439.rs:9:27: 9:29
|
|
goto -> bb4; // scope 1 at $DIR/issue-75439.rs:9:12: 9:30
|
|
}
|
|
|
|
bb6: {
|
|
StorageLive(_4); // scope 1 at $DIR/issue-75439.rs:9:27: 9:29
|
|
_4 = _2[3 of 4]; // scope 1 at $DIR/issue-75439.rs:9:27: 9:29
|
|
goto -> bb4; // scope 1 at $DIR/issue-75439.rs:9:12: 9:30
|
|
}
|
|
|
|
bb7: {
|
|
StorageDead(_6); // scope 4 at $DIR/issue-75439.rs:10:35: 10:36
|
|
((_0 as Some).0: [u8; 4]) = move _5; // scope 1 at $DIR/issue-75439.rs:10:9: 10:39
|
|
discriminant(_0) = 1; // scope 1 at $DIR/issue-75439.rs:10:9: 10:39
|
|
StorageDead(_5); // scope 1 at $DIR/issue-75439.rs:10:38: 10:39
|
|
StorageDead(_4); // scope 1 at $DIR/issue-75439.rs:11:5: 11:6
|
|
goto -> bb9; // scope 1 at $DIR/issue-75439.rs:9:5: 13:6
|
|
}
|
|
|
|
bb8: {
|
|
discriminant(_0) = 0; // scope 1 at $DIR/issue-75439.rs:12:9: 12:13
|
|
goto -> bb9; // scope 1 at $DIR/issue-75439.rs:9:5: 13:6
|
|
}
|
|
|
|
bb9: {
|
|
StorageDead(_2); // scope 0 at $DIR/issue-75439.rs:14:1: 14:2
|
|
return; // scope 0 at $DIR/issue-75439.rs:14:2: 14:2
|
|
}
|
|
}
|
|
|