Merge pull request #2113 from rtfeldman/joshuawarner32/fix-indentation-within-parens

Fix formatting of if as an left-hand-side of an operator
This commit is contained in:
Folkert de Vries 2021-12-01 13:38:22 +01:00 committed by GitHub
commit d37ddeb162
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -1098,6 +1098,7 @@ fn sub_expr_requests_parens(expr: &Expr<'_>) -> bool {
BinOp::Pizza | BinOp::Assignment | BinOp::HasType | BinOp::Backpassing => false,
})
}
Expr::If(_, _) => true,
_ => false,
}
}

View file

@ -2310,6 +2310,15 @@ mod test_fmt {
));
}
#[test]
fn binop_if() {
expr_formats_same(indoc!(
r#"
5 * (if x > 0 then 1 else 2)
"#
));
}
// UNARY OP
#[test]