Closed
Description
Under certain circumstances involving pub(crate) use Trait
, the compiler issues an "unused import" warning even though the import is actually being used.
This is an example (playground link):
mod foo {
pub(crate) use std::ascii::AsciiExt;
}
mod bar {
use foo::*;
pub fn bar() -> bool {
"bar".is_ascii()
}
}
fn main() {
println!("{}", bar::bar());
}
Since the body of bar::bar()
uses the AsciiExt
trait (AsciiExt
provides .is_ascii()
), there shouldn't be a warning.
Instead, this happened:
warning: unused import: `std::ascii::AsciiExt`
--> src/main.rs:2:20
|
2 | pub(crate) use std::ascii::AsciiExt;
| ^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
Applying any of the following changes makes the warning go away:
- change
pub(crate) use std::ascii::AsciiExt
topub use std::ascii::AsciiExt
- change
use foo::*
touse foo::AsciiExt
- change
"bar".is_ascii()
toAsciiExt::is_ascii("bar")
Meta
This occurs for all versions of the compiler on the playground:
Also, on my machine, rustc --version --verbose
:
rustc 1.21.0 (3b72af97e 2017-10-09)
binary: rustc
commit-hash: 3b72af97e42989b2fe104d8edbaee123cdf7c58f
commit-date: 2017-10-09
host: x86_64-unknown-linux-gnu
release: 1.21.0
LLVM version: 4.0