Skip to content

Commit 7cb54e7

Browse files
committed
add mir-opt test
1 parent 819cf8c commit 7cb54e7

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

compiler/rustc_mir_transform/src/elaborate_drops.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ impl<'tcx> crate::MirPass<'tcx> for ElaborateDrops {
6969
let dead_unwinds = compute_dead_unwinds(body, &mut inits);
7070

7171
let uninits = MaybeUninitializedPlaces::new(tcx, body, &env.move_data)
72+
.include_inactive_in_otherwise()
7273
.mark_inactive_variants_as_uninit()
7374
.skipping_unreachable_unwind(dead_unwinds)
7475
.iterate_to_fixpoint(tcx, body, Some("elaborate_drops"))

tests/mir-opt/otherwise_drops.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ test-mir-pass: ElaborateDrops
2+
3+
// EMIT_MIR otherwise_drops.result_ok.ElaborateDrops.after.mir
4+
fn result_ok(result: Result<String, ()>) -> Option<String> {
5+
match result {
6+
Ok(s) => Some(s),
7+
_ => None,
8+
}
9+
}
10+
11+
fn main() {
12+
result_ok(Err(()));
13+
}

0 commit comments

Comments
 (0)