Skip to content

Commit

Permalink
get all tests passing pending some questions
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Loren committed Mar 30, 2021
1 parent c1ea108 commit 9edd59e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
2 changes: 2 additions & 0 deletions clippy_utils/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ pub const OPEN_OPTIONS: [&str; 3] = ["std", "fs", "OpenOptions"];
pub const OPS_MODULE: [&str; 2] = ["core", "ops"];
pub const OPTION: [&str; 3] = ["core", "option", "Option"];
pub const OPTION_NONE: [&str; 4] = ["core", "option", "Option", "None"];
pub const OPTION_IS_SOME: [&str; 4] = ["core", "option", "Option", "is_some"];
pub const OPTION_SOME: [&str; 4] = ["core", "option", "Option", "Some"];
pub const OPTION_UNWRAP: [&str; 4] = ["core", "option", "Option", "unwrap"];
pub const ORD: [&str; 3] = ["core", "cmp", "Ord"];
pub const OS_STRING_AS_OS_STR: [&str; 5] = ["std", "ffi", "os_str", "OsString", "as_os_str"];
pub const OS_STR_TO_OS_STRING: [&str; 5] = ["std", "ffi", "os_str", "OsStr", "to_os_string"];
Expand Down
12 changes: 2 additions & 10 deletions tests/ui/filter_methods.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
error: called `filter(..).map(..)` on an `Iterator`
--> $DIR/filter_methods.rs:6:21
|
LL | let _: Vec<_> = vec![5; 6].into_iter().filter(|&x| x == 0).map(|x| x * 2).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::filter-map` implied by `-D warnings`
= help: this is more succinctly expressed by calling `.filter_map(..)` instead

error: called `filter(..).flat_map(..)` on an `Iterator`
--> $DIR/filter_methods.rs:8:21
|
Expand All @@ -17,6 +8,7 @@ LL | | .filter(|&x| x == 0)
LL | | .flat_map(|x| x.checked_mul(2))
| |_______________________________________^
|
= note: `-D clippy::filter-map` implied by `-D warnings`
= help: this is more succinctly expressed by calling `.flat_map(..)` and filtering by returning `iter::empty()`

error: called `filter_map(..).flat_map(..)` on an `Iterator`
Expand All @@ -43,5 +35,5 @@ LL | | .map(|x| x.checked_mul(2))
|
= help: this is more succinctly expressed by only calling `.filter_map(..)` instead

error: aborting due to 4 previous errors
error: aborting due to 3 previous errors

1 change: 1 addition & 0 deletions tests/ui/option_filter_map.fixed
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![warn(clippy::option_filter_map)]
// run-rustfix
fn odds_out(x: i32) -> Option<i32> {
if x % 2 == 0 {
Expand Down
1 change: 1 addition & 0 deletions tests/ui/option_filter_map.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![warn(clippy::option_filter_map)]
// run-rustfix
fn odds_out(x: i32) -> Option<i32> {
if x % 2 == 0 {
Expand Down
16 changes: 8 additions & 8 deletions tests/ui/option_filter_map.stderr
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
error: `filter` for `Some` followed by `unwrap`
--> $DIR/option_filter_map.rs:11:13
--> $DIR/option_filter_map.rs:12:13
|
LL | let _ = Some(Some(1)).filter(Option::is_some).map(Option::unwrap);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `Some(Some(1)).flatten()`
|
= note: `-D clippy::option-filter-map` implied by `-D warnings`

error: `filter` for `Some` followed by `unwrap`
--> $DIR/option_filter_map.rs:12:13
--> $DIR/option_filter_map.rs:13:13
|
LL | let _ = Some(Some(1)).filter(|o| o.is_some()).map(|o| o.unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `Some(Some(1)).flatten()`

error: `filter` for `Some` followed by `unwrap`
--> $DIR/option_filter_map.rs:13:13
--> $DIR/option_filter_map.rs:14:13
|
LL | let _ = Some(1).map(odds_out).filter(Option::is_some).map(Option::unwrap);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `Some(1).map(odds_out).flatten()`

error: `filter` for `Some` followed by `unwrap`
--> $DIR/option_filter_map.rs:14:13
--> $DIR/option_filter_map.rs:15:13
|
LL | let _ = Some(1).map(odds_out).filter(|o| o.is_some()).map(|o| o.unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `Some(1).map(odds_out).flatten()`

error: `filter` for `Some` followed by `unwrap`
--> $DIR/option_filter_map.rs:16:13
--> $DIR/option_filter_map.rs:17:13
|
LL | let _ = vec![Some(1)].into_iter().filter(Option::is_some).map(Option::unwrap);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `vec![Some(1)].into_iter().flatten()`

error: `filter` for `Some` followed by `unwrap`
--> $DIR/option_filter_map.rs:17:13
--> $DIR/option_filter_map.rs:18:13
|
LL | let _ = vec![Some(1)].into_iter().filter(|o| o.is_some()).map(|o| o.unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `vec![Some(1)].into_iter().flatten()`

error: `filter` for `Some` followed by `unwrap`
--> $DIR/option_filter_map.rs:18:13
--> $DIR/option_filter_map.rs:19:13
|
LL | let _ = vec![1]
| _____________^
Expand All @@ -55,7 +55,7 @@ LL | .map(odds_out).flatten();
|

error: `filter` for `Some` followed by `unwrap`
--> $DIR/option_filter_map.rs:23:13
--> $DIR/option_filter_map.rs:24:13
|
LL | let _ = vec![1]
| _____________^
Expand Down

0 comments on commit 9edd59e

Please sign in to comment.