Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn about lints that are disabled but not currently activated #39958

Open
johnthagen opened this Issue Feb 19, 2017 · 4 comments

Comments

Projects
None yet
5 participants
@johnthagen
Copy link
Contributor

johnthagen commented Feb 19, 2017

It would be nice if rustc could catch an unnecessary use of #[allow(unused_variables)]:

#[allow(unused_variables)]
fn fun(x: u32) -> u32{
    x
}

Often times #[allow(unused_variables)] is added during development and later should be removed after all parameters are in use so that it doesn't mask a real warning in the future.

Originally this was brought up as a lint for clippy (rust-lang/rust-clippy#1552) but was directed here because clippy does not handle allow/warn/deny itself.

@sanmai-NL

This comment has been minimized.

Copy link

sanmai-NL commented Feb 19, 2017

Interesting idea, but what makes such an attribute unnecessary?

@frewsxcv

This comment has been minimized.

Copy link
Member

frewsxcv commented Feb 20, 2017

Interesting idea, but what makes such an attribute unneccessary?

Presumably because the existence of the attribute in that particular scenario doesn't result in any fewer warnings upon compilation.

@sanmai-NL

This comment has been minimized.

Copy link

sanmai-NL commented Feb 20, 2017

@frewsxcv: yeah, but that context may (likely will) change between compilation runs. I would expect the programmer to put those lint check attributes in with a reason. In general, it is wise/good to check for unneeded allow attributes though. I personally see value in an unnecessary_unused attribute, just trying to point out the trade-off here. Giving warnings when the allow attribute coincidentally happens to have no effect at some point in the evolution of the source code is perhaps not desired?

@sanxiyn sanxiyn added the A-lint label Feb 21, 2017

@sanxiyn

This comment has been minimized.

Copy link
Member

sanxiyn commented Feb 21, 2017

This was also discussed in internals.rust-lang.org: Warning about disabled lints that don't need disabling?

@Mark-Simulacrum Mark-Simulacrum changed the title Unnecessary unused_variables lint Warn about lints that are disabled but not currently activated May 23, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.