Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Fixing unused imports #56

Closed
rohitjoshi opened this issue Jan 30, 2018 · 3 comments
Closed

Fixing unused imports #56

rohitjoshi opened this issue Jan 30, 2018 · 3 comments
Labels
postponed Later is better than never, right?

Comments

@rohitjoshi
Copy link

I really like rustfix and expectations are more :)

cargo build identifies unused imports. I would like to see rustfix provides similar suggestion and remove these unused imports.

e.g.

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;
   |     ^^^^^^^^
@oli-obk
Copy link
Collaborator

oli-obk commented Jan 30, 2018

This should be fixed in rustc by creating an empty suggestion

@killercup
Copy link
Member

killercup commented Jan 30, 2018

Yeah, I've been missing that too! :)

The strategy is to suggest replacing the unused import with an empty string. If it is the only item in the use (i.e., std::fs in use std::fs; is unused, in contrast to File in use std::fs::{File, copy} is unused), remove the whole use statement.

This suggestion needs to be implemented in rustc, probably here.

I couldn't find an open issue there, you should open one! Feel free to copy this comment too if you like :) (Maybe mention rust-lang/rust#42823 as it tracks a few diagnostic things already.)

Edit: Damn you @oli-obk I'm writing a long comment here and you just waltz in and say the same thing! Again! :P

@rohitjoshi
Copy link
Author

It would be good to remove unused crates extern crate xxx

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
postponed Later is better than never, right?
Projects
None yet
Development

No branches or pull requests

3 participants