Skip to content

Commit

Permalink
Rollup merge of #100434 - compiler-errors:issue-100373, r=cjgillot
Browse files Browse the repository at this point in the history
Fix HIR pretty printing of let else

Fixes #100373
Fixes #99318
Fixes #99319
  • Loading branch information
compiler-errors committed Aug 13, 2022
2 parents ea42f3c + e182d12 commit 2126cc6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,10 @@ impl<'a> State<'a> {
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);
}

Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/unpretty/pretty-let-else.rs
Original file line number Diff line number Diff line change
@@ -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() {}
18 changes: 18 additions & 0 deletions src/test/ui/unpretty/pretty-let-else.stdout
Original file line number Diff line number Diff line change
@@ -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() { }

0 comments on commit 2126cc6

Please sign in to comment.