Skip to content

Commit 50ba459

Browse files
committed
add- and fix existing tests
1 parent b309875 commit 50ba459

15 files changed

+82
-62
lines changed

tests/ui/cloned_instead_of_copied.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#![warn(clippy::cloned_instead_of_copied)]
44
#![allow(unused)]
5+
#![allow(clippy::useless_vec)]
56

67
fn main() {
78
// yay

tests/ui/cloned_instead_of_copied.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#![warn(clippy::cloned_instead_of_copied)]
44
#![allow(unused)]
5+
#![allow(clippy::useless_vec)]
56

67
fn main() {
78
// yay

tests/ui/cloned_instead_of_copied.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
11
error: used `cloned` where `copied` could be used instead
2-
--> $DIR/cloned_instead_of_copied.rs:8:24
2+
--> $DIR/cloned_instead_of_copied.rs:9:24
33
|
44
LL | let _ = [1].iter().cloned();
55
| ^^^^^^ help: try: `copied`
66
|
77
= note: `-D clippy::cloned-instead-of-copied` implied by `-D warnings`
88

99
error: used `cloned` where `copied` could be used instead
10-
--> $DIR/cloned_instead_of_copied.rs:9:31
10+
--> $DIR/cloned_instead_of_copied.rs:10:31
1111
|
1212
LL | let _ = vec!["hi"].iter().cloned();
1313
| ^^^^^^ help: try: `copied`
1414

1515
error: used `cloned` where `copied` could be used instead
16-
--> $DIR/cloned_instead_of_copied.rs:10:22
16+
--> $DIR/cloned_instead_of_copied.rs:11:22
1717
|
1818
LL | let _ = Some(&1).cloned();
1919
| ^^^^^^ help: try: `copied`
2020

2121
error: used `cloned` where `copied` could be used instead
22-
--> $DIR/cloned_instead_of_copied.rs:11:34
22+
--> $DIR/cloned_instead_of_copied.rs:12:34
2323
|
2424
LL | let _ = Box::new([1].iter()).cloned();
2525
| ^^^^^^ help: try: `copied`
2626

2727
error: used `cloned` where `copied` could be used instead
28-
--> $DIR/cloned_instead_of_copied.rs:12:32
28+
--> $DIR/cloned_instead_of_copied.rs:13:32
2929
|
3030
LL | let _ = Box::new(Some(&1)).cloned();
3131
| ^^^^^^ help: try: `copied`
3232

3333
error: used `cloned` where `copied` could be used instead
34-
--> $DIR/cloned_instead_of_copied.rs:28:22
34+
--> $DIR/cloned_instead_of_copied.rs:29:22
3535
|
3636
LL | let _ = Some(&1).cloned(); // Option::copied needs 1.35
3737
| ^^^^^^ help: try: `copied`
3838

3939
error: used `cloned` where `copied` could be used instead
40-
--> $DIR/cloned_instead_of_copied.rs:33:24
40+
--> $DIR/cloned_instead_of_copied.rs:34:24
4141
|
4242
LL | let _ = [1].iter().cloned(); // Iterator::copied needs 1.36
4343
| ^^^^^^ help: try: `copied`
4444

4545
error: used `cloned` where `copied` could be used instead
46-
--> $DIR/cloned_instead_of_copied.rs:34:22
46+
--> $DIR/cloned_instead_of_copied.rs:35:22
4747
|
4848
LL | let _ = Some(&1).cloned();
4949
| ^^^^^^ help: try: `copied`

tests/ui/eta.fixed

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
clippy::no_effect,
88
clippy::option_map_unit_fn,
99
clippy::redundant_closure_call,
10-
clippy::uninlined_format_args
10+
clippy::uninlined_format_args,
11+
clippy::useless_vec
1112
)]
1213

1314
use std::path::{Path, PathBuf};

tests/ui/eta.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
clippy::no_effect,
88
clippy::option_map_unit_fn,
99
clippy::redundant_closure_call,
10-
clippy::uninlined_format_args
10+
clippy::uninlined_format_args,
11+
clippy::useless_vec
1112
)]
1213

1314
use std::path::{Path, PathBuf};

tests/ui/eta.stderr

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,159 +1,159 @@
11
error: redundant closure
2-
--> $DIR/eta.rs:28:27
2+
--> $DIR/eta.rs:29: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:32:40
10+
--> $DIR/eta.rs:33: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:33:35
16+
--> $DIR/eta.rs:34: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: redundant closure
22-
--> $DIR/eta.rs:34:26
22+
--> $DIR/eta.rs:35:26
2323
|
2424
LL | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted
2525
| ^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `below`
2626

2727
error: redundant closure
28-
--> $DIR/eta.rs:41:27
28+
--> $DIR/eta.rs:42:27
2929
|
3030
LL | let e = Some(1u8).map(|a| generic(a));
3131
| ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `generic`
3232

3333
error: redundant closure
34-
--> $DIR/eta.rs:93:51
34+
--> $DIR/eta.rs:94:51
3535
|
3636
LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo());
3737
| ^^^^^^^^^^^ help: replace the closure with the method itself: `TestStruct::foo`
3838
|
3939
= note: `-D clippy::redundant-closure-for-method-calls` implied by `-D warnings`
4040

4141
error: redundant closure
42-
--> $DIR/eta.rs:94:51
42+
--> $DIR/eta.rs:95:51
4343
|
4444
LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.trait_foo());
4545
| ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `TestTrait::trait_foo`
4646

