rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.06k stars 12.4k forks source link

Proposal: Split `unused-variables` lint into `unused-variables`, `unused-function-parameters`, and `unused-trait-function-parameters` #74804

Open rickvanprim opened 4 years ago

rickvanprim commented 4 years ago

Per my own style preferences, I would like to disable unused-variables warnings on trait function implementations for unused parameters (related https://github.com/rust-lang/rust/issues/26487#issuecomment-169828205), while still being warned if non-trait functions have unused parameters, or if any of my function bodies have unused variables.

I propose splitting unused-variables lint into unused-variables, unused-function-parameters, and unused-trait-function-parameters. I'd expect all three to be warn by default to match current behavior. It seems like there's a little bit of precedent as there are already a variety of unused-X lints.

ian-h-chamberlain commented 2 months ago

If this were implemented, I think unused-variables would have to keep its current behavior to avoid warning on previously-accepted code, right (i.e. function parameters)? For example if someone had --deny=warnings --allow=unused-variables, the new behavior you described would stop compiling if they had unused function parameters, I think?

Maybe it could be split up like

?? That would theoretically also allow mixing and matching at a more granular level, but the existing behavior of unused-variables could remain unchanged.