From 5e9ca40ee4772eb384d61d2e95d8b8b32af3d085 Mon Sep 17 00:00:00 2001 From: Jacherr Date: Thu, 17 Oct 2024 23:45:15 +0100 Subject: [PATCH] add additional testcase with `PartialEq` present --- tests/ui/unnecessary_map_or.fixed | 5 +++++ tests/ui/unnecessary_map_or.rs | 5 +++++ tests/ui/unnecessary_map_or.stderr | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/ui/unnecessary_map_or.fixed b/tests/ui/unnecessary_map_or.fixed index 860a6cec0ca1..2d932a70e9d9 100644 --- a/tests/ui/unnecessary_map_or.fixed +++ b/tests/ui/unnecessary_map_or.fixed @@ -50,6 +50,11 @@ fn main() { struct S; let r: Result = Ok(3); let _ = r.is_ok_and(|x| x == 7); + + #[derive(PartialEq)] + struct S2; + let r: Result = Ok(4); + let _ = (r == Ok(8)); } #[clippy::msrv = "1.69.0"] diff --git a/tests/ui/unnecessary_map_or.rs b/tests/ui/unnecessary_map_or.rs index 059f9aee9c4f..4a9d69be1e9d 100644 --- a/tests/ui/unnecessary_map_or.rs +++ b/tests/ui/unnecessary_map_or.rs @@ -53,6 +53,11 @@ fn main() { struct S; let r: Result = Ok(3); let _ = r.map_or(false, |x| x == 7); + + #[derive(PartialEq)] + struct S2; + let r: Result = Ok(4); + let _ = r.map_or(false, |x| x == 8); } #[clippy::msrv = "1.69.0"] diff --git a/tests/ui/unnecessary_map_or.stderr b/tests/ui/unnecessary_map_or.stderr index 2925a6ec1a4b..299a4e5da7aa 100644 --- a/tests/ui/unnecessary_map_or.stderr +++ b/tests/ui/unnecessary_map_or.stderr @@ -89,5 +89,11 @@ error: this `map_or` is redundant LL | let _ = r.map_or(false, |x| x == 7); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use is_ok_and instead: `r.is_ok_and(|x| x == 7)` -error: aborting due to 12 previous errors +error: this `map_or` is redundant + --> tests/ui/unnecessary_map_or.rs:60:13 + | +LL | let _ = r.map_or(false, |x| x == 8); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a standard comparison instead: `(r == Ok(8))` + +error: aborting due to 13 previous errors