You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #51010 (not yet merged), I removed the unnecessary_extern_crate "idiom lint" and replaced it with the (pre-existing) unused_extern_crates lint. This lint already handles all the tricky cases and so forth so this seems good to me. (In particular, it will suggest removing the extern crate iff it is unused.)
However, there was some stuff that the unnecessary_extern_crate lint would do which we no longer do. For example, we used to sometimes suggest rewriting an extern crate into a use etc. In the event that we are in Epoch 2018, we can of course still do this in the unused_extern_crates lint. The question is, should we?
It seems to me that — most of the time — having just a random pub use crate_name; may not be the most idiomatic thing to do. You might prefer to rewrite the paths that relied on that to just begin with the crate. Or, if you don't, you might just rather leave the extern crate there. Another point in favor is that there are some functions (e.g., most notably #[macro_use] but maybe also #[no_link]?) that are not easily replicated any other way.
On the other hand, doing that rewrite does mean that fewer people ever have to know that extern crate existed.
The text was updated successfully, but these errors were encountered:
…diom, r=alexcrichton
merge unused-extern-crate and unnecessary-extern-crate lints
Extend the `unused_extern_crates` lint to offer a suggestion to remove the extern crate and remove the `unnecessary_extern_crate` lint.
Still a few minor issues to fix:
- [x] this *does* now leave a blank line... (defer to #51176)
- idea: extend the span to be replaced by 1 character if the next character is a `\n`
- [x] what about macros? do we need to watch out for that? (defer to #48704)
- [x] also it doesn't work for `extern crate foo; fn main() { foo::bar(); }`
- this is subtle: the `foo` might be shadowing a glob import too, can't always remove
- defer to #51177
- [x] we also don't do the `pub use` rewrite thang (#51013)
Spun off from #51010Fixes#50672
r? @alexcrichton
In #51010 (not yet merged), I removed the
unnecessary_extern_crate
"idiom lint" and replaced it with the (pre-existing)unused_extern_crates
lint. This lint already handles all the tricky cases and so forth so this seems good to me. (In particular, it will suggest removing the extern crate iff it is unused.)However, there was some stuff that the
unnecessary_extern_crate
lint would do which we no longer do. For example, we used to sometimes suggest rewriting anextern crate
into ause
etc. In the event that we are in Epoch 2018, we can of course still do this in theunused_extern_crates
lint. The question is, should we?It seems to me that — most of the time — having just a random
pub use crate_name;
may not be the most idiomatic thing to do. You might prefer to rewrite the paths that relied on that to just begin with the crate. Or, if you don't, you might just rather leave theextern crate
there. Another point in favor is that there are some functions (e.g., most notably#[macro_use]
but maybe also#[no_link]
?) that are not easily replicated any other way.On the other hand, doing that rewrite does mean that fewer people ever have to know that
extern crate
existed.The text was updated successfully, but these errors were encountered: