Closed
Description
I think I discovered a pretty severe bug related to const-generics as they are available on stable.
rust-analyzer version: 1.65.0-nightly (7480389 2022-08-25)
rustc version: 1.63.0 (4b91a6ea7 2022-08-08)
relevant settings: n/a
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
struct MyStruct<const X: usize>(u32);
impl<const X: usize> PartialEq<u16> for MyStruct<X> {
fn eq(&self, v: &u16) -> bool {
self.0 == *v as u32
}
}
fn compare<const X: usize>(a: MyStruct<X>, b: MyStruct<X>) {
let eq = a == b; // expected u16, found MyStruct<X> rust-analyzer[type-mismatch](https://rust-analyzer.github.io/manual.html#type-mismatch)
}
The error goes away if
- the const-generic
X
is removed or - the
PartialEq<u16>
impl is removed