File tree 3 files changed +53
-0
lines changed
3 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![warn(clippy::manual_is_variant_and)]
2
+
3
+ fn main() {
4
+ let _ = Some(2).is_some_and(|x| x % 2 == 0);
5
+ //~^ manual_is_variant_and
6
+ let _ = Some(2).is_none_or(|x| x % 2 == 0);
7
+ //~^ manual_is_variant_and
8
+ let _ = Ok::<usize, ()>(2).is_ok_and(|x| x % 2 == 0);
9
+ //~^ manual_is_variant_and
10
+ let _ = !Ok::<usize, ()>(2).is_ok_and(|x| x % 2 == 0);
11
+ //~^ manual_is_variant_and
12
+ }
Original file line number Diff line number Diff line change
1
+ #![ warn( clippy:: manual_is_variant_and) ]
2
+
3
+ fn main ( ) {
4
+ let _ = Some ( 2 ) . map ( |x| x % 2 == 0 ) == Some ( true ) ;
5
+ //~^ manual_is_variant_and
6
+ let _ = Some ( 2 ) . map ( |x| x % 2 == 0 ) != Some ( true ) ;
7
+ //~^ manual_is_variant_and
8
+ let _ = Ok :: < usize , ( ) > ( 2 ) . map ( |x| x % 2 == 0 ) == Ok ( true ) ;
9
+ //~^ manual_is_variant_and
10
+ let _ = Ok :: < usize , ( ) > ( 2 ) . map ( |x| x % 2 == 0 ) != Ok ( true ) ;
11
+ //~^ manual_is_variant_and
12
+ }
Original file line number Diff line number Diff line change
1
+ error: called `.map() == Some()`
2
+ --> tests/ui/manual_is_variant_and2.rs:4:13
3
+ |
4
+ LL | let _ = Some(2).map(|x| x % 2 == 0) == Some(true);
5
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `Some(2).is_some_and(|x| x % 2 == 0)`
6
+ |
7
+ = note: `-D clippy::manual-is-variant-and` implied by `-D warnings`
8
+ = help: to override `-D warnings` add `#[allow(clippy::manual_is_variant_and)]`
9
+
10
+ error: called `.map() != Some()`
11
+ --> tests/ui/manual_is_variant_and2.rs:6:13
12
+ |
13
+ LL | let _ = Some(2).map(|x| x % 2 == 0) != Some(true);
14
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `Some(2).is_none_or(|x| x % 2 == 0)`
15
+
16
+ error: called `.map() == Ok()`
17
+ --> tests/ui/manual_is_variant_and2.rs:8:13
18
+ |
19
+ LL | let _ = Ok::<usize, ()>(2).map(|x| x % 2 == 0) == Ok(true);
20
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `Ok::<usize, ()>(2).is_ok_and(|x| x % 2 == 0)`
21
+
22
+ error: called `.map() != Ok()`
23
+ --> tests/ui/manual_is_variant_and2.rs:10:13
24
+ |
25
+ LL | let _ = Ok::<usize, ()>(2).map(|x| x % 2 == 0) != Ok(true);
26
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `!Ok::<usize, ()>(2).is_ok_and(|x| x % 2 == 0)`
27
+
28
+ error: aborting due to 4 previous errors
29
+
You can’t perform that action at this time.
0 commit comments