diff options
| author | bors <bors@rust-lang.org> | 2022-10-05 20:47:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-10-05 20:47:39 +0000 |
| commit | c97d02cdb5ca5f5e9eff1fa9e4560d220d1fd2a0 (patch) | |
| tree | a1f4d6366cbbaf82445e15044966c745226e9846 /src | |
| parent | 75ada3a1534fbc4801c73fafecd0f7455f1e3419 (diff) | |
| parent | 565c35aa5c3c39626fcd332bafbd8936b70ed989 (diff) | |
| download | rust-c97d02cdb5ca5f5e9eff1fa9e4560d220d1fd2a0.tar.gz rust-c97d02cdb5ca5f5e9eff1fa9e4560d220d1fd2a0.zip | |
Auto merge of #102394 - dingxiangfei2009:issue-102317, r=oli-obk
Fix unwind drop glue for if-then scopes cc `@est31` Fix #102317 Fix #99852 This PR fixes the drop glue for unwinding from a panic originated in a drop while breaking out for the else block in an `if-then` scope. MIR validation does not fail for the synchronous versions of the test program, because `StorageDead` statements are skipped over in the unwinding process. It is only becoming a problem when it is inside a generator where `StorageDead` must be kept around.
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/let-else/issue-102317.rs | 20 | ||||
| -rw-r--r-- | src/test/ui/mir/issue-99852.rs | 24 |
2 files changed, 44 insertions, 0 deletions
diff --git a/src/test/ui/let-else/issue-102317.rs b/src/test/ui/let-else/issue-102317.rs new file mode 100644 index 00000000000..7369b4938ee --- /dev/null +++ b/src/test/ui/let-else/issue-102317.rs @@ -0,0 +1,20 @@ +// issue #102317 +// build-pass +// compile-flags: --edition 2021 -C opt-level=3 -Zvalidate-mir + +struct SegmentJob; + +impl Drop for SegmentJob { + fn drop(&mut self) {} +} + +pub async fn run() -> Result<(), ()> { + let jobs = Vec::<SegmentJob>::new(); + let Some(_job) = jobs.into_iter().next() else { + return Ok(()) + }; + + Ok(()) +} + +fn main() {} diff --git a/src/test/ui/mir/issue-99852.rs b/src/test/ui/mir/issue-99852.rs new file mode 100644 index 00000000000..1c675788ee9 --- /dev/null +++ b/src/test/ui/mir/issue-99852.rs @@ -0,0 +1,24 @@ +// check-pass +// compile-flags: -Z validate-mir +#![feature(let_chains)] + +fn lambda<T, U>() -> U +where + T: Default, + U: Default, +{ + let foo: Result<T, ()> = Ok(T::default()); + let baz: U = U::default(); + + if let Ok(foo) = foo && let Ok(bar) = transform(foo) { + bar + } else { + baz + } +} + +fn transform<T, U>(input: T) -> Result<U, ()> { + todo!() +} + +fn main() {} |
