Skip to content

Commit 3aa0d17

Browse files
allow lint in other tests
1 parent 4363610 commit 3aa0d17

29 files changed

+194
-172
lines changed

tests/ui/author/struct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[allow(clippy::unnecessary_operation, clippy::single_match)]
1+
#[allow(clippy::unnecessary_operation, clippy::single_match, clippy::single_field_patterns)]
22
fn main() {
33
struct Test {
44
field: u32,

tests/ui/collapsible_match2.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
clippy::needless_return,
44
clippy::no_effect,
55
clippy::single_match,
6-
clippy::needless_borrow
6+
clippy::needless_borrow,
7+
clippy::single_field_patterns
78
)]
89

910
fn lint_cases(opt_opt: Option<Option<u32>>, res_opt: Result<Option<u32>, String>) {

tests/ui/collapsible_match2.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: this `match` can be collapsed into the outer `match`
2-
--> $DIR/collapsible_match2.rs:13:34
2+
--> $DIR/collapsible_match2.rs:14:34
33
|
44
LL | Ok(val) if make() => match val {
55
| __________________________________^
@@ -10,15 +10,15 @@ LL | | },
1010
|
1111
= note: `-D clippy::collapsible-match` implied by `-D warnings`
1212
help: the outer pattern can be modified to include the inner pattern
13-
--> $DIR/collapsible_match2.rs:13:16
13+
--> $DIR/collapsible_match2.rs:14:16
1414
|
1515
LL | Ok(val) if make() => match val {
1616
| ^^^ replace this binding
1717
LL | Some(n) => foo(n),
1818
| ^^^^^^^ with this pattern
1919

2020
error: this `match` can be collapsed into the outer `match`
21-
--> $DIR/collapsible_match2.rs:20:24
21+
--> $DIR/collapsible_match2.rs:21:24
2222
|
2323
LL | Ok(val) => match val {
2424
| ________________________^
@@ -28,15 +28,15 @@ LL | | },
2828
| |_____________^
2929
|
3030
help: the outer pattern can be modified to include the inner pattern
31-
--> $DIR/collapsible_match2.rs:20:16
31+
--> $DIR/collapsible_match2.rs:21:16
3232
|
3333
LL | Ok(val) => match val {
3434
| ^^^ replace this binding
3535
LL | Some(n) => foo(n),
3636
| ^^^^^^^ with this pattern
3737

3838
error: this `match` can be collapsed into the outer `match`
39-
--> $DIR/collapsible_match2.rs:34:29
39+
--> $DIR/collapsible_match2.rs:35:29
4040
|
4141
LL | $pat => match $e {
4242
| _____________________________^
@@ -49,7 +49,7 @@ LL | mac!(res_opt => Ok(val), val => Some(n), foo(n));
4949
| ------------------------------------------------ in this macro invocation
5050
|
5151
help: the outer pattern can be modified to include the inner pattern
52-
--> $DIR/collapsible_match2.rs:46:28
52+
--> $DIR/collapsible_match2.rs:47:28
5353
|
5454
LL | mac!(res_opt => Ok(val), val => Some(n), foo(n));
5555
| ^^^ ^^^^^^^ with this pattern
@@ -58,7 +58,7 @@ LL | mac!(res_opt => Ok(val), val => Some(n), foo(n));
5858
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
5959

6060
error: this `match` can be collapsed into the outer `match`
61-
--> $DIR/collapsible_match2.rs:51:20
61+
--> $DIR/collapsible_match2.rs:52:20
6262
|
6363
LL | Some(s) => match *s {
6464
| ____________________^
@@ -68,15 +68,15 @@ LL | | },
6868
| |_________^
6969
|
7070
help: the outer pattern can be modified to include the inner pattern
71-
--> $DIR/collapsible_match2.rs:51:14
71+
--> $DIR/collapsible_match2.rs:52:14
7272
|
7373
LL | Some(s) => match *s {
7474
| ^ replace this binding
7575
LL | [n] => foo(n),
7676
| ^^^ with this pattern
7777

7878
error: this `match` can be collapsed into the outer `match`
79-
--> $DIR/collapsible_match2.rs:60:24
79+
--> $DIR/collapsible_match2.rs:61:24
8080
|
8181
LL | Some(ref s) => match &*s {
8282
| ________________________^
@@ -86,7 +86,7 @@ LL | | },
8686
| |_________^
8787
|
8888
help: the outer pattern can be modified to include the inner pattern
89-
--> $DIR/collapsible_match2.rs:60:14
89+
--> $DIR/collapsible_match2.rs:61:14
9090
|
9191
LL | Some(ref s) => match &*s {
9292
| ^^^^^ replace this binding

tests/ui/eta.fixed

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
clippy::no_effect,
66
clippy::redundant_closure_call,
77
clippy::needless_pass_by_value,
8-
clippy::option_map_unit_fn
8+
clippy::option_map_unit_fn,
9+
clippy::single_field_patterns
910
)]
1011
#![warn(
1112
clippy::redundant_closure,

tests/ui/eta.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
clippy::no_effect,
66
clippy::redundant_closure_call,
77
clippy::needless_pass_by_value,
8-
clippy::option_map_unit_fn
8+
clippy::option_map_unit_fn,
9+
clippy::single_field_patterns
910
)]
1011
#![warn(
1112
clippy::redundant_closure,

tests/ui/eta.stderr

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,131 @@
11
error: redundant closure
2-
--> $DIR/eta.rs:31:27
2+
--> $DIR/eta.rs:32:27
33
|
44
LL | let a = Some(1u8).map(|a| foo(a));
55
| ^^^^^^^^^^ help: replace the closure with the function itself: `foo`
66
|
77
= note: `-D clippy::redundant-closure` implied by `-D warnings`
88

99
error: redundant closure
10-
--> $DIR/eta.rs:35:40
10+
--> $DIR/eta.rs:36:40
1111
|
1212
LL | let _: Option<Vec<u8>> = true.then(|| vec![]); // special case vec!
1313
| ^^^^^^^^^ help: replace the closure with `Vec::new`: `std::vec::Vec::new`
1414

1515
error: redundant closure
16-
--> $DIR/eta.rs:36:35
16+
--> $DIR/eta.rs:37:35
1717
|
1818
LL | let d = Some(1u8).map(|a| foo((|b| foo2(b))(a))); //is adjusted?
1919
| ^^^^^^^^^^^^^ help: replace the closure with the function itself: `foo2`
2020

2121
error: this expression borrows a reference (`&u8`) that is immediately dereferenced by the compiler
22-
--> $DIR/eta.rs:37:21
22+
--> $DIR/eta.rs:38:21
2323
|
2424
LL | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted
2525
| ^^^ help: change this to: `&2`
2626
|
2727
= note: `-D clippy::needless-borrow` implied by `-D warnings`
2828

2929
error: redundant closure
30-
--> $DIR/eta.rs:37:26
30+
--> $DIR/eta.rs:38:26
3131
|
3232
LL | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted
3333
| ^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `below`
3434

3535
error: redundant closure
36-
--> $DIR/eta.rs:43:27
36+
--> $DIR/eta.rs:44:27
3737
|
3838
LL | let e = Some(1u8).map(|a| divergent(a));
3939
| ^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `divergent`
4040

4141
error: redundant closure
42-
--> $DIR/eta.rs:44:27
42+
--> $DIR/eta.rs:45:27
4343
|
4444
LL | let e = Some(1u8).map(|a| generic(a));
4545
| ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `generic`
4646

4747
error: redundant closure
48-
--> $DIR/eta.rs:90:51
48+
--> $DIR/eta.rs:91:51
4949
|
5050
LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo());
5151
| ^^^^^^^^^^^ help: replace the closure with the method itself: `TestStruct::foo`
5252
|
5353
= note: `-D clippy::redundant-closure-for-method-calls` implied by `-D warnings`
5454

5555
error: redundant closure
56-
--> $DIR/eta.rs:91:51
56+
--> $DIR/eta.rs:92:51
5757
|
5858
LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.trait_foo());
5959
| ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `TestTrait::trait_foo`
6060

