Skip to content

unused_extern_crates: wrong suggestion for aliased crate #57672

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
ehuss opened this issue Jan 16, 2019 · 1 comment · Fixed by #60252
Closed

unused_extern_crates: wrong suggestion for aliased crate #57672

ehuss opened this issue Jan 16, 2019 · 1 comment · Fixed by #60252
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-resolve Area: Name/path resolution done by `rustc_resolve` specifically A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ehuss
Copy link
Contributor

ehuss commented Jan 16, 2019

The following suggests converting to a use, but that causes it to fail to compile because use does not insert into the prelude.

#![warn(unused_extern_crates)]

extern crate time as time_crate;  // Suggests replacing with `use`.

pub mod m {
    pub use time_crate::Duration;   // But this will fail to compile.
}

Perhaps the suggestion should be removed if there is a rename?

rustc 1.33.0-nightly (2fadb0a 2019-01-13)
(This is after uniform-paths and the #57557 fix.)

@cramertj cramertj added A-frontend Area: Compiler frontend (errors, parsing and HIR) A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-resolve Area: Name/path resolution done by `rustc_resolve` specifically T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` labels Jan 16, 2019
@sunjay
Copy link
Member

sunjay commented Apr 24, 2019

Related case of what seems to be the same issue as this: #60222

(Thanks to @ehuss for pointing that out)

bors added a commit that referenced this issue May 18, 2019
Don't suggest changing extern crate w/ alias to use.

Fixes #57672.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-resolve Area: Name/path resolution done by `rustc_resolve` specifically A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants