File tree Expand file tree Collapse file tree 4 files changed +45
-45
lines changed Expand file tree Collapse file tree 4 files changed +45
-45
lines changed Original file line number Diff line number Diff line change @@ -443,17 +443,3 @@ fn main() {
443
443
let opt = Some ( 0 ) ;
444
444
let _ = opt. unwrap ( ) ;
445
445
}
446
-
447
- /// Checks implementation of `UNNECESSARY_FILTER_MAP` lint
448
- fn unnecessary_filter_map ( ) {
449
- let _ = ( 0 ..4 ) . filter_map ( |x| if x > 1 { Some ( x) } else { None } ) ;
450
- let _ = ( 0 ..4 ) . filter_map ( |x| { if x > 1 { return Some ( x) ; } ; None } ) ;
451
- let _ = ( 0 ..4 ) . filter_map ( |x| match x {
452
- 0 | 1 => None ,
453
- _ => Some ( x) ,
454
- } ) ;
455
-
456
- let _ = ( 0 ..4 ) . filter_map ( |x| Some ( x + 1 ) ) ;
457
-
458
- let _ = ( 0 ..4 ) . filter_map ( i32:: checked_abs) ;
459
- }
Original file line number Diff line number Diff line change @@ -453,35 +453,5 @@ error: used unwrap() on an Option value. If you don't want to handle the None ca
453
453
|
454
454
= note: `-D clippy::option-unwrap-used` implied by `-D warnings`
455
455
456
- error: this `.filter_map` can be written more simply using `.filter`
457
- --> $DIR/methods.rs:449:13
458
- |
459
- 449 | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None });
460
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
461
- |
462
- = note: `-D clippy::unnecessary-filter-map` implied by `-D warnings`
463
-
464
- error: this `.filter_map` can be written more simply using `.filter`
465
- --> $DIR/methods.rs:450:13
466
- |
467
- 450 | let _ = (0..4).filter_map(|x| { if x > 1 { return Some(x); }; None });
468
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
469
-
470
- error: this `.filter_map` can be written more simply using `.filter`
471
- --> $DIR/methods.rs:451:13
472
- |
473
- 451 | let _ = (0..4).filter_map(|x| match x {
474
- | _____________^
475
- 452 | | 0 | 1 => None,
476
- 453 | | _ => Some(x),
477
- 454 | | });
478
- | |______^
479
-
480
- error: this `.filter_map` can be written more simply using `.map`
481
- --> $DIR/methods.rs:456:13
482
- |
483
- 456 | let _ = (0..4).filter_map(|x| Some(x + 1));
484
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
485
-
486
- error: aborting due to 60 previous errors
456
+ error: aborting due to 56 previous errors
487
457
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ let _ = ( 0 ..4 ) . filter_map ( |x| if x > 1 { Some ( x) } else { None } ) ;
3
+ let _ = ( 0 ..4 ) . filter_map ( |x| { if x > 1 { return Some ( x) ; } ; None } ) ;
4
+ let _ = ( 0 ..4 ) . filter_map ( |x| match x {
5
+ 0 | 1 => None ,
6
+ _ => Some ( x) ,
7
+ } ) ;
8
+
9
+ let _ = ( 0 ..4 ) . filter_map ( |x| Some ( x + 1 ) ) ;
10
+
11
+ let _ = ( 0 ..4 ) . filter_map ( i32:: checked_abs) ;
12
+ }
Original file line number Diff line number Diff line change
1
+ error: this `.filter_map` can be written more simply using `.filter`
2
+ --> $DIR/unnecessary_filter_map.rs:2:13
3
+ |
4
+ 2 | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None });
5
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6
+ |
7
+ = note: `-D clippy::unnecessary-filter-map` implied by `-D warnings`
8
+
9
+ error: this `.filter_map` can be written more simply using `.filter`
10
+ --> $DIR/unnecessary_filter_map.rs:3:13
11
+ |
12
+ 3 | let _ = (0..4).filter_map(|x| { if x > 1 { return Some(x); }; None });
13
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14
+
15
+ error: this `.filter_map` can be written more simply using `.filter`
16
+ --> $DIR/unnecessary_filter_map.rs:4:13
17
+ |
18
+ 4 | let _ = (0..4).filter_map(|x| match x {
19
+ | _____________^
20
+ 5 | | 0 | 1 => None,
21
+ 6 | | _ => Some(x),
22
+ 7 | | });
23
+ | |______^
24
+
25
+ error: this `.filter_map` can be written more simply using `.map`
26
+ --> $DIR/unnecessary_filter_map.rs:9:13
27
+ |
28
+ 9 | let _ = (0..4).filter_map(|x| Some(x + 1));
29
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30
+
31
+ error: aborting due to 4 previous errors
32
+
You can’t perform that action at this time.
0 commit comments