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

Lint for unused extern mod #10385

Closed
klutzy opened this issue Nov 9, 2013 · 3 comments
Closed

Lint for unused extern mod #10385

klutzy opened this issue Nov 9, 2013 · 3 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@klutzy
Copy link
Contributor

klutzy commented Nov 9, 2013

extern mod extra;
fn main() {}

Would be good if rustc prints lint warning for unused extern mod.

@alexcrichton
Copy link
Member

This would be a bit tricky because currently every program links to the rustuv crate, and I don't think that any of the ever explicitly use it at all. It registers something to be put in the crate map, which is considered as "using' the rustuv crate, but this doesn't happen until translation time.

That being said, we have lots of lints for other unused things, so why not extern mod as well!

@elinorbgr
Copy link
Contributor

Hello,
Seeing the tag E-easy, I gave a try to this. While creating the lint itself was indeed pretty easy, there is currently no tracking of whether an extern crate as been used or not in librustc/middle/resolve.rs (where the tacking of used imports is done). So at my point, every extern crate is marked as unused by the lint checker.
But the tracking code of imports itself seems to be a side effect of the whole resolve code, and thus it is quite difficult to understand the whole thing enough to add tracking of extern crates as well. I'm not sure whether I'll manage to figure it out or not.

bors added a commit that referenced this issue Sep 12, 2014
…richton

This PR creates a new lint : ``unused_extern_crate``, which do pretty much the same thing as ``unused_import``, but for ``extern crate`` statements. It is related to feature request #10385.

I adapted the code tracking used imports so that it tracks extern crates usage as well. This was mainly trial and error and while I believe all cases are covered, there might be some code I added that is useless (long compile times didn't give me the opportunity to check this in detail).

Also, I removed some unused ``extern crate`` statements from the libs, that where spotted by this new lint.
@ghost
Copy link

ghost commented Oct 11, 2014

So I think this is done. Thank you, @vberger!

@ghost ghost closed this as completed Oct 11, 2014
Jarcho pushed a commit to Jarcho/rust that referenced this issue Feb 26, 2023
Update readme description of `restriction` lints to dissuade casual use.

Adds some stronger wording about not enabling `restriction` lints. I've seen it come up a few times where people are confused about what the `restriction` category is for and end up casually enabling lints from it (or the whole category).

changelog: None
flip1995 added a commit to flip1995/rust that referenced this issue Apr 18, 2024
The lint table and the restriction group description was improved in rust-lang#10385,
but only in the README. Apply the same changes to the book.
flip1995 pushed a commit to flip1995/rust that referenced this issue Apr 18, 2024
Consistent lint group table in book and README

The lint table and the restriction group description was improved in rust-lang#10385, but only in the README. Apply the same changes to the book.

r? `@xFrednet`

I noticed that I left review comments about this in rust-lang#10385, but never submitted them. So to this day they are listed as "pending" in the GitHub UI.

This is just copy and paste of the current README file on `master`.

changelog: none
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

4 participants