Lint suggests matches macro if PartialEq trait is not implemented

This commit is contained in:
Nahua Kang 2022-08-23 19:46:04 +02:00
parent a6444a69e2
commit 5ee1c24f28
2 changed files with 47 additions and 24 deletions

View file

@ -23,6 +23,11 @@ struct Struct {
b: bool,
}
struct NoPartialEqStruct {
a: i32,
b: bool,
}
enum NotPartialEq {
A,
B,
@ -47,6 +52,7 @@ fn main() {
let e = Enum::UnitVariant;
let f = NotPartialEq::A;
let g = NotStructuralEq::A;
let h = NoPartialEqStruct { a: 2, b: false };
// true
@ -70,6 +76,7 @@ fn main() {
if let NotStructuralEq::A = g {}
if let Some(NotPartialEq::A) = Some(f) {}
if let Some(NotStructuralEq::A) = Some(g) {}
if let NoPartialEqStruct { a: 2, b: false } = h {}
macro_rules! m1 {
(x) => {