1 error[E0606]: casting `*const U` as `*const V` is invalid
2 --> $DIR/cast-rfc0401.rs:3:5
7 = note: vtable kinds may not match
9 error[E0606]: casting `*const U` as `*const str` is invalid
10 --> $DIR/cast-rfc0401.rs:8:5
15 = note: vtable kinds may not match
17 error[E0609]: no field `f` on type `fn() {main}`
18 --> $DIR/cast-rfc0401.rs:65:18
20 LL | let _ = main.f as *const u32;
23 error[E0605]: non-primitive cast: `*const u8` as `&u8`
24 --> $DIR/cast-rfc0401.rs:29:13
26 LL | let _ = v as &u8;
27 | ^^^^^^^^ invalid cast
29 help: consider borrowing the value
31 LL - let _ = v as &u8;
35 error[E0605]: non-primitive cast: `*const u8` as `E`
36 --> $DIR/cast-rfc0401.rs:30:13
39 | ^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
41 error[E0605]: non-primitive cast: `*const u8` as `fn()`
42 --> $DIR/cast-rfc0401.rs:31:13
44 LL | let _ = v as fn();
45 | ^^^^^^^^^ invalid cast
47 error[E0605]: non-primitive cast: `*const u8` as `(u32,)`
48 --> $DIR/cast-rfc0401.rs:32:13
50 LL | let _ = v as (u32,);
51 | ^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
53 error[E0605]: non-primitive cast: `Option<&*const u8>` as `*const u8`
54 --> $DIR/cast-rfc0401.rs:33:13
56 LL | let _ = Some(&v) as *const u8;
57 | ^^^^^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
59 error[E0606]: casting `*const u8` as `f32` is invalid
60 --> $DIR/cast-rfc0401.rs:35:13
62 LL | let _ = v as f32;
65 error[E0606]: casting `fn() {main}` as `f64` is invalid
66 --> $DIR/cast-rfc0401.rs:36:13
68 LL | let _ = main as f64;
71 error[E0606]: casting `&*const u8` as `usize` is invalid
72 --> $DIR/cast-rfc0401.rs:37:13
74 LL | let _ = &v as usize;
77 = help: cast through a raw pointer first
79 error[E0606]: casting `f32` as `*const u8` is invalid
80 --> $DIR/cast-rfc0401.rs:38:13
82 LL | let _ = f as *const u8;
85 error[E0054]: cannot cast as `bool`
86 --> $DIR/cast-rfc0401.rs:39:13
88 LL | let _ = 3_i32 as bool;
89 | ^^^^^^^^^^^^^ help: compare with zero instead: `3_i32 != 0`
91 error[E0054]: cannot cast as `bool`
92 --> $DIR/cast-rfc0401.rs:40:13
94 LL | let _ = E::A as bool;
95 | ^^^^^^^^^^^^ unsupported cast
97 error[E0604]: only `u8` can be cast as `char`, not `u32`
98 --> $DIR/cast-rfc0401.rs:41:13
100 LL | let _ = 0x61u32 as char;
104 | help: try `char::from_u32` instead: `char::from_u32(0x61u32)`
106 error[E0606]: casting `bool` as `f32` is invalid
107 --> $DIR/cast-rfc0401.rs:43:13
109 LL | let _ = false as f32;
112 = help: cast through an integer first
114 error[E0606]: casting `E` as `f32` is invalid
115 --> $DIR/cast-rfc0401.rs:44:13
117 LL | let _ = E::A as f32;
120 = help: cast through an integer first
122 error[E0606]: casting `char` as `f32` is invalid
123 --> $DIR/cast-rfc0401.rs:45:13
125 LL | let _ = 'a' as f32;
128 = help: cast through an integer first
130 error[E0606]: casting `bool` as `*const u8` is invalid
131 --> $DIR/cast-rfc0401.rs:47:13
133 LL | let _ = false as *const u8;
136 error[E0606]: casting `E` as `*const u8` is invalid
137 --> $DIR/cast-rfc0401.rs:48:13
139 LL | let _ = E::A as *const u8;
142 error[E0606]: casting `char` as `*const u8` is invalid
143 --> $DIR/cast-rfc0401.rs:49:13
145 LL | let _ = 'a' as *const u8;
148 error[E0606]: cannot cast `usize` to a pointer that is wide
149 --> $DIR/cast-rfc0401.rs:51:24
151 LL | let _ = 42usize as *const [u8];
152 | ------- ^^^^^^^^^^^ creating a `*const [u8]` requires both an address and a length
154 | consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts`
156 error[E0607]: cannot cast thin pointer `*const u8` to fat pointer `*const [u8]`
157 --> $DIR/cast-rfc0401.rs:52:13
159 LL | let _ = v as *const [u8];
162 error[E0606]: casting `&dyn Foo` as `*const str` is invalid
163 --> $DIR/cast-rfc0401.rs:54:13
165 LL | let _ = foo as *const str;
168 error[E0606]: casting `&dyn Foo` as `*mut str` is invalid
169 --> $DIR/cast-rfc0401.rs:55:13
171 LL | let _ = foo as *mut str;
174 error[E0606]: casting `fn() {main}` as `*mut str` is invalid
175 --> $DIR/cast-rfc0401.rs:56:13
177 LL | let _ = main as *mut str;
180 error[E0606]: casting `&f32` as `*mut f32` is invalid
181 --> $DIR/cast-rfc0401.rs:57:13
183 LL | let _ = &f as *mut f32;
186 error[E0606]: casting `&f32` as `*const f64` is invalid
187 --> $DIR/cast-rfc0401.rs:58:13
189 LL | let _ = &f as *const f64;
192 error[E0606]: casting `*const [i8]` as `usize` is invalid
193 --> $DIR/cast-rfc0401.rs:59:13
195 LL | let _ = fat_sv as usize;
198 = help: cast through a thin pointer first
200 error[E0606]: casting `*const dyn Foo` as `*const [u16]` is invalid
201 --> $DIR/cast-rfc0401.rs:68:13
203 LL | let _ = cf as *const [u16];
206 = note: vtable kinds may not match
208 error[E0606]: casting `*const dyn Foo` as `*const dyn Bar` is invalid
209 --> $DIR/cast-rfc0401.rs:69:13
211 LL | let _ = cf as *const dyn Bar;
212 | ^^^^^^^^^^^^^^^^^^^^
214 = note: vtable kinds may not match
216 error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
217 --> $DIR/cast-rfc0401.rs:53:13
219 LL | let _ = fat_v as *const dyn Foo;
220 | ^^^^^ doesn't have a size known at compile-time
222 = help: the trait `Sized` is not implemented for `[u8]`
223 = note: required for the cast to the object type `dyn Foo`
224 help: consider borrowing the value, since `&[u8]` can be coerced into `dyn Foo`
226 LL | let _ = &fat_v as *const dyn Foo;
229 error[E0277]: the size for values of type `str` cannot be known at compilation time
230 --> $DIR/cast-rfc0401.rs:62:13
232 LL | let _ = a as *const dyn Foo;
233 | ^ doesn't have a size known at compile-time
235 = help: the trait `Sized` is not implemented for `str`
236 = note: required for the cast to the object type `dyn Foo`
237 help: consider borrowing the value, since `&str` can be coerced into `dyn Foo`
239 LL | let _ = &a as *const dyn Foo;
242 error[E0606]: casting `&{float}` as `f32` is invalid
243 --> $DIR/cast-rfc0401.rs:71:30
245 LL | vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>();
248 | cannot cast `&{float}` as `f32`
249 | help: dereference the expression: `*s`
251 error: aborting due to 34 previous errors
253 Some errors have detailed explanations: E0054, E0277, E0604, E0605, E0606, E0607, E0609.
254 For more information about an error, try `rustc --explain E0054`.