6161
error: redundant closure
62-
--> $DIR/eta.rs:93:42
62+
--> $DIR/eta.rs:94:42
6363
|
6464
LL | let e = Some(&mut vec![1, 2, 3]).map(|v| v.clear());
6565
| ^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::vec::Vec::clear`
6666

6767
error: redundant closure
68-
--> $DIR/eta.rs:97:29
68+
--> $DIR/eta.rs:98:29
6969
|
7070
LL | let e = Some("str").map(|s| s.to_string());
7171
| ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::string::ToString::to_string`
7272

7373
error: redundant closure
74-
--> $DIR/eta.rs:98:27
74+
--> $DIR/eta.rs:99:27
7575
|
7676
LL | let e = Some('a').map(|s| s.to_uppercase());
7777
| ^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `char::to_uppercase`
7878

7979
error: redundant closure
80-
--> $DIR/eta.rs:100:65
80+
--> $DIR/eta.rs:101:65
8181
|
8282
LL | let e: std::vec::Vec<char> = vec!['a', 'b', 'c'].iter().map(|c| c.to_ascii_uppercase()).collect();
8383
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `char::to_ascii_uppercase`
8484

8585
error: redundant closure
86-
--> $DIR/eta.rs:163:22
86+
--> $DIR/eta.rs:164:22
8787
|
8888
LL | requires_fn_once(|| x());
8989
| ^^^^^^ help: replace the closure with the function itself: `x`
9090

