rust-lang / rust-lang/rust-analyzer
'inline function' assist does not take generic type parameters into account
Open
Nobody has claimed this yet.
C-bug
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
rust-analyzer version: rust-analyzer version: 0.4.1808-standalone (a616c4d11 2024-01-15)
rustc version: rustc 1.75.0 (82e1608df 2023-12-21)
relevant settings: none
This issue is similar to https://github.com/rust-lang/rust-analyzer/issues/16090 but it seems more likely to happen on most generic types.
use std::ops::Add;
struct Foo<T: Add + Default>(T);
impl<T: Add + Default> Foo<T> {
fn clear(&mut self) {
self.0 = T::default();
}
}
fn main() {
let foo: &mut Foo<i32> = &mut Foo(3);
// foo.clear(); inline `clear` yeild:
{
let ref mut this = foo;
this.0 = T::default();
// ^------------ expect: i32
};
foo.0 += 1;
}
### Tasks
- [ ] https://github.com/rust-lang/rust-analyzer/issues/16090
- [ ] https://github.com/rust-lang/rust-analyzer/issues/15471
- [ ] https://github.com/rust-lang/rust-analyzer/issues/15470
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 inline clear assist behavior with the Rust example in the issue, focusing on the generic T used in T::default(). Compare the generated code with the expected i32 type; done means the assist accounts for the impl's generic type parameters.
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
- Mostly clear
- Newbie friendliness
- 35/100