rust-lang / rust-lang/rust-analyzer
feature request: text edits for bind_pat inlay hints.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Inlay hints can have text edits which can be provided to "apply" the inlay hint when double clicked on. I noticed this recently in the python language server's inlay hints, that I could do:

We could provide text edits which would auto-import any type that is referred to, and insert the type annotation, where syntactically valid.
For example:
fn foo() {
let eligible = "hello".starts_with(|c| c.is_uppercase());
// ^ `: bool ` ^ `: char`
match Some(eligible) {
Some(n) => { }
// ^ not eligible, because inserting `: bool` here would not be valid syntax.
None => { }
}
}
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 tracing bind_pat inlay-hint generation and the existing support for applying LSP text edits. Implement edits for eligible bindings that add type annotations and imports where syntactically valid; verify that cases such as the match binding example do not offer invalid edits.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100