rust-lang / rust-lang/rust-analyzer
Generate method assist misses generics when generating an impl block
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Input:
struct Generic<T: Send>(T);
fn foo() {
Generic("test").do_a_thing()
}
Current output:
struct Generic<T: Send>(T);
impl Generic {
fn do_a_thing(&self) {
todo!()
}
}
fn foo() {
Generic("test").do_a_thing()
}
Expected output:
struct Generic<T: Send>(T);
impl<T: Send> Generic<T> {
fn do_a_thing(&self) {
todo!()
}
}
fn foo() {
Generic("test").do_a_thing()
}
I suppose impl Generic<&'static str> would also be an option, but less likely to be what the user intended.
rust-analyzer version: 0.4.2462-standalone
rustc version: 1.89.0-nightly (414482f6a 2025-05-13)
editor or extension: VSCode (ext version 0.4.2462)
@rustbot label +A-assists
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 method-assist case from the issue with the generic Generic<T: Send> and compare the generated impl block with the expected output. Trace the generate-method assist and its impl-block generation to find where generic parameters are lost; done means the assist preserves the bounds and type parameters shown in the expected output.
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
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100