Closed
Description
calling mem::discriminant
on a &&T
will not deref the value to get the discriminant of the value, but just give you the same discriminant irrelevant of what you point to.
The following program demonstrates this:
enum Foo {
A,
B,
}
fn main() {
println!("{:?}", std::mem::discriminant(&Foo::A)); // 0
println!("{:?}", std::mem::discriminant(&&Foo::A)); // 0
println!("{:?}", std::mem::discriminant(&Foo::B)); // 1
println!("{:?}", std::mem::discriminant(&&Foo::B)); // 0
}
It makes little sense to call mem::discriminant
on double references, similarly to cloning double references.
We should lint about this. (Also I screwed this up in the compiler: https://github.com/rust-lang/rust/blob/ca2639e82ec4a18d7359efbfb555ea69dd644c97/src/librustc/ich/impls_ty.rs#L515 and I think it's causing ICEs in a PR I'm doing)