-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Improve unused extern crate
and unused #[macro_use]
warnings
#39060
Conversation
47c8ba5
to
4a90ee4
Compare
extern crate libc; | ||
extern crate std_unicode; | ||
extern crate serialize as rustc_serialize; // used by deriving |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And all these unused crates will still live undetected in Cargo.toml
s and introduce build dependencies :(
rustc
needs to somehow communicate this information to cargo
so it could warn too.
cc @alexcrichton
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's true yeah that it needs to be propagated outwards, but this may not need rustc -> cargo support. The compiler could simply warn about unused --extern
flags, and we could perhaps tailor it so the warning makes sense if you're just using Cargo.
In any case that seems like future work to me.
I've been wary of doing this in the past because linking a crate can have side effects other than wanting to pull in items/macros. For example you might link an allocator or just link a crate which contains a native library. I'd personally still prefer that the lint were allow by default. |
2ae2155
to
3186708
Compare
@alexcrichton |
4785cf4
to
ec51ba3
Compare
@jseyfried I haven't though too closely about how we might solve that problem, although it would likely involve taking a look at the crates that just that one crate pulls in (e.g. not shared dependencies from other crates) and then seeing what items it pulls in (e.g. any native libs, allocators, etc.) |
67dc901
to
2b1d677
Compare
@alexcrichton Ok, seems feasible but not easy -- I might try later in another PR. |
@alexcrichton, @jseyfried |
@alexcrichton
is reported by the |
I'm merely stating my opinion that I would like to not have this lint turned on by default. I personally feel very strongly that if a lint has a false positive it should be allow-by-default, but that's mostly just me. |
@petrochenkov, |
@petrochenkov There were 31 "true positives" and 1 "false positive" in rustc bootstrap. |
@bors: r+ |
📌 Commit 2b1d677 has been approved by |
Rollup of 28 pull requests - Successful merges: #38603, #38761, #38842, #38847, #38955, #38966, #39062, #39068, #39077, #39111, #39112, #39114, #39118, #39120, #39132, #39135, #39138, #39142, #39143, #39146, #39157, #39166, #39167, #39168, #39179, #39184, #39195, #39197 - Failed merges: #39060, #39145
☔ The latest upstream changes (presumably #39199) made this pull request unmergeable. Please resolve the merge conflicts. |
2b1d677
to
7753f19
Compare
@alexcrichton Thanks! |
📌 Commit 7753f19 has been approved by |
⌛ Testing commit 7753f19 with merge f117e15... |
💔 Test failed - status-travis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw if you want to annotate crates in tree to deny this lint by default I'd be down for that
|
||
extern crate getopts; | ||
extern crate term; | ||
extern crate libc; | ||
extern crate panic_unwind; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This, while unused, is intended to be linked for the side effects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed -- thanks again :)
60240aa
to
9e9262b
Compare
📌 Commit 9e9262b has been approved by |
⌛ Testing commit 9e9262b with merge 7a8c8af... |
💔 Test failed - status-travis |
9e9262b
to
191abc4
Compare
@bors r=nrc |
📌 Commit 191abc4 has been approved by |
Improve unused `extern crate` and unused `#[macro_use]` warnings This PR - adds `unused_imports` warnings for unused `#[macro_use] extern crate` macro imports, - improves `unused_extern_crates` warnings (avoids false negatives), and - removes unused `#[macro_use]` imports and unused `extern crate`s. r? @nrc
☀️ Test successful - status-appveyor, status-travis |
This PR
unused_imports
warnings for unused#[macro_use] extern crate
macro imports,unused_extern_crates
warnings (avoids false negatives), and#[macro_use]
imports and unusedextern crate
s.r? @nrc