1 error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
2 --> $DIR/ptr_arg.rs:13:14
4 LL | fn do_vec(x: &Vec<i64>) {
5 | ^^^^^^^^^ help: change this to: `&[i64]`
7 = note: `-D clippy::ptr-arg` implied by `-D warnings`
9 error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
10 --> $DIR/ptr_arg.rs:17:18
12 LL | fn do_vec_mut(x: &mut Vec<i64>) {
13 | ^^^^^^^^^^^^^ help: change this to: `&mut [i64]`
15 error: writing `&String` instead of `&str` involves a new object where a slice will do
16 --> $DIR/ptr_arg.rs:21:14
18 LL | fn do_str(x: &String) {
19 | ^^^^^^^ help: change this to: `&str`
21 error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do
22 --> $DIR/ptr_arg.rs:25:18
24 LL | fn do_str_mut(x: &mut String) {
25 | ^^^^^^^^^^^ help: change this to: `&mut str`
27 error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
28 --> $DIR/ptr_arg.rs:29:15
30 LL | fn do_path(x: &PathBuf) {
31 | ^^^^^^^^ help: change this to: `&Path`
33 error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do
34 --> $DIR/ptr_arg.rs:33:19
36 LL | fn do_path_mut(x: &mut PathBuf) {
37 | ^^^^^^^^^^^^ help: change this to: `&mut Path`
39 error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
40 --> $DIR/ptr_arg.rs:41:18
42 LL | fn do_vec(x: &Vec<i64>);
43 | ^^^^^^^^^ help: change this to: `&[i64]`
45 error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
46 --> $DIR/ptr_arg.rs:54:14
48 LL | fn cloned(x: &Vec<u8>) -> Vec<u8> {
53 LL ~ fn cloned(x: &[u8]) -> Vec<u8> {
54 LL ~ let e = x.to_owned();
55 LL | let f = e.clone(); // OK
57 LL ~ let h = g.to_owned();
58 LL | let i = (e).clone();
62 error: writing `&String` instead of `&str` involves a new object where a slice will do
63 --> $DIR/ptr_arg.rs:63:18
65 LL | fn str_cloned(x: &String) -> String {
70 LL ~ fn str_cloned(x: &str) -> String {
71 LL ~ let a = x.to_owned();
72 LL ~ let b = x.to_owned();
73 LL | let c = b.clone();
74 LL | let d = a.clone().clone().clone();
78 error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
79 --> $DIR/ptr_arg.rs:71:19
81 LL | fn path_cloned(x: &PathBuf) -> PathBuf {
86 LL ~ fn path_cloned(x: &Path) -> PathBuf {
87 LL ~ let a = x.to_path_buf();
88 LL ~ let b = x.to_path_buf();
89 LL | let c = b.clone();
90 LL | let d = a.clone().clone().clone();
94 error: writing `&String` instead of `&str` involves a new object where a slice will do
95 --> $DIR/ptr_arg.rs:79:44
97 LL | fn false_positive_capacity(x: &Vec<u8>, y: &String) {
102 LL ~ fn false_positive_capacity(x: &Vec<u8>, y: &str) {
103 LL | let a = x.capacity();
104 LL ~ let b = y.to_owned();
108 error: using a reference to `Cow` is not recommended
109 --> $DIR/ptr_arg.rs:93:25
111 LL | fn test_cow_with_ref(c: &Cow<[i32]>) {}
112 | ^^^^^^^^^^^ help: change this to: `&[i32]`
114 error: writing `&String` instead of `&str` involves a new object where a slice will do
115 --> $DIR/ptr_arg.rs:122:66
117 LL | fn some_allowed(#[allow(clippy::ptr_arg)] _v: &Vec<u32>, _s: &String) {}
118 | ^^^^^^^ help: change this to: `&str`
120 error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
121 --> $DIR/ptr_arg.rs:151:21
123 LL | fn foo_vec(vec: &Vec<u8>) {
128 LL ~ fn foo_vec(vec: &[u8]) {
129 LL ~ let _ = vec.to_owned().pop();
130 LL ~ let _ = vec.to_owned().clone();
133 error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
134 --> $DIR/ptr_arg.rs:156:23
136 LL | fn foo_path(path: &PathBuf) {
141 LL ~ fn foo_path(path: &Path) {
142 LL ~ let _ = path.to_path_buf().pop();
143 LL ~ let _ = path.to_path_buf().clone();
146 error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
147 --> $DIR/ptr_arg.rs:161:21
149 LL | fn foo_str(str: &PathBuf) {
154 LL ~ fn foo_str(str: &Path) {
155 LL ~ let _ = str.to_path_buf().pop();
156 LL ~ let _ = str.to_path_buf().clone();
159 error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
160 --> $DIR/ptr_arg.rs:167:29
162 LL | fn mut_vec_slice_methods(v: &mut Vec<u32>) {
163 | ^^^^^^^^^^^^^ help: change this to: `&mut [u32]`
165 error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
166 --> $DIR/ptr_arg.rs:229:17
168 LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
169 | ^^^^^^^^^^^^^ help: change this to: `&mut [u32]`
171 error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do
172 --> $DIR/ptr_arg.rs:229:35
174 LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
175 | ^^^^^^^^^^^ help: change this to: `&mut str`
177 error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do
178 --> $DIR/ptr_arg.rs:229:51
180 LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
181 | ^^^^^^^^^^^^ help: change this to: `&mut Path`
183 error: using a reference to `Cow` is not recommended
184 --> $DIR/ptr_arg.rs:252:39
186 LL | fn cow_elided_lifetime<'a>(input: &'a Cow<str>) -> &'a str {
187 | ^^^^^^^^^^^^ help: change this to: `&str`
189 error: using a reference to `Cow` is not recommended
190 --> $DIR/ptr_arg.rs:257:36
192 LL | fn cow_bad_ret_ty_1<'a>(input: &'a Cow<'a, str>) -> &'static str {
193 | ^^^^^^^^^^^^^^^^ help: change this to: `&str`
195 error: using a reference to `Cow` is not recommended
196 --> $DIR/ptr_arg.rs:260:40
198 LL | fn cow_bad_ret_ty_2<'a, 'b>(input: &'a Cow<'a, str>) -> &'b str {
199 | ^^^^^^^^^^^^^^^^ help: change this to: `&str`
201 error: aborting due to 23 previous errors