1 error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
2 --> $DIR/ptr_arg.rs:7: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:11: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:15: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:19: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:23: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:27: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:35: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:48: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();
61 error: writing `&String` instead of `&str` involves a new object where a slice will do
62 --> $DIR/ptr_arg.rs:57:18
64 LL | fn str_cloned(x: &String) -> String {
69 LL ~ fn str_cloned(x: &str) -> String {
70 LL ~ let a = x.to_owned();
71 LL ~ let b = x.to_owned();
72 LL | let c = b.clone();
73 LL | let d = a.clone().clone().clone();
77 error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
78 --> $DIR/ptr_arg.rs:65:19
80 LL | fn path_cloned(x: &PathBuf) -> PathBuf {
85 LL ~ fn path_cloned(x: &Path) -> PathBuf {
86 LL ~ let a = x.to_path_buf();
87 LL ~ let b = x.to_path_buf();
88 LL | let c = b.clone();
89 LL | let d = a.clone().clone().clone();
93 error: writing `&String` instead of `&str` involves a new object where a slice will do
94 --> $DIR/ptr_arg.rs:73:44
96 LL | fn false_positive_capacity(x: &Vec<u8>, y: &String) {
101 LL ~ fn false_positive_capacity(x: &Vec<u8>, y: &str) {
102 LL | let a = x.capacity();
103 LL ~ let b = y.to_owned();
107 error: using a reference to `Cow` is not recommended
108 --> $DIR/ptr_arg.rs:87:25
110 LL | fn test_cow_with_ref(c: &Cow<[i32]>) {}
111 | ^^^^^^^^^^^ help: change this to: `&[i32]`
113 error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
114 --> $DIR/ptr_arg.rs:140:21
116 LL | fn foo_vec(vec: &Vec<u8>) {
121 LL ~ fn foo_vec(vec: &[u8]) {
122 LL ~ let _ = vec.to_owned().pop();
123 LL ~ let _ = vec.to_owned().clone();
126 error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
127 --> $DIR/ptr_arg.rs:145:23
129 LL | fn foo_path(path: &PathBuf) {
134 LL ~ fn foo_path(path: &Path) {
135 LL ~ let _ = path.to_path_buf().pop();
136 LL ~ let _ = path.to_path_buf().clone();
139 error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
140 --> $DIR/ptr_arg.rs:150:21
142 LL | fn foo_str(str: &PathBuf) {
147 LL ~ fn foo_str(str: &Path) {
148 LL ~ let _ = str.to_path_buf().pop();
149 LL ~ let _ = str.to_path_buf().clone();
152 error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
153 --> $DIR/ptr_arg.rs:156:29
155 LL | fn mut_vec_slice_methods(v: &mut Vec<u32>) {
156 | ^^^^^^^^^^^^^ help: change this to: `&mut [u32]`
158 error: aborting due to 16 previous errors