-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
mir-opt
test for better drop elaboration
- Loading branch information
1 parent
dd155df
commit 8ea5ac6
Showing
1 changed file
with
41 additions
and
0 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
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 |