rust-lang / rust-lang/rust-analyzer
Remove imports often doesn't commit the change causing future assist calls to bug
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)
0.3.2045-standalone (4afe0d539 2024-07-21)
rustc version: (eg. output of rustc -V)
rustc 1.80.0 (051478957 2024-07-21)
editor or extension: (eg. VSCode, Vim, Emacs, etc. For VSCode users, specify your extension version; for users of other editors, provide the distribution if applicable)
VSCode
relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)
repository link (if public, optional): (eg. rust-analyzer)
code snippet to reproduce:
use std::{
alloc::Layout,
io::{stdout, Write},
};
fn main() {
write!(stdout(), "Hello, world!\n").unwrap();
}
Trigger remove unused import on the alloc line:
use std::io::{stdout, Write};
fn main() {
write!(stdout(), "Hello, world!\n").unwrap();
}
Trigger this again results in this odd output:
use std::ain() { write!(stdout(), "Hello, world!\n").unwrap();
}
The above is a minimal repro, but I trigger this bug fairly regularly in normal use when attempting to clean up imports. It's a broken window / paper cut problem.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in VSCode with the reported rust-analyzer version and the minimal Rust snippet, triggering remove unused import on the alloc line twice. Trace the assist behavior that applies the import removal; done means repeated cleanup leaves valid source and does not corrupt the function body.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, vscode
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100