]> git.lizzy.rs Git - rust.git/blob - src/test/ui/mismatched_types/cast-rfc0401.stderr
Use assert_eq! in copy_from_slice
[rust.git] / src / test / ui / mismatched_types / cast-rfc0401.stderr
1 error[E0606]: casting `*const U` as `*const V` is invalid
2   --> $DIR/cast-rfc0401.rs:13:5
3    |
4 LL |     u as *const V //~ ERROR is invalid
5    |     ^^^^^^^^^^^^^
6    |
7    = note: vtable kinds may not match
8
9 error[E0606]: casting `*const U` as `*const str` is invalid
10   --> $DIR/cast-rfc0401.rs:18:5
11    |
12 LL |     u as *const str //~ ERROR is invalid
13    |     ^^^^^^^^^^^^^^^
14    |
15    = note: vtable kinds may not match
16
17 error[E0609]: no field `f` on type `fn() {main}`
18   --> $DIR/cast-rfc0401.rs:75:18
19    |
20 LL |     let _ = main.f as *const u32; //~ ERROR no field
21    |                  ^
22
23 error[E0605]: non-primitive cast: `*const u8` as `&u8`
24   --> $DIR/cast-rfc0401.rs:39:13
25    |
26 LL |     let _ = v as &u8; //~ ERROR non-primitive cast
27    |             ^^^^^^^^
28    |
29    = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
30
31 error[E0605]: non-primitive cast: `*const u8` as `E`
32   --> $DIR/cast-rfc0401.rs:40:13
33    |
34 LL |     let _ = v as E; //~ ERROR non-primitive cast
35    |             ^^^^^^
36    |
37    = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
38
39 error[E0605]: non-primitive cast: `*const u8` as `fn()`
40   --> $DIR/cast-rfc0401.rs:41:13
41    |
42 LL |     let _ = v as fn(); //~ ERROR non-primitive cast
43    |             ^^^^^^^^^
44    |
45    = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
46
47 error[E0605]: non-primitive cast: `*const u8` as `(u32,)`
48   --> $DIR/cast-rfc0401.rs:42:13
49    |
50 LL |     let _ = v as (u32,); //~ ERROR non-primitive cast
51    |             ^^^^^^^^^^^
52    |
53    = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
54
55 error[E0605]: non-primitive cast: `std::option::Option<&*const u8>` as `*const u8`
56   --> $DIR/cast-rfc0401.rs:43:13
57    |
58 LL |     let _ = Some(&v) as *const u8; //~ ERROR non-primitive cast
59    |             ^^^^^^^^^^^^^^^^^^^^^
60    |
61    = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
62
63 error[E0606]: casting `*const u8` as `f32` is invalid
64   --> $DIR/cast-rfc0401.rs:45:13
65    |
66 LL |     let _ = v as f32; //~ ERROR is invalid
67    |             ^^^^^^^^
68
69 error[E0606]: casting `fn() {main}` as `f64` is invalid
70   --> $DIR/cast-rfc0401.rs:46:13
71    |
72 LL |     let _ = main as f64; //~ ERROR is invalid
73    |             ^^^^^^^^^^^
74
75 error[E0606]: casting `&*const u8` as `usize` is invalid
76   --> $DIR/cast-rfc0401.rs:47:13
77    |
78 LL |     let _ = &v as usize; //~ ERROR is invalid
79    |             ^^^^^^^^^^^
80    |
81    = help: cast through a raw pointer first
82
83 error[E0606]: casting `f32` as `*const u8` is invalid
84   --> $DIR/cast-rfc0401.rs:48:13
85    |
86 LL |     let _ = f as *const u8; //~ ERROR is invalid
87    |             ^^^^^^^^^^^^^^
88
89 error[E0054]: cannot cast as `bool`
90   --> $DIR/cast-rfc0401.rs:49:13
91    |
92 LL |     let _ = 3_i32 as bool; //~ ERROR cannot cast
93    |             ^^^^^^^^^^^^^ unsupported cast
94    |
95    = help: compare with zero instead
96
97 error[E0054]: cannot cast as `bool`
98   --> $DIR/cast-rfc0401.rs:50:13
99    |
100 LL |     let _ = E::A as bool; //~ ERROR cannot cast
101    |             ^^^^^^^^^^^^ unsupported cast
102    |
103    = help: compare with zero instead
104
105 error[E0604]: only `u8` can be cast as `char`, not `u32`
106   --> $DIR/cast-rfc0401.rs:51:13
107    |
108 LL |     let _ = 0x61u32 as char; //~ ERROR can be cast as
109    |             ^^^^^^^^^^^^^^^
110
111 error[E0606]: casting `bool` as `f32` is invalid
112   --> $DIR/cast-rfc0401.rs:53:13
113    |
114 LL |     let _ = false as f32; //~ ERROR is invalid
115    |             ^^^^^^^^^^^^
116    |
117    = help: cast through an integer first
118
119 error[E0606]: casting `E` as `f32` is invalid
120   --> $DIR/cast-rfc0401.rs:54:13
121    |
122 LL |     let _ = E::A as f32; //~ ERROR is invalid
123    |             ^^^^^^^^^^^
124    |
125    = help: cast through an integer first
126
127 error[E0606]: casting `char` as `f32` is invalid
128   --> $DIR/cast-rfc0401.rs:55:13
129    |
130 LL |     let _ = 'a' as f32; //~ ERROR is invalid
131    |             ^^^^^^^^^^
132    |
133    = help: cast through an integer first
134
135 error[E0606]: casting `bool` as `*const u8` is invalid
136   --> $DIR/cast-rfc0401.rs:57:13
137    |
138 LL |     let _ = false as *const u8; //~ ERROR is invalid
139    |             ^^^^^^^^^^^^^^^^^^
140
141 error[E0606]: casting `E` as `*const u8` is invalid
142   --> $DIR/cast-rfc0401.rs:58:13
143    |
144 LL |     let _ = E::A as *const u8; //~ ERROR is invalid
145    |             ^^^^^^^^^^^^^^^^^
146
147 error[E0606]: casting `char` as `*const u8` is invalid
148   --> $DIR/cast-rfc0401.rs:59:13
149    |
150 LL |     let _ = 'a' as *const u8; //~ ERROR is invalid
151    |             ^^^^^^^^^^^^^^^^
152
153 error[E0606]: casting `usize` as `*const [u8]` is invalid
154   --> $DIR/cast-rfc0401.rs:61:13
155    |
156 LL |     let _ = 42usize as *const [u8]; //~ ERROR is invalid
157    |             ^^^^^^^^^^^^^^^^^^^^^^
158
159 error[E0607]: cannot cast thin pointer `*const u8` to fat pointer `*const [u8]`
160   --> $DIR/cast-rfc0401.rs:62:13
161    |
162 LL |     let _ = v as *const [u8]; //~ ERROR cannot cast
163    |             ^^^^^^^^^^^^^^^^
164
165 error[E0606]: casting `&Foo` as `*const str` is invalid
166   --> $DIR/cast-rfc0401.rs:64:13
167    |
168 LL |     let _ = foo as *const str; //~ ERROR is invalid
169    |             ^^^^^^^^^^^^^^^^^
170
171 error[E0606]: casting `&Foo` as `*mut str` is invalid
172   --> $DIR/cast-rfc0401.rs:65:13
173    |
174 LL |     let _ = foo as *mut str; //~ ERROR is invalid
175    |             ^^^^^^^^^^^^^^^
176
177 error[E0606]: casting `fn() {main}` as `*mut str` is invalid
178   --> $DIR/cast-rfc0401.rs:66:13
179    |
180 LL |     let _ = main as *mut str; //~ ERROR is invalid
181    |             ^^^^^^^^^^^^^^^^
182
183 error[E0606]: casting `&f32` as `*mut f32` is invalid
184   --> $DIR/cast-rfc0401.rs:67:13
185    |
186 LL |     let _ = &f as *mut f32; //~ ERROR is invalid
187    |             ^^^^^^^^^^^^^^
188
189 error[E0606]: casting `&f32` as `*const f64` is invalid
190   --> $DIR/cast-rfc0401.rs:68:13
191    |
192 LL |     let _ = &f as *const f64; //~ ERROR is invalid
193    |             ^^^^^^^^^^^^^^^^
194
195 error[E0606]: casting `*const [i8]` as `usize` is invalid
196   --> $DIR/cast-rfc0401.rs:69:13
197    |
198 LL |     let _ = fat_sv as usize; //~ ERROR is invalid
199    |             ^^^^^^^^^^^^^^^
200    |
201    = help: cast through a thin pointer first
202
203 error[E0606]: casting `*const Foo` as `*const [u16]` is invalid
204   --> $DIR/cast-rfc0401.rs:78:13
205    |
206 LL |     let _ = cf as *const [u16]; //~ ERROR is invalid
207    |             ^^^^^^^^^^^^^^^^^^
208    |
209    = note: vtable kinds may not match
210
211 error[E0606]: casting `*const Foo` as `*const Bar` is invalid
212   --> $DIR/cast-rfc0401.rs:79:13
213    |
214 LL |     let _ = cf as *const Bar; //~ ERROR is invalid
215    |             ^^^^^^^^^^^^^^^^
216    |
217    = note: vtable kinds may not match
218
219 error[E0277]: the size for value values of type `[u8]` cannot be known at compilation time
220   --> $DIR/cast-rfc0401.rs:63:13
221    |
222 LL |     let _ = fat_v as *const Foo; //~ ERROR the size for value values of type
223    |             ^^^^^ doesn't have a size known at compile-time
224    |
225    = help: the trait `std::marker::Sized` is not implemented for `[u8]`
226    = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
227    = note: required for the cast to the object type `Foo`
228
229 error[E0277]: the size for value values of type `str` cannot be known at compilation time
230   --> $DIR/cast-rfc0401.rs:72:13
231    |
232 LL |     let _ = a as *const Foo; //~ ERROR the size for value values of type
233    |             ^ doesn't have a size known at compile-time
234    |
235    = help: the trait `std::marker::Sized` is not implemented for `str`
236    = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types--sized>
237    = note: required for the cast to the object type `Foo`
238
239 error[E0606]: casting `&{float}` as `f32` is invalid
240   --> $DIR/cast-rfc0401.rs:81:30
241    |
242 LL |     vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>(); //~ ERROR is invalid
243    |                              ^^^^^^^^ cannot cast `&{float}` as `f32`
244    |
245 help: did you mean `*s`?
246   --> $DIR/cast-rfc0401.rs:81:30
247    |
248 LL |     vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>(); //~ ERROR is invalid
249    |                              ^
250
251 error: aborting due to 34 previous errors
252
253 Some errors occurred: E0054, E0277, E0604, E0605, E0606, E0607, E0609.
254 For more information about an error, try `rustc --explain E0054`.