Description
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)