Pretty-print let-else with added parenthesization when needed
This commit is contained in:
parent
68854b798e
commit
94cc82c088
2 changed files with 6 additions and 2 deletions
|
@ -1238,7 +1238,11 @@ impl<'a> State<'a> {
|
||||||
if let Some((init, els)) = loc.kind.init_else_opt() {
|
if let Some((init, els)) = loc.kind.init_else_opt() {
|
||||||
self.nbsp();
|
self.nbsp();
|
||||||
self.word_space("=");
|
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 {
|
if let Some(els) = els {
|
||||||
self.cbox(INDENT_UNIT);
|
self.cbox(INDENT_UNIT);
|
||||||
self.ibox(INDENT_UNIT);
|
self.ibox(INDENT_UNIT);
|
||||||
|
|
|
@ -11,5 +11,5 @@ macro_rules! expr { ($e:expr) => { $e }; }
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = 1 + 1 else { return; };
|
let _ = 1 + 1 else { return; };
|
||||||
let _ = loop {} else { return; };
|
let _ = (loop {}) else { return; };
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue