]> git.lizzy.rs Git - rust.git/blob - tests/ui/ptr_arg.stderr
add suggestions for .clone() in ptr_arg fns
[rust.git] / tests / ui / ptr_arg.stderr
1 error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices.
2  --> $DIR/ptr_arg.rs:6:14
3   |
4 6 | fn do_vec(x: &Vec<i64>) {
5   |              ^^^^^^^^^ help: change this to: `&[i64]`
6   |
7   = note: `-D ptr-arg` implied by `-D warnings`
8
9 error: writing `&String` instead of `&str` involves a new object where a slice will do.
10   --> $DIR/ptr_arg.rs:14:14
11    |
12 14 | fn do_str(x: &String) {
13    |              ^^^^^^^ help: change this to: `&str`
14
15 error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices.
16   --> $DIR/ptr_arg.rs:27:18
17    |
18 27 |     fn do_vec(x: &Vec<i64>);
19    |                  ^^^^^^^^^ help: change this to: `&[i64]`
20
21 error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices.
22   --> $DIR/ptr_arg.rs:40:14
23    |
24 40 | fn cloned(x: &Vec<u8>) -> Vec<u8> {
25    |              ^^^^^^^^
26    |
27 help: change this to
28    |
29 40 | fn cloned(x: &[u8]) -> Vec<u8> {
30    |              ^^^^^
31 help: change the `.clone()` to
32    |
33 41 |     let e = x.to_owned();
34    |             ^^^^^^^^^^^^
35 help: change the `.clone()` to
36    |
37 46 |     x.to_owned()
38    |     ^^^^^^^^^^^^
39
40 error: writing `&String` instead of `&str` involves a new object where a slice will do.
41   --> $DIR/ptr_arg.rs:49:18
42    |
43 49 | fn str_cloned(x: &String) -> String {
44    |                  ^^^^^^^
45    |
46 help: change this to
47    |
48 49 | fn str_cloned(x: &str) -> String {
49    |                  ^^^^
50 help: change the `.clone` to 
51    |
52 50 |     let a = x.to_string();
53    |             ^^^^^^^^^^^^^
54 help: change the `.clone` to 
55    |
56 51 |     let b = x.to_string();
57    |             ^^^^^^^^^^^^^
58 help: change the `.clone` to 
59    |
60 56 |     x.to_string()
61    |     ^^^^^^^^^^^^^
62
63 error: aborting due to 5 previous errors
64