Merge pull request #3453 from rtfeldman/fix-comment-fmt

Fix comment between multiline annotation args
This commit is contained in:
Folkert de Vries 2022-07-08 21:28:36 +02:00 committed by GitHub
commit cd06859d9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 3 deletions

View file

@ -207,9 +207,11 @@ impl<'a> Formattable for TypeAnnotation<'a> {
match self {
Function(arguments, result) => {
let write_parens = parens != Parens::NotNeeded;
let needs_parens = parens != Parens::NotNeeded;
if write_parens {
buf.indent(indent);
if needs_parens {
buf.push('(')
}
@ -256,7 +258,7 @@ impl<'a> Formattable for TypeAnnotation<'a> {
indent,
);
if write_parens {
if needs_parens {
buf.push(')')
}
}

View file

@ -4276,6 +4276,21 @@ mod test_fmt {
));
}
#[test]
fn comment_between_multiline_ann_args() {
expr_formats_same(indoc!(
r#"
blah :
Str,
# comment
(Str -> Str)
-> Str
42
"#
))
}
#[test]
fn pipeline_apply_lambda_multiline() {
expr_formats_same(indoc!(