Remove single-argument function call special-case in formatter
Not sure what this special case was trying to achieve, but it's not right. There's no need to handle function call with a single argument differently than the others.
This commit is contained in:
@@ -843,30 +843,12 @@ impl<'comments> Formatter<'comments> {
|
||||
false
|
||||
};
|
||||
|
||||
match args {
|
||||
[arg] if is_breakable_expr(&arg.value) => self
|
||||
.expr(fun)
|
||||
.append(if needs_curly {
|
||||
break_(" {", " { ")
|
||||
} else {
|
||||
break_("(", "(")
|
||||
})
|
||||
.append(self.call_arg(arg, needs_curly))
|
||||
.append(if needs_curly {
|
||||
break_("}", " }")
|
||||
} else {
|
||||
break_(")", ")")
|
||||
})
|
||||
.group(),
|
||||
|
||||
_ => self
|
||||
.expr(fun)
|
||||
.append(wrap_args(
|
||||
args.iter()
|
||||
.map(|a| (self.call_arg(a, needs_curly), needs_curly)),
|
||||
))
|
||||
.group(),
|
||||
}
|
||||
self.expr(fun)
|
||||
.append(wrap_args(
|
||||
args.iter()
|
||||
.map(|a| (self.call_arg(a, needs_curly), needs_curly)),
|
||||
))
|
||||
.group()
|
||||
}
|
||||
|
||||
pub fn if_expr<'a>(
|
||||
|
||||
@@ -305,3 +305,46 @@ fn test_format_bytearray_literals() {
|
||||
|
||||
assert_fmt(src, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_nested_function_calls() {
|
||||
let src = indoc! {r#"
|
||||
fn foo(output) {
|
||||
[
|
||||
output.address.stake_credential == Some(
|
||||
Inline(
|
||||
VerificationKeyCredential(
|
||||
#"66666666666666666666666666666666666666666666666666666666",
|
||||
))
|
||||
)
|
||||
,
|
||||
when output.datum is {
|
||||
InlineDatum(_) -> True
|
||||
_ -> error("expected inline datum")
|
||||
},
|
||||
]
|
||||
|> list.and
|
||||
}
|
||||
"#};
|
||||
|
||||
let expected = indoc! {r#"
|
||||
fn foo(output) {
|
||||
[
|
||||
output.address.stake_credential == Some(
|
||||
Inline(
|
||||
VerificationKeyCredential(
|
||||
#"66666666666666666666666666666666666666666666666666666666",
|
||||
),
|
||||
),
|
||||
),
|
||||
when output.datum is {
|
||||
InlineDatum(_) -> True
|
||||
_ -> error("expected inline datum")
|
||||
},
|
||||
]
|
||||
|> list.and
|
||||
}
|
||||
"#};
|
||||
|
||||
assert_fmt(src, expected);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user