-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-lintArea: New lintsArea: New lintsE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.L-correctnessLint: Belongs in the correctness lint groupLint: Belongs in the correctness lint group
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)
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lintsE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.L-correctnessLint: Belongs in the correctness lint groupLint: Belongs in the correctness lint group