Skip to content

Commit

Permalink
Rollup merge of rust-lang#100434 - compiler-errors:issue-100373, r=cj…
Browse files Browse the repository at this point in the history
…gillot

Fix HIR pretty printing of let else

Fixes rust-lang#100373
Fixes rust-lang#99318
Fixes rust-lang#99319
  • Loading branch information
Dylan-DPC authored Aug 13, 2022
2 parents f8d1dcc + e182d12 commit 60fa217
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 60fa217

Please sign in to comment.