Rollup merge of #100434 - compiler-errors:issue-100373, r=cjgillot

Fix HIR pretty printing of let else

Fixes #100373
Fixes #99318
Fixes #99319
This commit is contained in:
Michael Goulet 2022-08-13 14:10:06 -07:00 committed by GitHub
commit 2126cc62fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 0 deletions

View File

@ -911,6 +911,10 @@ pub fn print_local(
if let Some(els) = els {
self.nbsp();
self.word_space("else");
// containing cbox, will be closed by print-block at `}`
self.cbox(0);
// head-box, will be closed by print-block after `{`
self.ibox(0);
self.print_block(els);
}

View File

@ -0,0 +1,10 @@
// compile-flags: -Zunpretty=hir
// check-pass
#![feature(let_else)]
fn foo(x: Option<u32>) {
let Some(_) = x else { panic!() };
}
fn main() {}

View File

@ -0,0 +1,18 @@
// compile-flags: -Zunpretty=hir
// check-pass
#![feature(let_else)]
#[prelude_import]
use ::std::prelude::rust_2015::*;
#[macro_use]
extern crate std;
fn foo(x:
Option<u32>) {
let Some(_) = x else
{
{ ::std::rt::begin_panic("explicit panic") }
};
}
fn main() { }