Skip to content

Stylistic warnings (as errors) in the compiler break the build #143701

Open
@heaths

Description

@heaths

After pulling a new nightly version, we were surprised to see a stylistic lint caught by the compiler that, because we pass -Dwarnings, failed the build. It seems that purely stylistic lints should be done only by clippy (or even check) but not by the compiler, as extra parens is completely valid syntax and, sometimes, used by people to write more maintainable code e.g., grouping expressions while disregarding operator precedence just to future contributes are less confused.

Again, totally reasonable as a lint but seems excessive as a compiler warning.

Code

I tried this code:

let mut error = error.get_ref()? as &(dyn std::error::Error);

I expected to see this happen: nothing should happen. While unnecessary, they also don't cause any issue and are syntactically correct. I could add any number of parens and it wouldn't change the meaning.

Instead, this happened: unused_parens warning-as-error.

We just had to get rid of the parens:

- let mut error = error.get_ref()? as &(dyn std::error::Error);
+ let mut error = error.get_ref()? as &dyn std::error::Error;

Both are syntactically correct so this seems purely stylistic and not something we'd expect in the compiler.

Version it worked on

It most recently worked on a version of nightly a few weeks older. Sorry, I don't have which version it was handy but this issue is more about not making stylistic lints a warning in the compiler.

Version with regression

rustc 1.90.0-nightly (ab68b0fb2 2025-07-08)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-discussionCategory: Discussion or questions that doesn't represent real issues.L-unused_parensLint: unused_parensT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions