Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HIR pretty printing of let else #100434

Merged
merged 1 commit into from
Aug 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() { }