9191
error: redundant closure
92-
--> $DIR/eta.rs:170:27
92+
--> $DIR/eta.rs:171:27
9393
|
9494
LL | let a = Some(1u8).map(|a| foo_ptr(a));
9595
| ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `foo_ptr`
9696

9797
error: redundant closure
98-
--> $DIR/eta.rs:175:27
98+
--> $DIR/eta.rs:176:27
9999
|
100100
LL | let a = Some(1u8).map(|a| closure(a));
101101
| ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `closure`
102102

103103
error: redundant closure
104-
--> $DIR/eta.rs:207:28
104+
--> $DIR/eta.rs:208:28
105105
|
106106
LL | x.into_iter().for_each(|x| add_to_res(x));
107107
| ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut add_to_res`
108108

109109
error: redundant closure
110-
--> $DIR/eta.rs:208:28
110+
--> $DIR/eta.rs:209:28
111111
|
112112
LL | y.into_iter().for_each(|x| add_to_res(x));
113113
| ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut add_to_res`
114114

115115
error: redundant closure
116-
--> $DIR/eta.rs:209:28
116+
--> $DIR/eta.rs:210:28
117117
|
118118
LL | z.into_iter().for_each(|x| add_to_res(x));
119119
| ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `add_to_res`
120120

121121
error: redundant closure
122-
--> $DIR/eta.rs:216:21
122+
--> $DIR/eta.rs:217:21
123123
|
124124
LL | Some(1).map(|n| closure(n));
125125
| ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut closure`
126126

127127
error: redundant closure
128-
--> $DIR/eta.rs:235:21
128+
--> $DIR/eta.rs:236:21
129129
|
130130
LL | map_str_to_path(|s| s.as_ref());
131131
| ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::convert::AsRef::as_ref`

tests/ui/infallible_destructuring_match.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// run-rustfix
22
#![feature(exhaustive_patterns, never_type)]
33
#![allow(dead_code, unreachable_code, unused_variables)]
4-
#![allow(clippy::let_and_return)]
4+
#![allow(clippy::let_and_return, clippy::single_field_patterns)]
55

66
enum SingleVariantEnum {
77
Variant(i32),

tests/ui/infallible_destructuring_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// run-rustfix
22
#![feature(exhaustive_patterns, never_type)]
33
#![allow(dead_code, unreachable_code, unused_variables)]
4-
#![allow(clippy::let_and_return)]
4+
#![allow(clippy::let_and_return, clippy::single_field_patterns)]
55

66
enum SingleVariantEnum {
77
Variant(i32),

tests/ui/needless_borrow_pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// FIXME: run-rustfix waiting on multi-span suggestions
22

33
#![warn(clippy::needless_borrow)]
4-
#![allow(clippy::needless_borrowed_reference)]
4+
#![allow(clippy::needless_borrowed_reference, clippy::single_field_patterns)]
55

66
fn f1(_: &str) {}
77
macro_rules! m1 {

tests/ui/needless_pass_by_value.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
clippy::single_match,
55
clippy::redundant_pattern_matching,
66
clippy::option_option,
7-
clippy::redundant_clone
7+
clippy::redundant_clone,
8+
clippy::single_field_patterns
89
)]
910

1011
use std::borrow::Borrow;

0 commit comments

Comments
 (0)