rust-lang / rust-lang/rust-analyzer

"Remove all the unused imports" assist removes used derive macros

Open
#15,411 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-assists C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

For the following code:

use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
struct MyStruct {
    field: i32,
}

fn main() {
    println!("Hello, world!");
}

The "remove all the unused imports" assist is suggested for the use block.
If applied, it will remove the imports, even though they are being used by a derive macro.

image

rust-analyzer version 0.3.1615-standalone

rustc version: rustc 1.73.0-nightly (04abc370b 2023-07-28)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the serde example in the report and invoke the “remove all the unused imports” assist on its use block. Trace the assist's unused-import handling and verify that imports referenced only by derive macros are retained while genuinely unused imports are removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.