rust/src/test/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff
Matthew Jasper ff8c0ef0e4 Fix drop handling for if let expressions
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.
2021-09-01 23:47:41 +01:00

39 lines
2.3 KiB
Diff

- // MIR for `opt_negative` before SimplifyComparisonIntegral
+ // MIR for `opt_negative` after SimplifyComparisonIntegral
fn opt_negative(_1: i32) -> u32 {
debug x => _1; // in scope 0 at $DIR/if-condition-int.rs:28:17: 28:18
let mut _0: u32; // return place in scope 0 at $DIR/if-condition-int.rs:28:28: 28:31
let mut _2: bool; // in scope 0 at $DIR/if-condition-int.rs:29:8: 29:16
let mut _3: i32; // in scope 0 at $DIR/if-condition-int.rs:29:8: 29:9
bb0: {
StorageLive(_2); // scope 0 at $DIR/if-condition-int.rs:29:8: 29:16
StorageLive(_3); // scope 0 at $DIR/if-condition-int.rs:29:8: 29:9
_3 = _1; // scope 0 at $DIR/if-condition-int.rs:29:8: 29:9
- _2 = Eq(move _3, const -42_i32); // scope 0 at $DIR/if-condition-int.rs:29:8: 29:16
- StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:29:15: 29:16
- switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:29:8: 29:16
+ nop; // scope 0 at $DIR/if-condition-int.rs:29:8: 29:16
+ nop; // scope 0 at $DIR/if-condition-int.rs:29:15: 29:16
+ switchInt(move _3) -> [-42_i32: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:29:8: 29:16
}
bb1: {
+ StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:29:8: 29:16
_0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:29:19: 29:20
goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:29:5: 29:33
}
bb2: {
+ StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:29:8: 29:16
_0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:29:30: 29:31
goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:29:5: 29:33
}
bb3: {
StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:29:32: 29:33
return; // scope 0 at $DIR/if-condition-int.rs:30:2: 30:2
}
}