11error: 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
33 |
44LL | fn do_vec(x: &Vec<i64>) {
55 | ^^^^^^^^^ help: change this to: `&[i64]`
66 |
77 = note: `-D clippy::ptr-arg` implied by `-D warnings`
88
99error: 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
1111 |
1212LL | fn do_vec_mut(x: &mut Vec<i64>) {
1313 | ^^^^^^^^^^^^^ help: change this to: `&mut [i64]`
1414
1515error: 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
1717 |
1818LL | fn do_str(x: &String) {
1919 | ^^^^^^^ help: change this to: `&str`
2020
2121error: 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
2323 |
2424LL | fn do_str_mut(x: &mut String) {
2525 | ^^^^^^^^^^^ help: change this to: `&mut str`
2626
2727error: 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
2929 |
3030LL | fn do_path(x: &PathBuf) {
3131 | ^^^^^^^^ help: change this to: `&Path`
3232
3333error: 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
3535 |
3636LL | fn do_path_mut(x: &mut PathBuf) {
3737 | ^^^^^^^^^^^^ help: change this to: `&mut Path`
3838
3939error: 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
4141 |
4242LL | fn do_vec(x: &Vec<i64>);
4343 | ^^^^^^^^^ help: change this to: `&[i64]`
4444
4545error: 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
4747 |
4848LL | fn cloned(x: &Vec<u8>) -> Vec<u8> {
4949 | ^^^^^^^^
@@ -60,7 +60,7 @@ LL ~ x.to_owned()
6060 |
6161
6262error: 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
6464 |
6565LL | fn str_cloned(x: &String) -> String {
6666 | ^^^^^^^
@@ -76,7 +76,7 @@ LL ~ x.to_owned()
7676 |
7777
7878error: 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
8080 |
8181LL | fn path_cloned(x: &PathBuf) -> PathBuf {
8282 | ^^^^^^^^
@@ -92,7 +92,7 @@ LL ~ x.to_path_buf()
9292 |
9393
9494error: 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
9696 |
9797LL | fn false_positive_capacity(x: &Vec<u8>, y: &String) {
9898 | ^^^^^^^
@@ -106,19 +106,19 @@ LL ~ let c = y;
106106 |
107107
108108error: using a reference to `Cow` is not recommended
109- --> $DIR/ptr_arg.rs:88 :25
109+ --> $DIR/ptr_arg.rs:93 :25
110110 |
111111LL | fn test_cow_with_ref(c: &Cow<[i32]>) {}
112112 | ^^^^^^^^^^^ help: change this to: `&[i32]`
113113
114114error: 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
116116 |
117117LL | fn some_allowed(#[allow(clippy::ptr_arg)] _v: &Vec<u32>, _s: &String) {}
118118 | ^^^^^^^ help: change this to: `&str`
119119
120120error: 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
122122 |
123123LL | fn foo_vec(vec: &Vec<u8>) {
124124 | ^^^^^^^^
@@ -131,7 +131,7 @@ LL ~ let _ = vec.to_owned().clone();
131131 |
132132
133133error: 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
135135 |
136136LL | fn foo_path(path: &PathBuf) {
137137 | ^^^^^^^^
@@ -144,7 +144,7 @@ LL ~ let _ = path.to_path_buf().clone();
144144 |
145145
146146error: 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
148148 |
149149LL | fn foo_str(str: &PathBuf) {
150150 | ^^^^^^^^
@@ -157,28 +157,46 @@ LL ~ let _ = str.to_path_buf().clone();
157157 |
158158
159159error: 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
161161 |
162162LL | fn mut_vec_slice_methods(v: &mut Vec<u32>) {
163163 | ^^^^^^^^^^^^^ help: change this to: `&mut [u32]`
164164
165165error: 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
167167 |
168168LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
169169 | ^^^^^^^^^^^^^ help: change this to: `&mut [u32]`
170170
171171error: 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
173173 |
174174LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
175175 | ^^^^^^^^^^^ help: change this to: `&mut str`
176176
177177error: 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
179179 |
180180LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
181181 | ^^^^^^^^^^^^ help: change this to: `&mut Path`
182182
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
184202
0 commit comments