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 unused extern crate #17134

Merged
merged 2 commits into from
Sep 12, 2014
Merged

Lint unused extern crate #17134

merged 2 commits into from
Sep 12, 2014

Conversation

elinorbgr
Copy link
Contributor

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.

@alexcrichton
Copy link
Member

We may want to consider moving this lint to allow-by-default, as linkage is normally much trickier and nuanced than things like imports. In terms of rust-semantics, an unused crate should probably be deleted, but in terms of an unused library I don't think a lint can actually cover that (only the linker can).

Also, can you add a test for this as well? You'll fine some similar tests for lints in src/test/compile-fail

@elinorbgr
Copy link
Contributor Author

@alexcrichton is this test okay ?

@alexcrichton
Copy link
Member

That looks great, thanks! One last thing you may want to consider is adding this to the unused group of lints: https://github.com/rust-lang/rust/blob/master/src/librustc/lint/context.rs#L202-L204.

Other than that this looks good to me, thanks!

@elinorbgr
Copy link
Contributor Author

@alexcrichton Okay, done. I also rebased and squashed the commits.

@elinorbgr
Copy link
Contributor Author

@alexcrichton Oops, I had left some too long lines, I corrected that.

bors added a commit that referenced this pull request 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.
@bors bors closed this Sep 12, 2014
@bors bors merged commit 8e61612 into rust-lang:master Sep 12, 2014
@elinorbgr elinorbgr deleted the lint_unused_extern_crate branch September 14, 2014 09:21
RalfJung pushed a commit to RalfJung/rust that referenced this pull request Apr 26, 2024
internal: Don't render unknown lifetimes when rendering generic args

cc rust-lang/rust-analyzer#17098
RalfJung pushed a commit to RalfJung/rust that referenced this pull request Apr 27, 2024
internal: Don't render unknown lifetimes when rendering generic args

cc rust-lang/rust-analyzer#17098
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants