Fix negative float and non-base-10 literal patterns

This commit is contained in:
Joshua Warner 2025-01-11 21:58:04 -08:00
parent 962534e3d1
commit f08a0012ea
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
5 changed files with 56 additions and 2 deletions

View file

@ -294,7 +294,8 @@ fn fmt_pattern_only(
is_negative,
} => {
buf.indent(indent);
let needs_parens = parens == Parens::InClosurePattern;
let needs_parens = parens == Parens::InClosurePattern
|| (parens == Parens::InPncApplyFunc && *is_negative);
if needs_parens {
buf.push('(');
}
@ -317,7 +318,8 @@ fn fmt_pattern_only(
}
Pattern::FloatLiteral(string) => {
buf.indent(indent);
let needs_parens = parens == Parens::InClosurePattern;
let needs_parens = parens == Parens::InClosurePattern
|| (parens == Parens::InPncApplyFunc && string.starts_with('-'));
if needs_parens {
buf.push('(');
}