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