You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extend the `unused_parens` lint to detect unnecessary parentheses around
method receivers like `(x).method()`. Previously, the lint only checked
method arguments but not the receiver.
The fix adds a new `MethodReceiver` context to `UnusedDelimsCtx` and
checks method call receivers in `check_expr()`. It also handles cases
where parentheses are necessary, such as:
- Range expressions: `(1..10).sum()`
- Unary expressions: `(*ptr).method()`, `(-1).abs()`
- Binary expressions: `(1 + 2).to_string()`
- Cast expressions: `(x as i32).abs()`
- Type expressions, assignments, and address-of expressions
Also removes unnecessary parentheses from the standard library that
were caught by the new lint.
Fixes#151985
0 commit comments