]>
Commit | Line | Data |
---|---|---|
5099ac24 | 1 | error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do |
f20569fa XL |
2 | --> $DIR/ptr_arg.rs:7: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 | ||
5099ac24 FG |
9 | error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do |
10 | --> $DIR/ptr_arg.rs:11:18 | |
11 | | | |
12 | LL | fn do_vec_mut(x: &mut Vec<i64>) { | |
13 | | ^^^^^^^^^^^^^ help: change this to: `&mut [i64]` | |
14 | ||
f20569fa | 15 | error: writing `&String` instead of `&str` involves a new object where a slice will do |
5099ac24 | 16 | --> $DIR/ptr_arg.rs:15:14 |
f20569fa XL |
17 | | |
18 | LL | fn do_str(x: &String) { | |
19 | | ^^^^^^^ help: change this to: `&str` | |
20 | ||
5099ac24 FG |
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 | |
23 | | | |
24 | LL | fn do_str_mut(x: &mut String) { | |
25 | | ^^^^^^^^^^^ help: change this to: `&mut str` | |
26 | ||
f20569fa | 27 | error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do |
5099ac24 | 28 | --> $DIR/ptr_arg.rs:23:15 |
f20569fa XL |
29 | | |
30 | LL | fn do_path(x: &PathBuf) { | |
31 | | ^^^^^^^^ help: change this to: `&Path` | |
32 | ||
5099ac24 FG |
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 | |
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:35:18 | |
f20569fa XL |
41 | | |
42 | LL | fn do_vec(x: &Vec<i64>); | |
43 | | ^^^^^^^^^ help: change this to: `&[i64]` | |
44 | ||
5099ac24 FG |
45 | error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do |
46 | --> $DIR/ptr_arg.rs:48:14 | |
f20569fa XL |
47 | | |
48 | LL | fn cloned(x: &Vec<u8>) -> Vec<u8> { | |
49 | | ^^^^^^^^ | |
50 | | | |
51 | help: change this to | |
52 | | | |
5099ac24 FG |
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(); | |
923072b8 FG |
59 | LL ~ x.to_owned() |
60 | | | |
f20569fa XL |
61 | |
62 | error: writing `&String` instead of `&str` involves a new object where a slice will do | |
5099ac24 | 63 | --> $DIR/ptr_arg.rs:57:18 |
f20569fa XL |
64 | | |
65 | LL | fn str_cloned(x: &String) -> String { | |
66 | | ^^^^^^^ | |
67 | | | |
68 | help: change this to | |
69 | | | |
5099ac24 FG |
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() | |
f20569fa XL |
76 | | |
77 | ||
78 | error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do | |
5099ac24 | 79 | --> $DIR/ptr_arg.rs:65:19 |
f20569fa XL |
80 | | |
81 | LL | fn path_cloned(x: &PathBuf) -> PathBuf { | |
82 | | ^^^^^^^^ | |
83 | | | |
84 | help: change this to | |
85 | | | |
5099ac24 FG |
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() | |
f20569fa XL |
92 | | |
93 | ||
94 | error: writing `&String` instead of `&str` involves a new object where a slice will do | |
5099ac24 | 95 | --> $DIR/ptr_arg.rs:73:44 |
f20569fa XL |
96 | | |
97 | LL | fn false_positive_capacity(x: &Vec<u8>, y: &String) { | |
98 | | ^^^^^^^ | |
99 | | | |
100 | help: change this to | |
101 | | | |
5099ac24 FG |
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; | |
f20569fa | 106 | | |
f20569fa XL |
107 | |
108 | error: using a reference to `Cow` is not recommended | |
5099ac24 | 109 | --> $DIR/ptr_arg.rs:87:25 |
f20569fa XL |
110 | | |
111 | LL | fn test_cow_with_ref(c: &Cow<[i32]>) {} | |
112 | | ^^^^^^^^^^^ help: change this to: `&[i32]` | |
113 | ||
5099ac24 FG |
114 | error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do |
115 | --> $DIR/ptr_arg.rs:140:21 | |
f20569fa XL |
116 | | |
117 | LL | fn foo_vec(vec: &Vec<u8>) { | |
118 | | ^^^^^^^^ | |
119 | | | |
120 | help: change this to | |
121 | | | |
5099ac24 FG |
122 | LL ~ fn foo_vec(vec: &[u8]) { |
123 | LL ~ let _ = vec.to_owned().pop(); | |
124 | LL ~ let _ = vec.to_owned().clone(); | |
f20569fa | 125 | | |
f20569fa XL |
126 | |
127 | error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do | |
5099ac24 | 128 | --> $DIR/ptr_arg.rs:145:23 |
f20569fa XL |
129 | | |
130 | LL | fn foo_path(path: &PathBuf) { | |
131 | | ^^^^^^^^ | |
132 | | | |
133 | help: change this to | |
134 | | | |
5099ac24 FG |
135 | LL ~ fn foo_path(path: &Path) { |
136 | LL ~ let _ = path.to_path_buf().pop(); | |
137 | LL ~ let _ = path.to_path_buf().clone(); | |
f20569fa | 138 | | |
f20569fa XL |
139 | |
140 | error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do | |
5099ac24 | 141 | --> $DIR/ptr_arg.rs:150:21 |
f20569fa XL |
142 | | |
143 | LL | fn foo_str(str: &PathBuf) { | |
144 | | ^^^^^^^^ | |
145 | | | |
146 | help: change this to | |
147 | | | |
5099ac24 FG |
148 | LL ~ fn foo_str(str: &Path) { |
149 | LL ~ let _ = str.to_path_buf().pop(); | |
150 | LL ~ let _ = str.to_path_buf().clone(); | |
f20569fa | 151 | | |
5099ac24 FG |
152 | |
153 | error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do | |
154 | --> $DIR/ptr_arg.rs:156:29 | |
f20569fa | 155 | | |
5099ac24 FG |
156 | LL | fn mut_vec_slice_methods(v: &mut Vec<u32>) { |
157 | | ^^^^^^^^^^^^^ help: change this to: `&mut [u32]` | |
f20569fa | 158 | |
5099ac24 | 159 | error: aborting due to 16 previous errors |
f20569fa | 160 |