1 error[E0606]: casting `*const U` as `*const V` is invalid
2 --> $DIR/cast-rfc0401.rs:13:5
4 LL | u as *const V //~ ERROR is invalid
7 = note: vtable kinds may not match
9 error[E0606]: casting `*const U` as `*const str` is invalid
10 --> $DIR/cast-rfc0401.rs:18:5
12 LL | u as *const str //~ ERROR is invalid
15 = note: vtable kinds may not match
17 error[E0609]: no field `f` on type `fn() {main}`
18 --> $DIR/cast-rfc0401.rs:75:18
20 LL | let _ = main.f as *const u32; //~ ERROR no field
23 error[E0605]: non-primitive cast: `*const u8` as `&u8`
24 --> $DIR/cast-rfc0401.rs:39:13
26 LL | let _ = v as &u8; //~ ERROR non-primitive cast
29 = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
31 error[E0605]: non-primitive cast: `*const u8` as `E`
32 --> $DIR/cast-rfc0401.rs:40:13
34 LL | let _ = v as E; //~ ERROR non-primitive cast
37 = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
39 error[E0605]: non-primitive cast: `*const u8` as `fn()`
40 --> $DIR/cast-rfc0401.rs:41:13
42 LL | let _ = v as fn(); //~ ERROR non-primitive cast
45 = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
47 error[E0605]: non-primitive cast: `*const u8` as `(u32,)`
48 --> $DIR/cast-rfc0401.rs:42:13
50 LL | let _ = v as (u32,); //~ ERROR non-primitive cast
53 = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
55 error[E0605]: non-primitive cast: `std::option::Option<&*const u8>` as `*const u8`
56 --> $DIR/cast-rfc0401.rs:43:13
58 LL | let _ = Some(&v) as *const u8; //~ ERROR non-primitive cast
59 | ^^^^^^^^^^^^^^^^^^^^^
61 = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
63 error[E0606]: casting `*const u8` as `f32` is invalid
64 --> $DIR/cast-rfc0401.rs:45:13
66 LL | let _ = v as f32; //~ ERROR is invalid
69 error[E0606]: casting `fn() {main}` as `f64` is invalid
70 --> $DIR/cast-rfc0401.rs:46:13
72 LL | let _ = main as f64; //~ ERROR is invalid
75 error[E0606]: casting `&*const u8` as `usize` is invalid
76 --> $DIR/cast-rfc0401.rs:47:13
78 LL | let _ = &v as usize; //~ ERROR is invalid
81 = help: cast through a raw pointer first
83 error[E0606]: casting `f32` as `*const u8` is invalid
84 --> $DIR/cast-rfc0401.rs:48:13
86 LL | let _ = f as *const u8; //~ ERROR is invalid
89 error[E0054]: cannot cast as `bool`
90 --> $DIR/cast-rfc0401.rs:49:13
92 LL | let _ = 3_i32 as bool; //~ ERROR cannot cast
93 | ^^^^^^^^^^^^^ unsupported cast
95 = help: compare with zero instead
97 error[E0054]: cannot cast as `bool`
98 --> $DIR/cast-rfc0401.rs:50:13
100 LL | let _ = E::A as bool; //~ ERROR cannot cast
101 | ^^^^^^^^^^^^ unsupported cast
103 = help: compare with zero instead
105 error[E0604]: only `u8` can be cast as `char`, not `u32`
106 --> $DIR/cast-rfc0401.rs:51:13
108 LL | let _ = 0x61u32 as char; //~ ERROR can be cast as
111 error[E0606]: casting `bool` as `f32` is invalid
112 --> $DIR/cast-rfc0401.rs:53:13
114 LL | let _ = false as f32; //~ ERROR is invalid
117 = help: cast through an integer first
119 error[E0606]: casting `E` as `f32` is invalid
120 --> $DIR/cast-rfc0401.rs:54:13
122 LL | let _ = E::A as f32; //~ ERROR is invalid
125 = help: cast through an integer first
127 error[E0606]: casting `char` as `f32` is invalid
128 --> $DIR/cast-rfc0401.rs:55:13
130 LL | let _ = 'a' as f32; //~ ERROR is invalid
133 = help: cast through an integer first
135 error[E0606]: casting `bool` as `*const u8` is invalid
136 --> $DIR/cast-rfc0401.rs:57:13
138 LL | let _ = false as *const u8; //~ ERROR is invalid
141 error[E0606]: casting `E` as `*const u8` is invalid
142 --> $DIR/cast-rfc0401.rs:58:13
144 LL | let _ = E::A as *const u8; //~ ERROR is invalid
147 error[E0606]: casting `char` as `*const u8` is invalid
148 --> $DIR/cast-rfc0401.rs:59:13
150 LL | let _ = 'a' as *const u8; //~ ERROR is invalid
153 error[E0606]: casting `usize` as `*const [u8]` is invalid
154 --> $DIR/cast-rfc0401.rs:61:13
156 LL | let _ = 42usize as *const [u8]; //~ ERROR is invalid
157 | ^^^^^^^^^^^^^^^^^^^^^^
159 error[E0607]: cannot cast thin pointer `*const u8` to fat pointer `*const [u8]`
160 --> $DIR/cast-rfc0401.rs:62:13
162 LL | let _ = v as *const [u8]; //~ ERROR cannot cast
165 error[E0606]: casting `&Foo` as `*const str` is invalid
166 --> $DIR/cast-rfc0401.rs:64:13
168 LL | let _ = foo as *const str; //~ ERROR is invalid
171 error[E0606]: casting `&Foo` as `*mut str` is invalid
172 --> $DIR/cast-rfc0401.rs:65:13
174 LL | let _ = foo as *mut str; //~ ERROR is invalid
177 error[E0606]: casting `fn() {main}` as `*mut str` is invalid
178 --> $DIR/cast-rfc0401.rs:66:13
180 LL | let _ = main as *mut str; //~ ERROR is invalid
183 error[E0606]: casting `&f32` as `*mut f32` is invalid
184 --> $DIR/cast-rfc0401.rs:67:13
186 LL | let _ = &f as *mut f32; //~ ERROR is invalid
189 error[E0606]: casting `&f32` as `*const f64` is invalid
190 --> $DIR/cast-rfc0401.rs:68:13
192 LL | let _ = &f as *const f64; //~ ERROR is invalid
195 error[E0606]: casting `*const [i8]` as `usize` is invalid
196 --> $DIR/cast-rfc0401.rs:69:13
198 LL | let _ = fat_sv as usize; //~ ERROR is invalid
201 = help: cast through a thin pointer first
203 error[E0606]: casting `*const Foo` as `*const [u16]` is invalid
204 --> $DIR/cast-rfc0401.rs:78:13
206 LL | let _ = cf as *const [u16]; //~ ERROR is invalid
209 = note: vtable kinds may not match
211 error[E0606]: casting `*const Foo` as `*const Bar` is invalid
212 --> $DIR/cast-rfc0401.rs:79:13
214 LL | let _ = cf as *const Bar; //~ ERROR is invalid
217 = note: vtable kinds may not match
219 error[E0277]: the size for value values of type `[u8]` cannot be known at compilation time
220 --> $DIR/cast-rfc0401.rs:63:13
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
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`
229 error[E0277]: the size for value values of type `str` cannot be known at compilation time
230 --> $DIR/cast-rfc0401.rs:72:13
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
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`
239 error[E0606]: casting `&{float}` as `f32` is invalid
240 --> $DIR/cast-rfc0401.rs:81:30
242 LL | vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>(); //~ ERROR is invalid
243 | ^^^^^^^^ cannot cast `&{float}` as `f32`
245 help: did you mean `*s`?
246 --> $DIR/cast-rfc0401.rs:81:30
248 LL | vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>(); //~ ERROR is invalid
251 error: aborting due to 34 previous errors
253 Some errors occurred: E0054, E0277, E0604, E0605, E0606, E0607, E0609.
254 For more information about an error, try `rustc --explain E0054`.