Skip to content

Commit 5e9ca40

Browse files
committed
add additional testcase with PartialEq present
1 parent 8097bb2 commit 5e9ca40

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

tests/ui/unnecessary_map_or.fixed

+5
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ fn main() {
5050
struct S;
5151
let r: Result<i32, S> = Ok(3);
5252
let _ = r.is_ok_and(|x| x == 7);
53+
54+
#[derive(PartialEq)]
55+
struct S2;
56+
let r: Result<i32, S2> = Ok(4);
57+
let _ = (r == Ok(8));
5358
}
5459

5560
#[clippy::msrv = "1.69.0"]

tests/ui/unnecessary_map_or.rs

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ fn main() {
5353
struct S;
5454
let r: Result<i32, S> = Ok(3);
5555
let _ = r.map_or(false, |x| x == 7);
56+
57+
#[derive(PartialEq)]
58+
struct S2;
59+
let r: Result<i32, S2> = Ok(4);
60+
let _ = r.map_or(false, |x| x == 8);
5661
}
5762

5863
#[clippy::msrv = "1.69.0"]

tests/ui/unnecessary_map_or.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,11 @@ error: this `map_or` is redundant
8989
LL | let _ = r.map_or(false, |x| x == 7);
9090
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use is_ok_and instead: `r.is_ok_and(|x| x == 7)`
9191

92-
error: aborting due to 12 previous errors
92+
error: this `map_or` is redundant
93+
--> tests/ui/unnecessary_map_or.rs:60:13
94+
|
95+
LL | let _ = r.map_or(false, |x| x == 8);
96+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a standard comparison instead: `(r == Ok(8))`
97+
98+
error: aborting due to 13 previous errors
9399

0 commit comments

Comments
 (0)