11error: 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
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:11 :18
10+ --> $DIR/ptr_arg.rs:12 :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:15 :14
16+ --> $DIR/ptr_arg.rs:16 :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:19 :18
22+ --> $DIR/ptr_arg.rs:20 :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:23 :15
28+ --> $DIR/ptr_arg.rs:24 :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:27 :19
34+ --> $DIR/ptr_arg.rs:28 :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:35 :18
40+ --> $DIR/ptr_arg.rs:36 :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:48 :14
46+ --> $DIR/ptr_arg.rs:49 :14
4747 |
4848LL | fn cloned(x: &Vec<u8>) -> Vec<u8> {
4949 | ^^^^^^^^
@@ -59,7 +59,7 @@ LL | let i = (e).clone();
5959 ...
6060
6161error: 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
6363 |
6464LL | fn str_cloned(x: &String) -> String {
6565 | ^^^^^^^
@@ -75,7 +75,7 @@ LL ~ x.to_owned()
7575 |
7676
7777error: 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
7979 |
8080LL | fn path_cloned(x: &PathBuf) -> PathBuf {
8181 | ^^^^^^^^
@@ -91,7 +91,7 @@ LL ~ x.to_path_buf()
9191 |
9292
9393error: 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
9595 |
9696LL | fn false_positive_capacity(x: &Vec<u8>, y: &String) {
9797 | ^^^^^^^
@@ -105,13 +105,19 @@ LL ~ let c = y;
105105 |
106106
107107error: using a reference to `Cow` is not recommended
108- --> $DIR/ptr_arg.rs:87 :25
108+ --> $DIR/ptr_arg.rs:88 :25
109109 |
110110LL | fn test_cow_with_ref(c: &Cow<[i32]>) {}
111111 | ^^^^^^^^^^^ help: change this to: `&[i32]`
112112
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+
113119error: 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
115121 |
116122LL | fn foo_vec(vec: &Vec<u8>) {
117123 | ^^^^^^^^
@@ -124,7 +130,7 @@ LL ~ let _ = vec.to_owned().clone();
124130 |
125131
126132error: 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
128134 |
129135LL | fn foo_path(path: &PathBuf) {
130136 | ^^^^^^^^
@@ -137,7 +143,7 @@ LL ~ let _ = path.to_path_buf().clone();
137143 |
138144
139145error: 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
141147 |
142148LL | fn foo_str(str: &PathBuf) {
143149 | ^^^^^^^^
@@ -150,10 +156,10 @@ LL ~ let _ = str.to_path_buf().clone();
150156 |
151157
152158error: 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
154160 |
155161LL | fn mut_vec_slice_methods(v: &mut Vec<u32>) {
156162 | ^^^^^^^^^^^^^ help: change this to: `&mut [u32]`
157163
158- error: aborting due to 16 previous errors
164+ error: aborting due to 17 previous errors
159165
0 commit comments