rust-lang / rust-lang/rust-analyzer
Duplicated functions on the list
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: v0.3.1258
rustc version: rustc 1.64.0 (a55dd71d5 2022-09-19)
Functions on the list are duplicated when implemented by macro.
pub struct Vec2<T> {
pub x: T,
pub y: T,
}
macro_rules! implement {
($type:ident) => {
impl Vec2<$type> {
pub fn length(&self) -> f64 {
((self.x as f64).powf(2.0) + (self.y as f64).powf(2.0)).sqrt()
}
}
}
}
implement!(u8);
implement!(i8);
implement!(u16);
implement!(i16);
implement!(i32);
implement!(u32);
pub fn main() {
// Vec2::
// Vec2::<i32>::
}
The first case is when we don't specify the generic type in ``Vec2` explicitly:

The second case when using Vec2::<i32>:

While I can somehow understand why it's displaying duplicates in the first case (still don't like it tho), it rather shouldn't do it in the second one.
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 duplicated completion results with the Rust macro example in the issue, checking both Vec2:: and Vec2::<i32>::. Trace the completion results for macro-generated functions and consider the work complete when the generic form lists length only once while the reproduction remains covered by an appropriate test.
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
- Clearly specified
- Newbie friendliness
- 35/100