fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
6.8 KiB210 linesraw
1error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
2  --> $DIR/ptr_arg.rs:14:14
3   |
4LL | fn do_vec(x: &Vec<i64>) {
5   |              ^^^^^^^^^ help: change this to: `&[i64]`
6   |
7   = note: `-D clippy::ptr-arg` implied by `-D warnings`
8   = help: to override `-D warnings` add `#[allow(clippy::ptr_arg)]`
9
10error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
11  --> $DIR/ptr_arg.rs:20:18
12   |
13LL | fn do_vec_mut(x: &mut Vec<i64>) {
14   |                  ^^^^^^^^^^^^^ help: change this to: `&mut [i64]`
15
16error: writing `&String` instead of `&str` involves a new object where a slice will do
17  --> $DIR/ptr_arg.rs:25:14
18   |
19LL | fn do_str(x: &String) {
20   |              ^^^^^^^ help: change this to: `&str`
21
22error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do
23  --> $DIR/ptr_arg.rs:30:18
24   |
25LL | fn do_str_mut(x: &mut String) {
26   |                  ^^^^^^^^^^^ help: change this to: `&mut str`
27
28error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
29  --> $DIR/ptr_arg.rs:35:15
30   |
31LL | fn do_path(x: &PathBuf) {
32   |               ^^^^^^^^ help: change this to: `&Path`
33
34error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do
35  --> $DIR/ptr_arg.rs:40:19
36   |
37LL | fn do_path_mut(x: &mut PathBuf) {
38   |                   ^^^^^^^^^^^^ help: change this to: `&mut Path`
39
40error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
41  --> $DIR/ptr_arg.rs:49:18
42   |
43LL |     fn do_vec(x: &Vec<i64>);
44   |                  ^^^^^^^^^ help: change this to: `&[i64]`
45
46error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
47  --> $DIR/ptr_arg.rs:63:14
48   |
49LL | fn cloned(x: &Vec<u8>) -> Vec<u8> {
50   |              ^^^^^^^^
51   |
52help: change this to
53   |
54LL ~ fn cloned(x: &[u8]) -> Vec<u8> {
55LL |
56LL ~     let e = x.to_owned();
57LL |     let f = e.clone(); // OK
58LL |     let g = x;
59LL ~     let h = g.to_owned();
60LL |     let i = (e).clone();
61LL ~     x.to_owned()
62   |
63
64error: writing `&String` instead of `&str` involves a new object where a slice will do
65  --> $DIR/ptr_arg.rs:73:18
66   |
67LL | fn str_cloned(x: &String) -> String {
68   |                  ^^^^^^^
69   |
70help: change this to
71   |
72LL ~ fn str_cloned(x: &str) -> String {
73LL |
74LL ~     let a = x.to_owned();
75LL ~     let b = x.to_owned();
76LL |     let c = b.clone();
77LL |     let d = a.clone().clone().clone();
78LL ~     x.to_owned()
79   |
80
81error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
82  --> $DIR/ptr_arg.rs:82:19
83   |
84LL | fn path_cloned(x: &PathBuf) -> PathBuf {
85   |                   ^^^^^^^^
86   |
87help: change this to
88   |
89LL ~ fn path_cloned(x: &Path) -> PathBuf {
90LL |
91LL ~     let a = x.to_path_buf();
92LL ~     let b = x.to_path_buf();
93LL |     let c = b.clone();
94LL |     let d = a.clone().clone().clone();
95LL ~     x.to_path_buf()
96   |
97
98error: writing `&String` instead of `&str` involves a new object where a slice will do
99  --> $DIR/ptr_arg.rs:91:44
100   |
101LL | fn false_positive_capacity(x: &Vec<u8>, y: &String) {
102   |                                            ^^^^^^^
103   |
104help: change this to
105   |
106LL ~ fn false_positive_capacity(x: &Vec<u8>, y: &str) {
107LL |
108LL |     let a = x.capacity();
109LL ~     let b = y.to_owned();
110LL ~     let c = y;
111   |
112
113error: using a reference to `Cow` is not recommended
114  --> $DIR/ptr_arg.rs:106:25
115   |
116LL | fn test_cow_with_ref(c: &Cow<[i32]>) {}
117   |                         ^^^^^^^^^^^ help: change this to: `&[i32]`
118
119error: writing `&String` instead of `&str` involves a new object where a slice will do
120  --> $DIR/ptr_arg.rs:136:66
121   |
122LL |     fn some_allowed(#[allow(clippy::ptr_arg)] _v: &Vec<u32>, _s: &String) {}
123   |                                                                  ^^^^^^^ help: change this to: `&str`
124
125error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
126  --> $DIR/ptr_arg.rs:166:21
127   |
128LL |     fn foo_vec(vec: &Vec<u8>) {
129   |                     ^^^^^^^^
130   |
131help: change this to
132   |
133LL ~     fn foo_vec(vec: &[u8]) {
134LL |
135LL ~         let _ = vec.to_owned().pop();
136LL ~         let _ = vec.to_owned().clone();
137   |
138
139error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
140  --> $DIR/ptr_arg.rs:172:23
141   |
142LL |     fn foo_path(path: &PathBuf) {
143   |                       ^^^^^^^^
144   |
145help: change this to
146   |
147LL ~     fn foo_path(path: &Path) {
148LL |
149LL ~         let _ = path.to_path_buf().pop();
150LL ~         let _ = path.to_path_buf().clone();
151   |
152
153error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
154  --> $DIR/ptr_arg.rs:178:21
155   |
156LL |     fn foo_str(str: &PathBuf) {
157   |                     ^^^^^^^^
158   |
159help: change this to
160   |
161LL ~     fn foo_str(str: &Path) {
162LL |
163LL ~         let _ = str.to_path_buf().pop();
164LL ~         let _ = str.to_path_buf().clone();
165   |
166
167error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
168  --> $DIR/ptr_arg.rs:185:29
169   |
170LL | fn mut_vec_slice_methods(v: &mut Vec<u32>) {
171   |                             ^^^^^^^^^^^^^ help: change this to: `&mut [u32]`
172
173error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
174  --> $DIR/ptr_arg.rs:248:17
175   |
176LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
177   |                 ^^^^^^^^^^^^^ help: change this to: `&mut [u32]`
178
179error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do
180  --> $DIR/ptr_arg.rs:248:35
181   |
182LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
183   |                                   ^^^^^^^^^^^ help: change this to: `&mut str`
184
185error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do
186  --> $DIR/ptr_arg.rs:248:51
187   |
188LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
189   |                                                   ^^^^^^^^^^^^ help: change this to: `&mut Path`
190
191error: using a reference to `Cow` is not recommended
192  --> $DIR/ptr_arg.rs:274:39
193   |
194LL |     fn cow_elided_lifetime<'a>(input: &'a Cow<str>) -> &'a str {
195   |                                       ^^^^^^^^^^^^ help: change this to: `&str`
196
197error: using a reference to `Cow` is not recommended
198  --> $DIR/ptr_arg.rs:280:36
199   |
200LL |     fn cow_bad_ret_ty_1<'a>(input: &'a Cow<'a, str>) -> &'static str {
201   |                                    ^^^^^^^^^^^^^^^^ help: change this to: `&str`
202
203error: using a reference to `Cow` is not recommended
204  --> $DIR/ptr_arg.rs:284:40
205   |
206LL |     fn cow_bad_ret_ty_2<'a, 'b>(input: &'a Cow<'a, str>) -> &'b str {
207   |                                        ^^^^^^^^^^^^^^^^ help: change this to: `&str`
208
209error: aborting due to 23 previous errors
210