Skip to content

Commit

Permalink
add additional testcase with PartialEq present
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacherr committed Nov 3, 2024
1 parent 8097bb2 commit 5e9ca40
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/ui/unnecessary_map_or.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ fn main() {
struct S;
let r: Result<i32, S> = Ok(3);
let _ = r.is_ok_and(|x| x == 7);

#[derive(PartialEq)]
struct S2;
let r: Result<i32, S2> = Ok(4);
let _ = (r == Ok(8));
}

#[clippy::msrv = "1.69.0"]
Expand Down
5 changes: 5 additions & 0 deletions tests/ui/unnecessary_map_or.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ fn main() {
struct S;
let r: Result<i32, S> = Ok(3);
let _ = r.map_or(false, |x| x == 7);

#[derive(PartialEq)]
struct S2;
let r: Result<i32, S2> = Ok(4);
let _ = r.map_or(false, |x| x == 8);
}

#[clippy::msrv = "1.69.0"]
Expand Down
8 changes: 7 additions & 1 deletion tests/ui/unnecessary_map_or.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5e9ca40

Please sign in to comment.