mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Pretty-print let-else with added parenthesization when needed
This commit is contained in:
parent
68854b798e
commit
94cc82c088
@ -1238,7 +1238,11 @@ impl<'a> State<'a> {
|
||||
if let Some((init, els)) = loc.kind.init_else_opt() {
|
||||
self.nbsp();
|
||||
self.word_space("=");
|
||||
self.print_expr(init, FixupContext::default());
|
||||
self.print_expr_cond_paren(
|
||||
init,
|
||||
els.is_some() && classify::expr_trailing_brace(init).is_some(),
|
||||
FixupContext::default(),
|
||||
);
|
||||
if let Some(els) = els {
|
||||
self.cbox(INDENT_UNIT);
|
||||
self.ibox(INDENT_UNIT);
|
||||
|
@ -11,5 +11,5 @@ macro_rules! expr { ($e:expr) => { $e }; }
|
||||
|
||||
fn main() {
|
||||
let _ = 1 + 1 else { return; };
|
||||
let _ = loop {} else { return; };
|
||||
let _ = (loop {}) else { return; };
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user