rust-lang / rust-lang/rust-analyzer

Quick fix `Remove all the unused imports` should not remove `proc_macro_attribute` which is in-used

Open
#16,995 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

rust-analyzer version: v0.3.1906-standalone

rustc version: rustc 1.73.0 (cc66ad468 2023-10-03)

editor or extension: VSCode

relevant settings:

repository link (if public, optional):

code snippet to reproduce:

use {
    napi::bindgen_prelude::{AbortSignal, Buffer},
    napi_derive::napi,
};

#[napi]
pub fn foo(x: Buffer) {
    let _ = x;
}

actual

Quick fix Remove all the unused imports remove proc_macro_attribute which is in-used.

use
    napi::bindgen_prelude::Buffer
;

#[napi]
pub fn foo(x: Buffer) {
    let _ = x;
}

expected

Quick fix Remove all the unused imports should not remove proc_macro_attribute which is in-used.

use {
    napi::bindgen_prelude::Buffer,
    napi_derive::napi,
};

#[napi]
pub fn foo(x: Buffer) {
    let _ = x;
}

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 Rust snippet and the Remove all the unused imports quick fix, checking how it handles the napi_derive::napi proc-macro attribute. The fix is done when the quick fix removes only genuinely unused imports and preserves napi in the expected output.

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
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.