rust-lang / rust-lang/rust-analyzer
When using code actions for quick fix, multiple possible options were not split
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
use std;
fn main() {
let x = vec![[2]];
let s: &[i32] = x.iter().map(Deref::deref).next().unwrap();
}
in line 1 use CodeAction
1. remove the whole `use` item │
2. Change visibility to pub(crate) │
3. Remove all the unused imports │
4. consider importing one of these items: `use core::ops::Deref;<00>`, `use │
crate::std::ops::Deref;<00>`, `use std::ops::Deref;<00>` │
expect
1. remove the whole `use` item │
2. Change visibility to pub(crate) │
3. Remove all the unused imports │
4. consider importing `use core::ops::Deref;` │
5. consider importing `use crate::std::ops::Deref;` │
6. consider importing `use std::ops::Deref;` │
rust-analyzer version: rust-analyzer 1.78.0-nightly (bccb9bb 2024-02-16)
rustc version: rustc 1.78.0-nightly (bccb9bbb4 2024-02-16)
relevant settings: NONE
More serious examples:
use std::collections::HashMap;
fn foo(map: &mut HashMap<String, ()>) {
map[""] = ();
}
r-a sends out overlapping text edits, causing the client to errors
Outputs in rustc (behavior changed in rustc 1.100.0-nightly (c54751567 2026-08-22)):
help: use `.insert()` to insert a value into a `HashMap<String, ()>`, `.get_mut()` to modify it, or the entry API for more flexibility
|
4 - map[""] = ();
4 + map.insert("", ());
|
4 - map[""] = ();
4 + if let Some(val) = map.get_mut("") { *val = (); };
|
4 - map[""] = ();
4 + let val = map.entry("").or_insert(());
|
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
Reproduce the Rust example in an editor using rust-analyzer CodeAction quick fixes and inspect the returned actions and text edits. Trace how multiple diagnostic suggestions are represented, including the overlapping HashMap edits. Done means each alternative appears as a separate quick-fix option and clients no longer receive overlapping edits in one action.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100