forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#69676 - ecstatic-morse:fix-enum-discr-effec…
…t, r=oli-obk Pass correct place to `discriminant_switch_effect` PR rust-lang#69562, which fixed a bug that was causing clippy to ICE, mistakenly passed the place holding the *result* of `Rvalue::Discriminant` instead of the place holding its *operand* to `apply_discriminant_switch_effect` as the enum place. As a result, no effect was applied at all, and we lost the perf benefits from marking inactive enum variants as uninitialized. This PR corrects that mistake and adds a regression test to `mir-opt`. I fear that the regression test may prove too brittle; the test schema makes hard to test for the *absence* of certain kinds of MIR without exhaustively matching each basic block. r? @oli-obk
- Loading branch information
Showing
2 changed files
with
69 additions
and
20 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
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,41 @@ | ||
// Ensure that there are no drop terminators in `unwrap<T>` (except the one along the cleanup | ||
// path). | ||
|
||
fn unwrap<T>(opt: Option<T>) -> T { | ||
match opt { | ||
Some(x) => x, | ||
None => panic!(), | ||
} | ||
} | ||
|
||
fn main() { | ||
let _ = unwrap(Some(1i32)); | ||
} | ||
|
||
// END RUST SOURCE | ||
// START rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir | ||
// fn unwrap(_1: std::option::Option<T>) -> T { | ||
// ... | ||
// bb0: { | ||
// ... | ||
// switchInt(move _2) -> [0isize: bb2, 1isize: bb4, otherwise: bb3]; | ||
// } | ||
// bb1 (cleanup): { | ||
// resume; | ||
// } | ||
// bb2: { | ||
// ... | ||
// const std::rt::begin_panic::<&'static str>(const "explicit panic") -> bb5; | ||
// } | ||
// bb3: { | ||
// unreachable; | ||
// } | ||
// bb4: { | ||
// ... | ||
// return; | ||
// } | ||
// bb5 (cleanup): { | ||
// drop(_1) -> bb1; | ||
// } | ||
// } | ||
// END rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir |