rust-lang / rust-lang/rust-analyzer

Import insertion can remove used names from an import

Open
#9,407 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

use heapless::pool;

pool!(P: u8);

fn main() {
    P::grow$0(&mut [0; 1024]);
}

Applying the "Import heapless::pool::singleton::Pool" assist to make grow resolve results in this code, which does not compile, because the pool! macro is no longer getting imported:

use heapless::pool::{self, singleton::Pool};

pool!(P: u8);

fn main() {
    P::grow(&mut [0; 1024]);
}

(we also seem to incorrectly import the macro during name resolution)

Tested with heapless 0.7.1

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 import-assist behavior with the heapless 0.7.1 example, then trace the import insertion and name-resolution paths involved in the assist. Done means applying the assist keeps the pool macro available and the resulting code compiles without incorrectly importing the macro.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
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.