rust-lang / rust-lang/rust-clippy

double_parens: consider one diagnostic instead of one per pair?

Open
#17,475 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-enhancement D-confusing
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

Description
#![allow(unused_parens)]
#![allow(non_upper_case_globals)]
#![allow(dead_code)]
#![cfg_attr(rustfmt, rustfmt::skip)]
static a: isize = ((((1))));

pub fn main() {}

clippy will print

warning: unnecessary parentheses
 --> a.rs:5:19
  |
5 | static a: isize = ((((1))));
  |                   ^^^^^^^^^ help: remove them: `(((1)))`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_parens
  = note: `#[warn(clippy::double_parens)]` on by default

warning: unnecessary parentheses
 --> a.rs:5:20
  |
5 | static a: isize = ((((1))));
  |                    ^^^^^^^ help: remove them: `((1))`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_parens

warning: unnecessary parentheses
 --> a.rs:5:21
  |
5 | static a: isize = ((((1))));
  |                     ^^^^^ help: remove them: `(1)`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_parens

warning: 3 warnings emitted

which seems a bit over the top, can clippy figure out that we can reduce ((((1)))) to (1) in one go?

warning: unnecessary parentheses
 --> a.rs:5:19
  |
5 | static a: isize = ((((1))));
  |                   ^^^^^^^^^ help: remove them: `(1)`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_parens
  = note: `#[warn(clippy::double_parens)]` on by default
Version
rustc 1.99.0-nightly (1a833e165 2026-07-29)
binary: rustc
commit-hash: 1a833e16546c2eb012758ddd499964fd8afee29e
commit-date: 2026-07-29
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8
Additional Labels

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported double_parens diagnostic with the Rust example in the issue, then trace the lint's implementation and existing tests. Update the behavior so nested redundant parentheses produce one diagnostic whose suggestion reduces ((((1)))) to (1), and verify the resulting output against the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.