Skip to content

Commit 9edd59e

Browse files
author
Eric Loren
committed
get all tests passing pending some questions
1 parent c1ea108 commit 9edd59e

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

clippy_utils/src/paths.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ pub const OPEN_OPTIONS: [&str; 3] = ["std", "fs", "OpenOptions"];
8181
pub const OPS_MODULE: [&str; 2] = ["core", "ops"];
8282
pub const OPTION: [&str; 3] = ["core", "option", "Option"];
8383
pub const OPTION_NONE: [&str; 4] = ["core", "option", "Option", "None"];
84+
pub const OPTION_IS_SOME: [&str; 4] = ["core", "option", "Option", "is_some"];
8485
pub const OPTION_SOME: [&str; 4] = ["core", "option", "Option", "Some"];
86+
pub const OPTION_UNWRAP: [&str; 4] = ["core", "option", "Option", "unwrap"];
8587
pub const ORD: [&str; 3] = ["core", "cmp", "Ord"];
8688
pub const OS_STRING_AS_OS_STR: [&str; 5] = ["std", "ffi", "os_str", "OsString", "as_os_str"];
8789
pub const OS_STR_TO_OS_STRING: [&str; 5] = ["std", "ffi", "os_str", "OsStr", "to_os_string"];

tests/ui/filter_methods.stderr

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
error: called `filter(..).map(..)` on an `Iterator`
2-
--> $DIR/filter_methods.rs:6:21
3-
|
4-
LL | let _: Vec<_> = vec![5; 6].into_iter().filter(|&x| x == 0).map(|x| x * 2).collect();
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6-
|
7-
= note: `-D clippy::filter-map` implied by `-D warnings`
8-
= help: this is more succinctly expressed by calling `.filter_map(..)` instead
9-
101
error: called `filter(..).flat_map(..)` on an `Iterator`
112
--> $DIR/filter_methods.rs:8:21
123
|
@@ -17,6 +8,7 @@ LL | | .filter(|&x| x == 0)
178
LL | | .flat_map(|x| x.checked_mul(2))
189
| |_______________________________________^
1910
|
11+
= note: `-D clippy::filter-map` implied by `-D warnings`
2012
= help: this is more succinctly expressed by calling `.flat_map(..)` and filtering by returning `iter::empty()`
2113

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

46-
error: aborting due to 4 previous errors
38+
error: aborting due to 3 previous errors
4739

tests/ui/option_filter_map.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![warn(clippy::option_filter_map)]
12
// run-rustfix
23
fn odds_out(x: i32) -> Option<i32> {
34
if x % 2 == 0 {

tests/ui/option_filter_map.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![warn(clippy::option_filter_map)]
12
// run-rustfix
23
fn odds_out(x: i32) -> Option<i32> {
34
if x % 2 == 0 {

tests/ui/option_filter_map.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
error: `filter` for `Some` followed by `unwrap`
2-
--> $DIR/option_filter_map.rs:11:13
2+
--> $DIR/option_filter_map.rs:12:13
33
|
44
LL | let _ = Some(Some(1)).filter(Option::is_some).map(Option::unwrap);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `Some(Some(1)).flatten()`
66
|
77
= note: `-D clippy::option-filter-map` implied by `-D warnings`
88

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)