1
1
error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
2
- --> $DIR/ptr_arg.rs:8 :14
2
+ --> $DIR/ptr_arg.rs:13 :14
3
3
|
4
4
LL | fn do_vec(x: &Vec<i64>) {
5
5
| ^^^^^^^^^ help: change this to: `&[i64]`
6
6
|
7
7
= note: `-D clippy::ptr-arg` implied by `-D warnings`
8
8
9
9
error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
10
- --> $DIR/ptr_arg.rs:12 :18
10
+ --> $DIR/ptr_arg.rs:17 :18
11
11
|
12
12
LL | fn do_vec_mut(x: &mut Vec<i64>) {
13
13
| ^^^^^^^^^^^^^ help: change this to: `&mut [i64]`
14
14
15
15
error: writing `&String` instead of `&str` involves a new object where a slice will do
16
- --> $DIR/ptr_arg.rs:16 :14
16
+ --> $DIR/ptr_arg.rs:21 :14
17
17
|
18
18
LL | fn do_str(x: &String) {
19
19
| ^^^^^^^ help: change this to: `&str`
20
20
21
21
error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do
22
- --> $DIR/ptr_arg.rs:20 :18
22
+ --> $DIR/ptr_arg.rs:25 :18
23
23
|
24
24
LL | fn do_str_mut(x: &mut String) {
25
25
| ^^^^^^^^^^^ help: change this to: `&mut str`
26
26
27
27
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
28
- --> $DIR/ptr_arg.rs:24 :15
28
+ --> $DIR/ptr_arg.rs:29 :15
29
29
|
30
30
LL | fn do_path(x: &PathBuf) {
31
31
| ^^^^^^^^ help: change this to: `&Path`
32
32
33
33
error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do
34
- --> $DIR/ptr_arg.rs:28 :19
34
+ --> $DIR/ptr_arg.rs:33 :19
35
35
|
36
36
LL | fn do_path_mut(x: &mut PathBuf) {
37
37
| ^^^^^^^^^^^^ help: change this to: `&mut Path`
38
38
39
39
error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
40
- --> $DIR/ptr_arg.rs:36 :18
40
+ --> $DIR/ptr_arg.rs:41 :18
41
41
|
42
42
LL | fn do_vec(x: &Vec<i64>);
43
43
| ^^^^^^^^^ help: change this to: `&[i64]`
44
44
45
45
error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
46
- --> $DIR/ptr_arg.rs:49 :14
46
+ --> $DIR/ptr_arg.rs:54 :14
47
47
|
48
48
LL | fn cloned(x: &Vec<u8>) -> Vec<u8> {
49
49
| ^^^^^^^^
@@ -60,7 +60,7 @@ LL ~ x.to_owned()
60
60
|
61
61
62
62
error: writing `&String` instead of `&str` involves a new object where a slice will do
63
- --> $DIR/ptr_arg.rs:58 :18
63
+ --> $DIR/ptr_arg.rs:63 :18
64
64
|
65
65
LL | fn str_cloned(x: &String) -> String {
66
66
| ^^^^^^^
@@ -76,7 +76,7 @@ LL ~ x.to_owned()
76
76
|
77
77
78
78
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
79
- --> $DIR/ptr_arg.rs:66 :19
79
+ --> $DIR/ptr_arg.rs:71 :19
80
80
|
81
81
LL | fn path_cloned(x: &PathBuf) -> PathBuf {
82
82
| ^^^^^^^^
@@ -92,7 +92,7 @@ LL ~ x.to_path_buf()
92
92
|
93
93
94
94
error: writing `&String` instead of `&str` involves a new object where a slice will do
95
- --> $DIR/ptr_arg.rs:74 :44
95
+ --> $DIR/ptr_arg.rs:79 :44
96
96
|
97
97
LL | fn false_positive_capacity(x: &Vec<u8>, y: &String) {
98
98
| ^^^^^^^
@@ -106,19 +106,19 @@ LL ~ let c = y;
106
106
|
107
107
108
108
error: using a reference to `Cow` is not recommended
109
- --> $DIR/ptr_arg.rs:88 :25
109
+ --> $DIR/ptr_arg.rs:93 :25
110
110
|
111
111
LL | fn test_cow_with_ref(c: &Cow<[i32]>) {}
112
112
| ^^^^^^^^^^^ help: change this to: `&[i32]`
113
113
114
114
error: writing `&String` instead of `&str` involves a new object where a slice will do
115
- --> $DIR/ptr_arg.rs:117 :66
115
+ --> $DIR/ptr_arg.rs:122 :66
116
116
|
117
117
LL | fn some_allowed(#[allow(clippy::ptr_arg)] _v: &Vec<u32>, _s: &String) {}
118
118
| ^^^^^^^ help: change this to: `&str`
119
119
120
120
error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
121
- --> $DIR/ptr_arg.rs:146 :21
121
+ --> $DIR/ptr_arg.rs:151 :21
122
122
|
123
123
LL | fn foo_vec(vec: &Vec<u8>) {
124
124
| ^^^^^^^^
@@ -131,7 +131,7 @@ LL ~ let _ = vec.to_owned().clone();
131
131
|
132
132
133
133
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
134
- --> $DIR/ptr_arg.rs:151 :23
134
+ --> $DIR/ptr_arg.rs:156 :23
135
135
|
136
136
LL | fn foo_path(path: &PathBuf) {
137
137
| ^^^^^^^^
@@ -144,7 +144,7 @@ LL ~ let _ = path.to_path_buf().clone();
144
144
|
145
145
146
146
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
147
- --> $DIR/ptr_arg.rs:156 :21
147
+ --> $DIR/ptr_arg.rs:161 :21
148
148
|
149
149
LL | fn foo_str(str: &PathBuf) {
150
150
| ^^^^^^^^
@@ -157,28 +157,46 @@ LL ~ let _ = str.to_path_buf().clone();
157
157
|
158
158
159
159
error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
160
- --> $DIR/ptr_arg.rs:162 :29
160
+ --> $DIR/ptr_arg.rs:167 :29
161
161
|
162
162
LL | fn mut_vec_slice_methods(v: &mut Vec<u32>) {
163
163
| ^^^^^^^^^^^^^ help: change this to: `&mut [u32]`
164
164
165
165
error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
166
- --> $DIR/ptr_arg.rs:224 :17
166
+ --> $DIR/ptr_arg.rs:229 :17
167
167
|
168
168
LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
169
169
| ^^^^^^^^^^^^^ help: change this to: `&mut [u32]`
170
170
171
171
error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do
172
- --> $DIR/ptr_arg.rs:224 :35
172
+ --> $DIR/ptr_arg.rs:229 :35
173
173
|
174
174
LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
175
175
| ^^^^^^^^^^^ help: change this to: `&mut str`
176
176
177
177
error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do
178
- --> $DIR/ptr_arg.rs:224 :51
178
+ --> $DIR/ptr_arg.rs:229 :51
179
179
|
180
180
LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
181
181
| ^^^^^^^^^^^^ help: change this to: `&mut Path`
182
182
183
- error: aborting due to 20 previous errors
183
+ error: using a reference to `Cow` is not recommended
184
+ --> $DIR/ptr_arg.rs:252:39
185
+ |
186
+ LL | fn cow_elided_lifetime<'a>(input: &'a Cow<str>) -> &'a str {
187
+ | ^^^^^^^^^^^^ help: change this to: `&str`
188
+
189
+ error: using a reference to `Cow` is not recommended
190
+ --> $DIR/ptr_arg.rs:257:36
191
+ |
192
+ LL | fn cow_bad_ret_ty_1<'a>(input: &'a Cow<'a, str>) -> &'static str {
193
+ | ^^^^^^^^^^^^^^^^ help: change this to: `&str`
194
+
195
+ error: using a reference to `Cow` is not recommended
196
+ --> $DIR/ptr_arg.rs:260:40
197
+ |
198
+ LL | fn cow_bad_ret_ty_2<'a, 'b>(input: &'a Cow<'a, str>) -> &'b str {
199
+ | ^^^^^^^^^^^^^^^^ help: change this to: `&str`
200
+
201
+ error: aborting due to 23 previous errors
184
202
0 commit comments