[−][src]Static rustc_ap_rustc_session::lint::builtin::INDIRECT_STRUCTURAL_MATCH
pub static INDIRECT_STRUCTURAL_MATCH: &Lint
The indirect_structural_match
lint detects a const
in a pattern
that manually implements PartialEq
and Eq
.
Example
ⓘThis example deliberately fails to compile
#![deny(indirect_structural_match)] struct Plus(i32, i32); const ONE_PLUS_TWO: &&Plus = &&Plus(1, 2); impl PartialEq for Plus { fn eq(&self, other: &Self) -> bool { self.0 + self.1 == other.0 + other.1 } } impl Eq for Plus {} fn main() { if let ONE_PLUS_TWO = &&Plus(3, 0) { println!("semantic!"); } else { println!("structural!"); } }
{{produces}}
Explanation
The compiler unintentionally accepted this form in the past. This is a future-incompatible lint to transition this to a hard error in the future. See issue #62411 for a complete description of the problem, and some possible solutions.