]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/ptr_arg.stderr
New upstream version 1.72.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / ptr_arg.stderr
1 error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
2 --> $DIR/ptr_arg.rs:13:14
3 |
4 LL | fn do_vec(x: &Vec<i64>) {
5 | ^^^^^^^^^ help: change this to: `&[i64]`
6 |
7 = note: `-D clippy::ptr-arg` implied by `-D warnings`
8
9 error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
10 --> $DIR/ptr_arg.rs:17:18
11 |
12 LL | fn do_vec_mut(x: &mut Vec<i64>) {
13 | ^^^^^^^^^^^^^ help: change this to: `&mut [i64]`
14
15 error: writing `&String` instead of `&str` involves a new object where a slice will do
16 --> $DIR/ptr_arg.rs:21:14
17 |
18 LL | fn do_str(x: &String) {
19 | ^^^^^^^ help: change this to: `&str`
20
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
23 |
24 LL | fn do_str_mut(x: &mut String) {
25 | ^^^^^^^^^^^ help: change this to: `&mut str`
26
27 error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
28 --> $DIR/ptr_arg.rs:29:15
29 |
30 LL | fn do_path(x: &PathBuf) {
31 | ^^^^^^^^ help: change this to: `&Path`
32
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
35 |
36 LL | fn do_path_mut(x: &mut PathBuf) {
37 | ^^^^^^^^^^^^ help: change this to: `&mut Path`
38
39 error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
40 --> $DIR/ptr_arg.rs:41:18
41 |
42 LL | fn do_vec(x: &Vec<i64>);
43 | ^^^^^^^^^ help: change this to: `&[i64]`
44
45 error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
46 --> $DIR/ptr_arg.rs:54:14
47 |
48 LL | fn cloned(x: &Vec<u8>) -> Vec<u8> {
49 | ^^^^^^^^
50 |
51 help: change this to
52 |
53 LL ~ fn cloned(x: &[u8]) -> Vec<u8> {
54 LL ~ let e = x.to_owned();
55 LL | let f = e.clone(); // OK
56 LL | let g = x;
57 LL ~ let h = g.to_owned();
58 LL | let i = (e).clone();
59 LL ~ x.to_owned()
60 |
61
62 error: writing `&String` instead of `&str` involves a new object where a slice will do
63 --> $DIR/ptr_arg.rs:63:18
64 |
65 LL | fn str_cloned(x: &String) -> String {
66 | ^^^^^^^
67 |
68 help: change this to
69 |
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();
75 LL ~ x.to_owned()
76 |
77
78 error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
79 --> $DIR/ptr_arg.rs:71:19
80 |
81 LL | fn path_cloned(x: &PathBuf) -> PathBuf {
82 | ^^^^^^^^
83 |
84 help: change this to
85 |
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();
91 LL ~ x.to_path_buf()
92 |
93
94 error: writing `&String` instead of `&str` involves a new object where a slice will do
95 --> $DIR/ptr_arg.rs:79:44
96 |
97 LL | fn false_positive_capacity(x: &Vec<u8>, y: &String) {
98 | ^^^^^^^
99 |
100 help: change this to
101 |
102 LL ~ fn false_positive_capacity(x: &Vec<u8>, y: &str) {
103 LL | let a = x.capacity();
104 LL ~ let b = y.to_owned();
105 LL ~ let c = y;
106 |
107
108 error: using a reference to `Cow` is not recommended
109 --> $DIR/ptr_arg.rs:93:25
110 |
111 LL | fn test_cow_with_ref(c: &Cow<[i32]>) {}
112 | ^^^^^^^^^^^ help: change this to: `&[i32]`
113
114 error: writing `&String` instead of `&str` involves a new object where a slice will do
115 --> $DIR/ptr_arg.rs:122:66
116 |
117 LL | fn some_allowed(#[allow(clippy::ptr_arg)] _v: &Vec<u32>, _s: &String) {}
118 | ^^^^^^^ help: change this to: `&str`
119
120 error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
121 --> $DIR/ptr_arg.rs:151:21
122 |
123 LL | fn foo_vec(vec: &Vec<u8>) {
124 | ^^^^^^^^
125 |
126 help: change this to
127 |
128 LL ~ fn foo_vec(vec: &[u8]) {
129 LL ~ let _ = vec.to_owned().pop();
130 LL ~ let _ = vec.to_owned().clone();
131 |
132
133 error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
134 --> $DIR/ptr_arg.rs:156:23
135 |
136 LL | fn foo_path(path: &PathBuf) {
137 | ^^^^^^^^
138 |
139 help: change this to
140 |
141 LL ~ fn foo_path(path: &Path) {
142 LL ~ let _ = path.to_path_buf().pop();
143 LL ~ let _ = path.to_path_buf().clone();
144 |
145
146 error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
147 --> $DIR/ptr_arg.rs:161:21
148 |
149 LL | fn foo_str(str: &PathBuf) {
150 | ^^^^^^^^
151 |
152 help: change this to
153 |
154 LL ~ fn foo_str(str: &Path) {
155 LL ~ let _ = str.to_path_buf().pop();
156 LL ~ let _ = str.to_path_buf().clone();
157 |
158
159 error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
160 --> $DIR/ptr_arg.rs:167:29
161 |
162 LL | fn mut_vec_slice_methods(v: &mut Vec<u32>) {
163 | ^^^^^^^^^^^^^ help: change this to: `&mut [u32]`
164
165 error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
166 --> $DIR/ptr_arg.rs:229:17
167 |
168 LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
169 | ^^^^^^^^^^^^^ help: change this to: `&mut [u32]`
170
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
173 |
174 LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
175 | ^^^^^^^^^^^ help: change this to: `&mut str`
176
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
179 |
180 LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
181 | ^^^^^^^^^^^^ help: change this to: `&mut Path`
182
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
202