]> git.lizzy.rs Git - rust.git/blob - tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr
Rollup merge of #106717 - klensy:typo, r=lcnr
[rust.git] / tests / ui / parser / issues / issue-35813-postfix-after-cast.stderr
1 error: cast cannot be followed by indexing
2   --> $DIR/issue-35813-postfix-after-cast.rs:10:5
3    |
4 LL |     vec![1, 2, 3] as Vec<i32>[0];
5    |     ^^^^^^^^^^^^^^^^^^^^^^^^^
6    |
7 help: try surrounding the expression in parentheses
8    |
9 LL |     (vec![1, 2, 3] as Vec<i32>)[0];
10    |     +                         +
11
12 error: type ascription cannot be followed by indexing
13   --> $DIR/issue-35813-postfix-after-cast.rs:12:5
14    |
15 LL |     vec![1, 2, 3]: Vec<i32>[0];
16    |     ^^^^^^^^^^^^^^^^^^^^^^^
17    |
18 help: try surrounding the expression in parentheses
19    |
20 LL |     (vec![1, 2, 3]: Vec<i32>)[0];
21    |     +                       +
22 help: alternatively, remove the type ascription
23    |
24 LL -     vec![1, 2, 3]: Vec<i32>[0];
25 LL +     vec![1, 2, 3][0];
26    |
27
28 error: cast cannot be followed by indexing
29   --> $DIR/issue-35813-postfix-after-cast.rs:17:5
30    |
31 LL |     (&[0]) as &[i32][0];
32    |     ^^^^^^^^^^^^^^^^
33    |
34 help: try surrounding the expression in parentheses
35    |
36 LL |     ((&[0]) as &[i32])[0];
37    |     +                +
38
39 error: type ascription cannot be followed by indexing
40   --> $DIR/issue-35813-postfix-after-cast.rs:19:5
41    |
42 LL |     (&[0i32]): &[i32; 1][0];
43    |     ^^^^^^^^^^^^^^^^^^^^
44    |
45 help: try surrounding the expression in parentheses
46    |
47 LL |     ((&[0i32]): &[i32; 1])[0];
48    |     +                    +
49 help: alternatively, remove the type ascription
50    |
51 LL -     (&[0i32]): &[i32; 1][0];
52 LL +     (&[0i32])[0];
53    |
54
55 error: type ascription cannot be followed by a method call
56   --> $DIR/issue-35813-postfix-after-cast.rs:39:13
57    |
58 LL |     let _ = 0i32: i32: i32.count_ones();
59    |             ^^^^^^^^^^^^^^
60    |
61 help: try surrounding the expression in parentheses
62    |
63 LL |     let _ = (0i32: i32: i32).count_ones();
64    |             +              +
65 help: alternatively, remove the type ascription
66    |
67 LL -     let _ = 0i32: i32: i32.count_ones();
68 LL +     let _ = 0i32: i32.count_ones();
69    |
70
71 error: type ascription cannot be followed by a method call
72   --> $DIR/issue-35813-postfix-after-cast.rs:41:13
73    |
74 LL |     let _ = 0 as i32: i32.count_ones();
75    |             ^^^^^^^^^^^^^
76    |
77 help: try surrounding the expression in parentheses
78    |
79 LL |     let _ = (0 as i32: i32).count_ones();
80    |             +             +
81 help: alternatively, remove the type ascription
82    |
83 LL -     let _ = 0 as i32: i32.count_ones();
84 LL +     let _ = 0 as i32.count_ones();
85    |
86
87 error: cast cannot be followed by a method call
88   --> $DIR/issue-35813-postfix-after-cast.rs:43:13
89    |
90 LL |     let _ = 0i32: i32 as i32.count_ones();
91    |             ^^^^^^^^^^^^^^^^
92    |
93 help: try surrounding the expression in parentheses
94    |
95 LL |     let _ = (0i32: i32 as i32).count_ones();
96    |             +                +
97
98 error: cast cannot be followed by a method call
99   --> $DIR/issue-35813-postfix-after-cast.rs:45:13
100    |
101 LL |     let _ = 0 as i32 as i32.count_ones();
102    |             ^^^^^^^^^^^^^^^
103    |
104 help: try surrounding the expression in parentheses
105    |
106 LL |     let _ = (0 as i32 as i32).count_ones();
107    |             +               +
108
109 error: cast cannot be followed by a method call
110   --> $DIR/issue-35813-postfix-after-cast.rs:47:13
111    |
112 LL |     let _ = 0i32: i32: i32 as u32 as i32.count_ones();
113    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
114    |
115 help: try surrounding the expression in parentheses
116    |
117 LL |     let _ = (0i32: i32: i32 as u32 as i32).count_ones();
118    |             +                            +
119
120 error: type ascription cannot be followed by a method call
121   --> $DIR/issue-35813-postfix-after-cast.rs:49:13
122    |
123 LL |     let _ = 0i32: i32.count_ones(): u32;
124    |             ^^^^^^^^^
125    |
126 help: try surrounding the expression in parentheses
127    |
128 LL |     let _ = (0i32: i32).count_ones(): u32;
129    |             +         +
130 help: alternatively, remove the type ascription
131    |
132 LL -     let _ = 0i32: i32.count_ones(): u32;
133 LL +     let _ = 0i32.count_ones(): u32;
134    |
135
136 error: cast cannot be followed by a method call
137   --> $DIR/issue-35813-postfix-after-cast.rs:51:13
138    |
139 LL |     let _ = 0 as i32.count_ones(): u32;
140    |             ^^^^^^^^
141    |
142 help: try surrounding the expression in parentheses
143    |
144 LL |     let _ = (0 as i32).count_ones(): u32;
145    |             +        +
146
147 error: type ascription cannot be followed by a method call
148   --> $DIR/issue-35813-postfix-after-cast.rs:53:13
149    |
150 LL |     let _ = 0i32: i32.count_ones() as u32;
151    |             ^^^^^^^^^
152    |
153 help: try surrounding the expression in parentheses
154    |
155 LL |     let _ = (0i32: i32).count_ones() as u32;
156    |             +         +
157 help: alternatively, remove the type ascription
158    |
159 LL -     let _ = 0i32: i32.count_ones() as u32;
160 LL +     let _ = 0i32.count_ones() as u32;
161    |
162
163 error: cast cannot be followed by a method call
164   --> $DIR/issue-35813-postfix-after-cast.rs:55:13
165    |
166 LL |     let _ = 0 as i32.count_ones() as u32;
167    |             ^^^^^^^^
168    |
169 help: try surrounding the expression in parentheses
170    |
171 LL |     let _ = (0 as i32).count_ones() as u32;
172    |             +        +
173
174 error: type ascription cannot be followed by a method call
175   --> $DIR/issue-35813-postfix-after-cast.rs:57:13
176    |
177 LL |     let _ = 0i32: i32: i32.count_ones() as u32 as i32;
178    |             ^^^^^^^^^^^^^^
179    |
180 help: try surrounding the expression in parentheses
181    |
182 LL |     let _ = (0i32: i32: i32).count_ones() as u32 as i32;
183    |             +              +
184 help: alternatively, remove the type ascription
185    |
186 LL -     let _ = 0i32: i32: i32.count_ones() as u32 as i32;
187 LL +     let _ = 0i32: i32.count_ones() as u32 as i32;
188    |
189
190 error: cast cannot be followed by a method call
191   --> $DIR/issue-35813-postfix-after-cast.rs:62:13
192    |
193 LL |       let _ = 0
194    |  _____________^
195 LL | |         as i32
196    | |______________^
197    |
198 help: try surrounding the expression in parentheses
199    |
200 LL ~     let _ = (0
201 LL ~         as i32)
202    |
203
204 error: cast cannot be followed by indexing
205   --> $DIR/issue-35813-postfix-after-cast.rs:70:18
206    |
207 LL |     let x: i32 = &vec![1, 2, 3] as &Vec<i32>[0];
208    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
209    |
210 help: try surrounding the expression in parentheses
211    |
212 LL |     let x: i32 = (&vec![1, 2, 3] as &Vec<i32>)[0];
213    |                  +                           +
214
215 error: cast cannot be followed by a method call
216   --> $DIR/issue-35813-postfix-after-cast.rs:75:5
217    |
218 LL |     0 as i32.max(0);
219    |     ^^^^^^^^
220    |
221 help: try surrounding the expression in parentheses
222    |
223 LL |     (0 as i32).max(0);
224    |     +        +
225
226 error: type ascription cannot be followed by a method call
227   --> $DIR/issue-35813-postfix-after-cast.rs:77:5
228    |
229 LL |     0: i32.max(0);
230    |     ^^^^^^
231    |
232 help: try surrounding the expression in parentheses
233    |
234 LL |     (0: i32).max(0);
235    |     +      +
236 help: alternatively, remove the type ascription
237    |
238 LL -     0: i32.max(0);
239 LL +     0.max(0);
240    |
241
242 error: cast cannot be followed by a method call
243   --> $DIR/issue-35813-postfix-after-cast.rs:92:8
244    |
245 LL |     if 5u64 as i32.max(0) == 0 {
246    |        ^^^^^^^^^^^
247    |
248 help: try surrounding the expression in parentheses
249    |
250 LL |     if (5u64 as i32).max(0) == 0 {
251    |        +           +
252
253 error: type ascription cannot be followed by a method call
254   --> $DIR/issue-35813-postfix-after-cast.rs:95:8
255    |
256 LL |     if 5u64: u64.max(0) == 0 {
257    |        ^^^^^^^^^
258    |
259 help: try surrounding the expression in parentheses
260    |
261 LL |     if (5u64: u64).max(0) == 0 {
262    |        +         +
263 help: alternatively, remove the type ascription
264    |
265 LL -     if 5u64: u64.max(0) == 0 {
266 LL +     if 5u64.max(0) == 0 {
267    |
268
269 error: cast cannot be followed by a method call
270   --> $DIR/issue-35813-postfix-after-cast.rs:102:9
271    |
272 LL |         5u64 as u32.max(0) == 0
273    |         ^^^^^^^^^^^
274    |
275 help: try surrounding the expression in parentheses
276    |
277 LL |         (5u64 as u32).max(0) == 0
278    |         +           +
279
280 error: type ascription cannot be followed by a method call
281   --> $DIR/issue-35813-postfix-after-cast.rs:106:9
282    |
283 LL |         5u64: u64.max(0) == 0
284    |         ^^^^^^^^^
285    |
286 help: try surrounding the expression in parentheses
287    |
288 LL |         (5u64: u64).max(0) == 0
289    |         +         +
290 help: alternatively, remove the type ascription
291    |
292 LL -         5u64: u64.max(0) == 0
293 LL +         5u64.max(0) == 0
294    |
295
296 error: cast cannot be followed by indexing
297   --> $DIR/issue-35813-postfix-after-cast.rs:111:24
298    |
299 LL | static bar: &[i32] = &(&[1,2,3] as &[i32][0..1]);
300    |                        ^^^^^^^^^^^^^^^^^^
301    |
302 help: try surrounding the expression in parentheses
303    |
304 LL | static bar: &[i32] = &((&[1,2,3] as &[i32])[0..1]);
305    |                        +                  +
306
307 error: type ascription cannot be followed by indexing
308   --> $DIR/issue-35813-postfix-after-cast.rs:114:25
309    |
310 LL | static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]);
311    |                         ^^^^^^^^^^^^^^^^^^^^^^
312    |
313 help: try surrounding the expression in parentheses
314    |
315 LL | static bar2: &[i32] = &((&[1i32,2,3]: &[i32; 3])[0..1]);
316    |                         +                      +
317 help: alternatively, remove the type ascription
318    |
319 LL - static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]);
320 LL + static bar2: &[i32] = &(&[1i32,2,3][0..1]);
321    |
322
323 error: cast cannot be followed by `?`
324   --> $DIR/issue-35813-postfix-after-cast.rs:119:5
325    |
326 LL |     Err(0u64) as Result<u64,u64>?;
327    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
328    |
329 help: try surrounding the expression in parentheses
330    |
331 LL |     (Err(0u64) as Result<u64,u64>)?;
332    |     +                            +
333
334 error: type ascription cannot be followed by `?`
335   --> $DIR/issue-35813-postfix-after-cast.rs:121:5
336    |
337 LL |     Err(0u64): Result<u64,u64>?;
338    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
339    |
340 help: try surrounding the expression in parentheses
341    |
342 LL |     (Err(0u64): Result<u64,u64>)?;
343    |     +                          +
344 help: alternatively, remove the type ascription
345    |
346 LL -     Err(0u64): Result<u64,u64>?;
347 LL +     Err(0u64)?;
348    |
349
350 error: cast cannot be followed by a function call
351   --> $DIR/issue-35813-postfix-after-cast.rs:145:5
352    |
353 LL |     drop as fn(u8)(0);
354    |     ^^^^^^^^^^^^^^
355    |
356 help: try surrounding the expression in parentheses
357    |
358 LL |     (drop as fn(u8))(0);
359    |     +              +
360
361 error: type ascription cannot be followed by a function call
362   --> $DIR/issue-35813-postfix-after-cast.rs:147:5
363    |
364 LL |     drop_ptr: fn(u8)(0);
365    |     ^^^^^^^^^^^^^^^^
366    |
367 help: try surrounding the expression in parentheses
368    |
369 LL |     (drop_ptr: fn(u8))(0);
370    |     +                +
371 help: alternatively, remove the type ascription
372    |
373 LL -     drop_ptr: fn(u8)(0);
374 LL +     drop_ptr(0);
375    |
376
377 error: cast cannot be followed by `.await`
378   --> $DIR/issue-35813-postfix-after-cast.rs:152:5
379    |
380 LL |     Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>.await;
381    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
382    |
383 help: try surrounding the expression in parentheses
384    |
385 LL |     (Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>).await;
386    |     +                                                     +
387
388 error: type ascription cannot be followed by `.await`
389   --> $DIR/issue-35813-postfix-after-cast.rs:155:5
390    |
391 LL |     Box::pin(noop()): Pin<Box<_>>.await;
392    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
393    |
394 help: try surrounding the expression in parentheses
395    |
396 LL |     (Box::pin(noop()): Pin<Box<_>>).await;
397    |     +                             +
398 help: alternatively, remove the type ascription
399    |
400 LL -     Box::pin(noop()): Pin<Box<_>>.await;
401 LL +     Box::pin(noop()).await;
402    |
403
404 error: cast cannot be followed by a field access
405   --> $DIR/issue-35813-postfix-after-cast.rs:167:5
406    |
407 LL |     Foo::default() as Foo.bar;
408    |     ^^^^^^^^^^^^^^^^^^^^^
409    |
410 help: try surrounding the expression in parentheses
411    |
412 LL |     (Foo::default() as Foo).bar;
413    |     +                     +
414
415 error: type ascription cannot be followed by a field access
416   --> $DIR/issue-35813-postfix-after-cast.rs:169:5
417    |
418 LL |     Foo::default(): Foo.bar;
419    |     ^^^^^^^^^^^^^^^^^^^
420    |
421 help: try surrounding the expression in parentheses
422    |
423 LL |     (Foo::default(): Foo).bar;
424    |     +                   +
425 help: alternatively, remove the type ascription
426    |
427 LL -     Foo::default(): Foo.bar;
428 LL +     Foo::default().bar;
429    |
430
431 error: cast cannot be followed by a method call
432   --> $DIR/issue-35813-postfix-after-cast.rs:84:9
433    |
434 LL |         if true { 33 } else { 44 } as i32.max(0),
435    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
436    |
437 help: try surrounding the expression in parentheses
438    |
439 LL |         (if true { 33 } else { 44 } as i32).max(0),
440    |         +                                 +
441
442 error: type ascription cannot be followed by a method call
443   --> $DIR/issue-35813-postfix-after-cast.rs:86:9
444    |
445 LL |         if true { 33 } else { 44 }: i32.max(0)
446    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
447    |
448 help: try surrounding the expression in parentheses
449    |
450 LL |         (if true { 33 } else { 44 }: i32).max(0)
451    |         +                               +
452 help: alternatively, remove the type ascription
453    |
454 LL -         if true { 33 } else { 44 }: i32.max(0)
455 LL +         if true { 33 } else { 44 }.max(0)
456    |
457
458 error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
459   --> $DIR/issue-35813-postfix-after-cast.rs:131:13
460    |
461 LL |     drop as F();
462    |             ^^^ only `Fn` traits may use parentheses
463
464 error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
465   --> $DIR/issue-35813-postfix-after-cast.rs:133:15
466    |
467 LL |     drop_ptr: F();
468    |               ^^^ only `Fn` traits may use parentheses
469
470 error: aborting due to 36 previous errors
471
472 For more information about this error, try `rustc --explain E0214`.