1
1
error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
2
- --> $DIR/ptr_arg.rs:7 :14
2
+ --> $DIR/ptr_arg.rs:8 :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:11 :18
10
+ --> $DIR/ptr_arg.rs:12 :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:15 :14
16
+ --> $DIR/ptr_arg.rs:16 :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:19 :18
22
+ --> $DIR/ptr_arg.rs:20 :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:23 :15
28
+ --> $DIR/ptr_arg.rs:24 :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:27 :19
34
+ --> $DIR/ptr_arg.rs:28 :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:35 :18
40
+ --> $DIR/ptr_arg.rs:36 :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:48 :14
46
+ --> $DIR/ptr_arg.rs:49 :14
47
47
|
48
48
LL | fn cloned(x: &Vec<u8>) -> Vec<u8> {
49
49
| ^^^^^^^^
@@ -59,7 +59,7 @@ LL | let i = (e).clone();
59
59
...
60
60
61
61
error: writing `&String` instead of `&str` involves a new object where a slice will do
62
- --> $DIR/ptr_arg.rs:57 :18
62
+ --> $DIR/ptr_arg.rs:58 :18
63
63
|
64
64
LL | fn str_cloned(x: &String) -> String {
65
65
| ^^^^^^^
@@ -75,7 +75,7 @@ LL ~ x.to_owned()
75
75
|
76
76
77
77
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
78
- --> $DIR/ptr_arg.rs:65 :19
78
+ --> $DIR/ptr_arg.rs:66 :19
79
79
|
80
80
LL | fn path_cloned(x: &PathBuf) -> PathBuf {
81
81
| ^^^^^^^^
@@ -91,7 +91,7 @@ LL ~ x.to_path_buf()
91
91
|
92
92
93
93
error: writing `&String` instead of `&str` involves a new object where a slice will do
94
- --> $DIR/ptr_arg.rs:73 :44
94
+ --> $DIR/ptr_arg.rs:74 :44
95
95
|
96
96
LL | fn false_positive_capacity(x: &Vec<u8>, y: &String) {
97
97
| ^^^^^^^
@@ -105,13 +105,19 @@ LL ~ let c = y;
105
105
|
106
106
107
107
error: using a reference to `Cow` is not recommended
108
- --> $DIR/ptr_arg.rs:87 :25
108
+ --> $DIR/ptr_arg.rs:88 :25
109
109
|
110
110
LL | fn test_cow_with_ref(c: &Cow<[i32]>) {}
111
111
| ^^^^^^^^^^^ help: change this to: `&[i32]`
112
112
113
+ error: writing `&String` instead of `&str` involves a new object where a slice will do
114
+ --> $DIR/ptr_arg.rs:117:66
115
+ |
116
+ LL | fn some_allowed(#[allow(clippy::ptr_arg)] _v: &Vec<u32>, _s: &String) {}
117
+ | ^^^^^^^ help: change this to: `&str`
118
+
113
119
error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
114
- --> $DIR/ptr_arg.rs:140 :21
120
+ --> $DIR/ptr_arg.rs:146 :21
115
121
|
116
122
LL | fn foo_vec(vec: &Vec<u8>) {
117
123
| ^^^^^^^^
@@ -124,7 +130,7 @@ LL ~ let _ = vec.to_owned().clone();
124
130
|
125
131
126
132
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
127
- --> $DIR/ptr_arg.rs:145 :23
133
+ --> $DIR/ptr_arg.rs:151 :23
128
134
|
129
135
LL | fn foo_path(path: &PathBuf) {
130
136
| ^^^^^^^^
@@ -137,7 +143,7 @@ LL ~ let _ = path.to_path_buf().clone();
137
143
|
138
144
139
145
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
140
- --> $DIR/ptr_arg.rs:150 :21
146
+ --> $DIR/ptr_arg.rs:156 :21
141
147
|
142
148
LL | fn foo_str(str: &PathBuf) {
143
149
| ^^^^^^^^
@@ -150,10 +156,10 @@ LL ~ let _ = str.to_path_buf().clone();
150
156
|
151
157
152
158
error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
153
- --> $DIR/ptr_arg.rs:156 :29
159
+ --> $DIR/ptr_arg.rs:162 :29
154
160
|
155
161
LL | fn mut_vec_slice_methods(v: &mut Vec<u32>) {
156
162
| ^^^^^^^^^^^^^ help: change this to: `&mut [u32]`
157
163
158
- error: aborting due to 16 previous errors
164
+ error: aborting due to 17 previous errors
159
165
0 commit comments