Closed
Description
Warnings like the following should contain information in their diagnostics output that allows rustfix to remove the unused import.
warning: unused import: `std::io::prelude::*`
--> src/tiso/tiso_msg.rs:10:5
|
10 | use std::io::prelude::*;
| ^^^^^^^^^^^^^^^^^^^
warning: unused import: `std::fmt`
--> src/tiso/tiso_msg.rs:13:5
|
13 | use std::fmt;
| ^^^^^^^^
The strategy is to suggest replacing the unused import with an empty string. There are two cases:
- Are all items in the
use
statement unused (e.g.,std::fs
inuse std::fs;
is unused)? Then remove the wholeuse
statement. - Are only some of the items imported by the
use
statement unused (e.g.,File
inuse std::fs::{File, copy};
is unused)? Remove only these items but keep theuse
statement.
A quick search found this relevant file in typeck:
rust/src/librustc_typeck/check_unused.rs
Lines 27 to 46 in 7051754
Originally opened as https://github.com/killercup/rustfix/issues/56.