rust-lang / rust-lang/rust-analyzer
Off-by-one error when performing autocomplete on an expression inside a proc macro
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
In recent versions of Rust Analyzer, inlay hints and completions seem to be broken for expressions passed to proc macros which emit the input expression as-is. See #16004 for hints, but completions also seem to be having trouble with the wrong expression being used to compute completions. For example, consider the following case:
Rust Analyzer correctly infers the type of v to be a Result<BytesMut, ...>, but the completions are for the BytesMut rather than the Result. This used to behave fine in previous versions of Rust Analyzer, so something seems to have changed.
rust-analyzer version: 0.3.1766-standalone
rustc version: rustc 1.76.0-nightly (3340d49d2 2023-12-12)
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 autocomplete for an expression passed to a proc macro that emits its input unchanged, using the reported Rust Analyzer and rustc versions as context. Trace which expression is used to compute completions and compare it with the inferred Result type; done when completions target the Result rather than the inner BytesMut.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100