Move tests into separate file

This commit is contained in:
Michael Wright 2018-09-29 13:57:04 +02:00
parent 4b4d758ce0
commit db5c63b77a
4 changed files with 45 additions and 45 deletions

View file

@ -443,17 +443,3 @@ fn main() {
let opt = Some(0);
let _ = opt.unwrap();
}
/// Checks implementation of `UNNECESSARY_FILTER_MAP` lint
fn unnecessary_filter_map() {
let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None });
let _ = (0..4).filter_map(|x| { if x > 1 { return Some(x); }; None });
let _ = (0..4).filter_map(|x| match x {
0 | 1 => None,
_ => Some(x),
});
let _ = (0..4).filter_map(|x| Some(x + 1));
let _ = (0..4).filter_map(i32::checked_abs);
}

View file

@ -453,35 +453,5 @@ error: used unwrap() on an Option value. If you don't want to handle the None ca
|
= note: `-D clippy::option-unwrap-used` implied by `-D warnings`
error: this `.filter_map` can be written more simply using `.filter`
--> $DIR/methods.rs:449:13
|
449 | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::unnecessary-filter-map` implied by `-D warnings`
error: this `.filter_map` can be written more simply using `.filter`
--> $DIR/methods.rs:450:13
|
450 | let _ = (0..4).filter_map(|x| { if x > 1 { return Some(x); }; None });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this `.filter_map` can be written more simply using `.filter`
--> $DIR/methods.rs:451:13
|
451 | let _ = (0..4).filter_map(|x| match x {
| _____________^
452 | | 0 | 1 => None,
453 | | _ => Some(x),
454 | | });
| |______^
error: this `.filter_map` can be written more simply using `.map`
--> $DIR/methods.rs:456:13
|
456 | let _ = (0..4).filter_map(|x| Some(x + 1));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 60 previous errors
error: aborting due to 56 previous errors

View file

@ -0,0 +1,12 @@
fn main() {
let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None });
let _ = (0..4).filter_map(|x| { if x > 1 { return Some(x); }; None });
let _ = (0..4).filter_map(|x| match x {
0 | 1 => None,
_ => Some(x),
});
let _ = (0..4).filter_map(|x| Some(x + 1));
let _ = (0..4).filter_map(i32::checked_abs);
}

View file

@ -0,0 +1,32 @@
error: this `.filter_map` can be written more simply using `.filter`
--> $DIR/unnecessary_filter_map.rs:2:13
|
2 | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::unnecessary-filter-map` implied by `-D warnings`
error: this `.filter_map` can be written more simply using `.filter`
--> $DIR/unnecessary_filter_map.rs:3:13
|
3 | let _ = (0..4).filter_map(|x| { if x > 1 { return Some(x); }; None });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this `.filter_map` can be written more simply using `.filter`
--> $DIR/unnecessary_filter_map.rs:4:13
|
4 | let _ = (0..4).filter_map(|x| match x {
| _____________^
5 | | 0 | 1 => None,
6 | | _ => Some(x),
7 | | });
| |______^
error: this `.filter_map` can be written more simply using `.map`
--> $DIR/unnecessary_filter_map.rs:9:13
|
9 | let _ = (0..4).filter_map(|x| Some(x + 1));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors