Auto merge of #7093 - Jarcho:single_match_fp, r=llogiq

Fix `single_match`

fixes: #7038
changelog: Don't suggest an equality check for types which don't implement `PartialEq` in `single_match`
This commit is contained in:
bors 2021-04-16 06:44:26 +00:00
commit ddc2598230
3 changed files with 23 additions and 3 deletions

View file

@ -135,6 +135,14 @@ fn if_suggestion() {
Bar::A => println!(),
_ => (),
}
// issue #7038
struct X;
let x = Some(X);
match x {
None => println!(),
_ => (),
};
}
macro_rules! single_match {

View file

@ -119,5 +119,14 @@ LL | | _ => (),
LL | | }
| |_____^ help: try this: `if let Bar::A = x { println!() }`
error: aborting due to 12 previous errors
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> $DIR/single_match.rs:142:5
|
LL | / match x {
LL | | None => println!(),
LL | | _ => (),
LL | | };
| |_____^ help: try this: `if let None = x { println!() }`
error: aborting due to 13 previous errors