diff options
| author | Michael Goulet <michael@errs.io> | 2022-08-04 05:08:09 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-08-04 05:08:09 +0000 |
| commit | 47a7a91c969ed2edd12c674ca05c1baf867f6f6f (patch) | |
| tree | 17f7ba57188046248e221f76389f24e1d6d02fa4 | |
| parent | 1b57946a405d5b2a87e612335db033edb2c3427f (diff) | |
| download | rust-47a7a91c969ed2edd12c674ca05c1baf867f6f6f.tar.gz rust-47a7a91c969ed2edd12c674ca05c1baf867f6f6f.zip | |
Use (actually) dummy place for let-else divergence
| -rw-r--r-- | compiler/rustc_mir_build/src/build/matches/mod.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/let-else/issue-100103.rs | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index 58b1564cc5d..cefb5f36b6a 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -2334,7 +2334,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // This place is not really used because this destination place // should never be used to take values at the end of the failure // block. - let dummy_place = Place { local: RETURN_PLACE, projection: ty::List::empty() }; + let dummy_place = self.temp(self.tcx.types.never, else_block.span); let failure_block; unpack!( failure_block = self.ast_block( diff --git a/src/test/ui/let-else/issue-100103.rs b/src/test/ui/let-else/issue-100103.rs new file mode 100644 index 00000000000..e393deab764 --- /dev/null +++ b/src/test/ui/let-else/issue-100103.rs @@ -0,0 +1,15 @@ +// edition:2021 +// check-pass + +#![feature(try_blocks)] +#![feature(let_else)] + +fn main() { + let _: Result<i32, i32> = try { + let Some(x) = Some(0) else { + Err(1)? + }; + + x + }; +} |
