From 47a7a91c969ed2edd12c674ca05c1baf867f6f6f Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 4 Aug 2022 05:08:09 +0000 Subject: [PATCH] Use (actually) dummy place for let-else divergence --- compiler/rustc_mir_build/src/build/matches/mod.rs | 2 +- src/test/ui/let-else/issue-100103.rs | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/let-else/issue-100103.rs diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index 58b1564cc5d8c..cefb5f36b6a94 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 0000000000000..e393deab764f3 --- /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 = try { + let Some(x) = Some(0) else { + Err(1)? + }; + + x + }; +}