Skip to content

unused_extern_crates lint does not suggest rewriting crates to a use or pub use #51013

Closed
@nikomatsakis

Description

@nikomatsakis

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions