Correctly format nested pipeline operators

Closes #4151
This commit is contained in:
Ayaz Hafiz 2022-10-03 14:18:17 -05:00
parent b7e9b07acb
commit bbb2083dd6
No known key found for this signature in database
GPG Key ID: 0E2A37416A25EF58
2 changed files with 18 additions and 3 deletions

View File

@ -1382,9 +1382,9 @@ fn sub_expr_requests_parens(expr: &Expr<'_>) -> bool {
| BinOp::LessThanOrEq
| BinOp::GreaterThanOrEq
| BinOp::And
| BinOp::Or => true,
BinOp::Pizza
| BinOp::Assignment
| BinOp::Or
| BinOp::Pizza => true,
BinOp::Assignment
| BinOp::IsAliasType
| BinOp::IsOpaqueType
| BinOp::Backpassing => false,

View File

@ -5582,6 +5582,21 @@ mod test_fmt {
));
}
#[test]
fn format_nested_pipeline() {
expr_formats_same(indoc!(
r#"
(a |> b) |> c
"#
));
expr_formats_same(indoc!(
r#"
a |> b |> c
"#
));
}
// this is a parse error atm
// #[test]
// fn multiline_apply() {