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

Suggest removal for unused_imports warning #48675

Closed
alexheretic opened this issue Mar 2, 2018 · 2 comments
Closed

Suggest removal for unused_imports warning #48675

alexheretic opened this issue Mar 2, 2018 · 2 comments

Comments

@alexheretic
Copy link
Member

rustc correctly highlights unused imports, but doesn't provide an action to remove them. Providing the removal via the lint allows fix buttons in IDEs to handle unused imports and further more automatic behaviour working towards rust-lang/rls#742.

Can unused import suggested removal be added?

use std::{f64, u64, u8 as Foo};

pub fn main() {
    let _s = u64::MAX;
}
warning: unused imports: `f64`, `u8 as Foo`
 --> src/main.rs:4:11
  |
4 | use std::{f64, u64, u8 as Foo};
  |           ^^^       ^^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default
{
  "children": [{
    "children": [],
    "code": null,
    "level": "note",
    "message": "#[warn(unused_imports)] on by default",
    "rendered": null,
    "spans": []
  }],
  "code": {
    "code": "unused_imports",
    "explanation": null
  },
  "level": "warning",
  "message": "unused imports: `f64`, `u8 as Foo`",
  "rendered": "warning: unused imports: `f64`, `u8 as Foo`\n --> src/main.rs:4:11\n  |\n4 | use std::{f64, u64, u8 as Foo};\n  |           ^^^       ^^^^^^^^^\n  |\n  = note: #[warn(unused_imports)] on by default\n\n",
  "spans": [{
    "byte_end": 56,
    "byte_start": 53,
    "column_end": 14,
    "column_start": 11,
    "expansion": null,
    "file_name": "src/main.rs",
    "is_primary": true,
    "label": null,
    "line_end": 4,
    "line_start": 4,
    "suggested_replacement": null,
    "text": [{
      "highlight_end": 14,
      "highlight_start": 11,
      "text": "use std::{f64, u64, u8 as Foo};"
    }]
  }, {
    "byte_end": 72,
    "byte_start": 63,
    "column_end": 30,
    "column_start": 21,
    "expansion": null,
    "file_name": "src/main.rs",
    "is_primary": true,
    "label": null,
    "line_end": 4,
    "line_start": 4,
    "suggested_replacement": null,
    "text": [{
      "highlight_end": 30,
      "highlight_start": 21,
      "text": "use std::{f64, u64, u8 as Foo};"
    }]
  }]
}
@zackmdavis
Copy link
Member

(duplicate of #47888)

@alexheretic
Copy link
Member Author

Ok thanks I missed that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants