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

unused variable / dead assignment warnings should have lint modes #3266

Closed
nikomatsakis opened this issue Aug 24, 2012 · 6 comments
Closed
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@nikomatsakis
Copy link
Contributor

RIght now, they are always issued as warnings without any control from the user. To hook into the lint system, the liveness code has to be modified to thread along an expr/item id. Not a huge deal but sufficiently annoying I didn't do it.

@nikomatsakis
Copy link
Contributor Author

I did drop in some fixme's into the code.

@brson
Copy link
Contributor

brson commented Sep 20, 2012

If we do this can we remove feature that allows the _ prefix turn off the warning?

@nikomatsakis
Copy link
Contributor Author

I was wondering whether that would be a good thing or not. Currently I think not for two reasons.

First, the lint annotations are very chatty. Something like

fn foo(_v: uint) { }

is a lot less chatty than

#[no(warn_unused_variables)]
fn foo(v: uint) { }

of course maybe we should just disable this warning for function parameters. Most compilers do. Similarly, let _ignored = something_with_a_dtor() is tolerable, but adding an annotation, not so much.

Second, I think right now they are too coarse-grained. We'd need them to be applicable at the level of individual statements.

I guess both of these problems are fixable though.

@graydon
Copy link
Contributor

graydon commented Mar 20, 2013

non-critical for 0.6, de-milestoning

@metajack
Copy link
Contributor

metajack commented Apr 3, 2013

I would like this for Servo, specifically for the auto-generated bindings. I already use allow(unused_imports) now for similar reasons. think _ as a prefix suppression should also be kept.

bors added a commit that referenced this issue Apr 10, 2013
This leaves the default lint modes at `warn`, but now the unused variable and dead assignment warnings are configurable on a per-item basis. As described in #3266, this just involved carrying around a couple ids to pass over to `span_lint`. I personally would prefer to keep the `_` prefix as well.

This closes #3266.
@alexcrichton
Copy link
Member

I think this can be closed now.

bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
jaisnan pushed a commit to jaisnan/rust-dev that referenced this issue Jul 29, 2024
jaisnan pushed a commit to jaisnan/rust-dev that referenced this issue Jul 29, 2024
In rust-lang#3266 a job to build macOS ARM binaries was added, but the artifacts
weren't yet propagated to the release. This PR adds this missing step.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

6 participants