4747
error: redundant closure
48-
--> $DIR/eta.rs:96:42
48+
--> $DIR/eta.rs:97:42
4949
|
5050
LL | let e = Some(&mut vec![1, 2, 3]).map(|v| v.clear());
5151
| ^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::vec::Vec::clear`
5252

5353
error: redundant closure
54-
--> $DIR/eta.rs:100:29
54+
--> $DIR/eta.rs:101:29
5555
|
5656
LL | let e = Some("str").map(|s| s.to_string());
5757
| ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::string::ToString::to_string`
5858

5959
error: redundant closure
60-
--> $DIR/eta.rs:101:27
60+
--> $DIR/eta.rs:102:27
6161
|
6262
LL | let e = Some('a').map(|s| s.to_uppercase());
6363
| ^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `char::to_uppercase`
6464

6565
error: redundant closure
66-
--> $DIR/eta.rs:103:65
66+
--> $DIR/eta.rs:104:65
6767
|
6868
LL | let e: std::vec::Vec<char> = vec!['a', 'b', 'c'].iter().map(|c| c.to_ascii_uppercase()).collect();
6969
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `char::to_ascii_uppercase`
7070

7171
error: redundant closure
72-
--> $DIR/eta.rs:166:22
72+
--> $DIR/eta.rs:167:22
7373
|
7474
LL | requires_fn_once(|| x());
7575
| ^^^^^^ help: replace the closure with the function itself: `x`
7676

7777
error: redundant closure
78-
--> $DIR/eta.rs:173:27
78+
--> $DIR/eta.rs:174:27
7979
|
8080
LL | let a = Some(1u8).map(|a| foo_ptr(a));
8181
| ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `foo_ptr`
8282

8383
error: redundant closure
84-
--> $DIR/eta.rs:178:27
84+
--> $DIR/eta.rs:179:27
8585
|
8686
LL | let a = Some(1u8).map(|a| closure(a));
8787
| ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `closure`
8888

8989
error: redundant closure
90-
--> $DIR/eta.rs:210:28
90+
--> $DIR/eta.rs:211:28
9191
|
9292
LL | x.into_iter().for_each(|x| add_to_res(x));
9393
| ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut add_to_res`
9494

9595
error: redundant closure
96-
--> $DIR/eta.rs:211:28
96+
--> $DIR/eta.rs:212:28
9797
|
9898
LL | y.into_iter().for_each(|x| add_to_res(x));
9999
| ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut add_to_res`
100100

101101
error: redundant closure
102-
--> $DIR/eta.rs:212:28
102+
--> $DIR/eta.rs:213:28
103103
|
104104
LL | z.into_iter().for_each(|x| add_to_res(x));
105105
| ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `add_to_res`
106106

107107
error: redundant closure
108-
--> $DIR/eta.rs:219:21
108+
--> $DIR/eta.rs:220:21
109109
|
110110
LL | Some(1).map(|n| closure(n));
111111
| ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut closure`
112112

113113
error: redundant closure
114-
--> $DIR/eta.rs:223:21
114+
--> $DIR/eta.rs:224:21
115115
|
116116
LL | Some(1).map(|n| in_loop(n));
117117
| ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `in_loop`
118118

119119
error: redundant closure
120-
--> $DIR/eta.rs:316:18
120+
--> $DIR/eta.rs:317:18
121121
|
122122
LL | takes_fn_mut(|| f());
123123
| ^^^^^^ help: replace the closure with the function itself: `&mut f`
124124

125125
error: redundant closure
126-
--> $DIR/eta.rs:319:19
126+
--> $DIR/eta.rs:320:19
127127
|
128128
LL | takes_fn_once(|| f());
129129
| ^^^^^^ help: replace the closure with the function itself: `&mut f`
130130

131131
error: redundant closure
132-
--> $DIR/eta.rs:323:26
132+
--> $DIR/eta.rs:324:26
133133
|
134134
LL | move || takes_fn_mut(|| f_used_once())
135135
| ^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut f_used_once`
136136

137137
error: redundant closure
138-
--> $DIR/eta.rs:335:19
138+
--> $DIR/eta.rs:336:19
139139
|
140140
LL | array_opt.map(|a| a.as_slice());
141141
| ^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `<[u8; 3]>::as_slice`
142142

143143
error: redundant closure
144-
--> $DIR/eta.rs:338:19
144+
--> $DIR/eta.rs:339:19
145145
|
146146
LL | slice_opt.map(|s| s.len());
147147
| ^^^^^^^^^^^ help: replace the closure with the method itself: `<[u8]>::len`
148148

149149
error: redundant closure
150-
--> $DIR/eta.rs:341:17
150+
--> $DIR/eta.rs:342:17
151151
|
152152
LL | ptr_opt.map(|p| p.is_null());
153153
| ^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `<*const usize>::is_null`
154154

155155
error: redundant closure
156-
--> $DIR/eta.rs:345:17
156+
--> $DIR/eta.rs:346:17
157157
|
158158
LL | dyn_opt.map(|d| d.method_on_dyn());
159159
| ^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `<dyn TestTrait>::method_on_dyn`

tests/ui/from_iter_instead_of_collect.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#![warn(clippy::from_iter_instead_of_collect)]
44
#![allow(unused_imports, unused_tuple_struct_fields)]
5+
#![allow(clippy::useless_vec)]
56

67
use std::collections::{BTreeMap, BTreeSet, HashMap, VecDeque};
78

tests/ui/from_iter_instead_of_collect.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#![warn(clippy::from_iter_instead_of_collect)]
44
#![allow(unused_imports, unused_tuple_struct_fields)]
5+
#![allow(clippy::useless_vec)]
56

67
use std::collections::{BTreeMap, BTreeSet, HashMap, VecDeque};
78

0 commit comments

Comments
 (0)