pub static INDIRECT_STRUCTURAL_MATCH: &Lint
Expand description
The indirect_structural_match
lint detects a const
in a pattern
that manually implements PartialEq
and Eq
.
§Example
ⓘ
#![deny(indirect_structural_match)]
struct NoDerive(i32);
impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
impl Eq for NoDerive { }
#[derive(PartialEq, Eq)]
struct WrapParam<T>(T);
const WRAP_INDIRECT_PARAM: & &WrapParam<NoDerive> = & &WrapParam(NoDerive(0));
fn main() {
match WRAP_INDIRECT_PARAM {
WRAP_INDIRECT_PARAM => { }
_ => { }
}
}
{{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.