Avoid parenthesizing unsplittable because of comments (#8431)

This commit is contained in:
Micha Reiser 2023-11-03 14:12:59 +09:00 committed by GitHub
parent a08c5b7fa7
commit dd2d8cb579
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 781 additions and 35 deletions

View file

@ -59,7 +59,10 @@ impl NeedsParentheses for AnyExpressionYield<'_> {
OptionalParentheses::Never
} else {
// Ex) `x = yield f(1, 2, 3)`
value.needs_parentheses(self.into(), context)
match value.needs_parentheses(self.into(), context) {
OptionalParentheses::BestFit => OptionalParentheses::Never,
parentheses => parentheses,
}
}
} else {
// Ex) `x = yield`