Improper parenthesis addition when using clippy_lints::utils::Sugg::maybe_par
#6767
Labels
C-bug
Category: Clippy is not doing the correct thing
E-medium
Call for participation: Medium difficulty level problem and requires some initial experience.
L-suggestion
Lint: Improving, adding or fixing lint suggestions
While working on #6717, I noticed that sometimes an expression like
(1+2)
would be (falsely?) converted to aSugg::BinOp
, which coupled with themaybe_par
method would produce the suggestion((1+2))
.I'm not sure where the issue is: should the expression have been converted into a
NonParen
in the first place, or doesmaybe_par
need to have an additional check when working withBinOp
? If it's the latter, care must be taken because a simple check that the boundaries are()
is wrong: for example,(1+2) + (3+4)
.Also related - shouldn't the
MaybeParen
branch always return aNonParen
?It should be noted that this bug affects the following lints:
The text was updated successfully, but these errors were encountered: