Fix HIR pretty printing of let else
This commit is contained in:
parent
2ed0f29168
commit
e182d12a84
3 changed files with 32 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
10
src/test/ui/unpretty/pretty-let-else.rs
Normal file
10
src/test/ui/unpretty/pretty-let-else.rs
Normal 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() {}
|
18
src/test/ui/unpretty/pretty-let-else.stdout
Normal file
18
src/test/ui/unpretty/pretty-let-else.stdout
Normal 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() { }
|
Loading…
Add table
Reference in a new issue