Skip to content

Commit 42ce9b4

Browse files
committed
Auto merge of #69744 - ecstatic-morse:fix-enum-discr-effect-test, r=oli-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
2 parents 5ed3453 + 68f2001 commit 42ce9b4

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// ignore-wasm32-bare compiled with panic=abort by default
2+
3+
// Ensure that there are no drop terminators in `unwrap<T>` (except the one along the cleanup
4+
// path).
5+
6+
fn unwrap<T>(opt: Option<T>) -> T {
7+
match opt {
8+
Some(x) => x,
9+
None => panic!(),
10+
}
11+
}
12+
13+
fn main() {
14+
let _ = unwrap(Some(1i32));
15+
}
16+
17+
// END RUST SOURCE
18+
// START rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir
19+
// fn unwrap(_1: std::option::Option<T>) -> T {
20+
// ...
21+
// bb0: {
22+
// ...
23+
// switchInt(move _2) -> [0isize: bb2, 1isize: bb4, otherwise: bb3];
24+
// }
25+
// bb1 (cleanup): {
26+
// resume;
27+
// }
28+
// bb2: {
29+
// ...
30+
// const std::rt::begin_panic::<&'static str>(const "explicit panic") -> bb5;
31+
// }
32+
// bb3: {
33+
// unreachable;
34+
// }
35+
// bb4: {
36+
// ...
37+
// return;
38+
// }
39+
// bb5 (cleanup): {
40+
// drop(_1) -> bb1;
41+
// }
42+
// }
43+
// END rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir

0 commit comments

Comments
 (0)