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

unused_extern_crates: does not handle renamed crates used in other modules #57421

Closed
ehuss opened this issue Jan 7, 2019 · 4 comments
Closed
Labels
A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`

Comments

@ehuss
Copy link
Contributor

ehuss commented Jan 7, 2019

The following suggests removing the extern crate which results in broken code.

#![warn(unused_extern_crates)]

extern crate time as time_crate;

pub mod m {
    pub use time_crate::Duration;
}

The following is also very similar:

#![warn(unused_extern_crates)]

extern crate time as time_crate;

pub mod m {
    use time_crate::Duration;
    pub fn f() {
        Duration::days(1);
    }
}
@petrochenkov
Copy link
Contributor

Fixed in #57557

@petrochenkov petrochenkov removed their assignment Jan 12, 2019
Centril added a commit to Centril/rust that referenced this issue Jan 13, 2019
resolve: Mark extern crate items as used in more cases

Fixes rust-lang#57421
@ehuss
Copy link
Contributor Author

ehuss commented Jan 16, 2019

@petrochenkov The unused_extern_crates suggestion still doesn't seem to be working right in this scenario. Maybe this should stay open? Now, instead of suggesting removing the extern crate, it suggests replacing it with use, but that still does not compile.

#![warn(unused_extern_crates)]

use time as time_crate;

pub mod m {
    pub use time_crate::Duration;  // Error, time_crate not found.
}

@petrochenkov
Copy link
Contributor

@ehuss
Could you open a new issue?
"Replace extern crate with use" is actually an entirely different thing from "extern crate is unused", I don't know why they merged it into the same lint.

@ehuss
Copy link
Contributor Author

ehuss commented Jan 16, 2019

Ok, filed #57672. Thanks for taking a look and all the fixes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`
Projects
None yet
Development

No branches or pull requests

3 participants