Skip to content

Commit db5c63b

Browse files
author
Michael Wright
committed
Move tests into separate file
1 parent 4b4d758 commit db5c63b

File tree

4 files changed

+45
-45
lines changed

4 files changed

+45
-45
lines changed

tests/ui/methods.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -443,17 +443,3 @@ fn main() {
443443
let opt = Some(0);
444444
let _ = opt.unwrap();
445445
}
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-
}

tests/ui/methods.stderr

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -453,35 +453,5 @@ error: used unwrap() on an Option value. If you don't want to handle the None ca
453453
|
454454
= note: `-D clippy::option-unwrap-used` implied by `-D warnings`
455455

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
487457

tests/ui/unnecessary_filter_map.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+

0 commit comments

Comments
 (0)