rust-lang / rust-lang/rust-analyzer
Wrong range when request at edited std
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: 2026-07-20 tag release (2026-07-13 no this bug)
rustc version: rustc 1.97.0-nightly (36ba2c771 2026-04-23)
editor or extension: Vim coc-rust-analyzer or naked rust-analyzer
code snippet to reproduce:
In ~/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/non_null.rs
#[stable(feature = "nonnull", since = "1.25.0")]
#[repr(transparent)]
#[rustc_nonnull_optimization_guaranteed]
#[rustc_diagnostic_item = "NonNull"]
pub struct NonNull<T: PointeeSized> {
pointer: crate::pattern_type!(*const T is !null),
i$0
}
Outputs:
Error on resolve complete item from rust-analyzer: {
"label": "impl",
"kind": 14,
"preselect": true,
"sortText": "7ffffff6",
"filterText": "impl",
"insertTextFormat": 2,
"textEdit": {
"newText": "impl $1 {\n $0\n}",
"insert": {
"start": { "line": 76, "character": 0 },
"end": { "line": 75, "character": 5 }
},
"replace": {
"start": { "line": 76, "character": 0 },
"end": { "line": 76, "character": 0 }
}
}
}
ResponseError: Received a completion with overlapping edits, this is not LSP-compliant
Better reproduction
- Insert a space before
pub struct NonNull - Cursor on
NonNull, use hover doc, response range is based on the original, not the edited document
Expect "NonNull", Actual " NonNul"
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 by reproducing the Better reproduction with the completion and hover requests, then trace rust-analyzer's LSP text-edit and range handling. Compare the response ranges with the edited document after inserting a space before pub struct NonNull. Done means completion and hover ranges use the edited document and no overlapping edits or shifted text are returned.
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
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100