Skip to content

Commit

Permalink
Auto merge of #69744 - ecstatic-morse:fix-enum-discr-effect-test, r=o…
Browse files Browse the repository at this point in the history
…li-obk

Add `mir-opt` test for more precise drop elaboration

Depends on #69676. This test should ensure that the problem fixed in that PR does not reoccur.

This has been split out from #69676 since the test fails on certain targets where no cleanup blocks are emitted. I have to find the correct `ignore` directives.

r? @oli-obk
  • Loading branch information
bors committed Mar 14, 2020
2 parents 5ed3453 + 68f2001 commit 42ce9b4
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/test/mir-opt/no-drop-for-inactive-variant.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// ignore-wasm32-bare compiled with panic=abort by default

// 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

0 comments on commit 42ce9b4

Please sign in to comment.