diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-03-03 12:05:59 -0800 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-03-10 17:18:16 -0700 |
| commit | 8ea5ac60b6723356dc14954d10c5069175f61fc2 (patch) | |
| tree | 1e2bf8c1dfdc20033a85ea16a791516e12ed5e72 | |
| parent | dd155df0a69338757ca39a2a606a6accb7b8d342 (diff) | |
| download | rust-8ea5ac60b6723356dc14954d10c5069175f61fc2.tar.gz rust-8ea5ac60b6723356dc14954d10c5069175f61fc2.zip | |
Add `mir-opt` test for better drop elaboration
| -rw-r--r-- | src/test/mir-opt/no-drop-for-inactive-variant.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/test/mir-opt/no-drop-for-inactive-variant.rs b/src/test/mir-opt/no-drop-for-inactive-variant.rs new file mode 100644 index 00000000000..cccfa2e1d41 --- /dev/null +++ b/src/test/mir-opt/no-drop-for-inactive-variant.rs @@ -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 |
