Closed
Description
Ever since @alexcrichton refactored lints (which was awesome!) to print eagerly, the unused import lints have gotten pretty annoying. Example output from a recent compilation session:
error[E0432]: unresolved import `rustc::util::CellUsizeExt`
--> src/librustc_traits/normalize_projection_ty.rs:19:5
|
19 | use rustc::util::CellUsizeExt;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ no `CellUsizeExt` in `util`
warning: unused import: `rustc::util::CellUsizeExt`
--> src/librustc_traits/normalize_projection_ty.rs:19:5
|
19 | use rustc::util::CellUsizeExt;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
^^^^^^^^^^^^^^^^^^^^^^^^^
Note that I got an error about the import not being valid -- and then a lint that my invalid path is not used! Here is a similar problem, in a standalone test case:
use std::io::Write;
fn main() {
let x = File::open(22); // deliberate missing import
x.write(22);
}
As of now, I get this output (in stable, but also nightly):
Compiling playground v0.0.1 (file:///playground)
error[E0433]: failed to resolve. Use of undeclared type or module `File`
--> src/main.rs:4:13
|
4 | let x = File::open("foo");
| ^^^^ Use of undeclared type or module `File`
warning: unused import: `std::io::Write`
--> src/main.rs:1:5
|
1 | use std::io::Write;
| ^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
I have also frequently seen it happen that the unused import lint comes first, which is extra annoying.