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;
34 error[E0605]: non-primitive cast: `*const u8` as `E`
35 --> $DIR/cast-rfc0401.rs:30:13
38 | ^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
40 error[E0605]: non-primitive cast: `*const u8` as `fn()`
41 --> $DIR/cast-rfc0401.rs:31:13
43 LL | let _ = v as fn();
44 | ^^^^^^^^^ invalid cast
46 error[E0605]: non-primitive cast: `*const u8` as `(u32,)`
47 --> $DIR/cast-rfc0401.rs:32:13
49 LL | let _ = v as (u32,);
50 | ^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
52 error[E0605]: non-primitive cast: `Option<&*const u8>` as `*const u8`
53 --> $DIR/cast-rfc0401.rs:33:13
55 LL | let _ = Some(&v) as *const u8;
56 | ^^^^^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
58 error[E0606]: casting `*const u8` as `f32` is invalid
59 --> $DIR/cast-rfc0401.rs:35:13
61 LL | let _ = v as f32;
64 error[E0606]: casting `fn() {main}` as `f64` is invalid
65 --> $DIR/cast-rfc0401.rs:36:13
67 LL | let _ = main as f64;
70 error[E0606]: casting `&*const u8` as `usize` is invalid
71 --> $DIR/cast-rfc0401.rs:37:13
73 LL | let _ = &v as usize;
76 = help: cast through a raw pointer first
78 error[E0606]: casting `f32` as `*const u8` is invalid
79 --> $DIR/cast-rfc0401.rs:38:13
81 LL | let _ = f as *const u8;
84 error[E0054]: cannot cast as `bool`
85 --> $DIR/cast-rfc0401.rs:39:13
87 LL | let _ = 3_i32 as bool;
88 | ^^^^^^^^^^^^^ help: compare with zero instead: `3_i32 != 0`
90 error[E0054]: cannot cast as `bool`
91 --> $DIR/cast-rfc0401.rs:40:13
93 LL | let _ = E::A as bool;
94 | ^^^^^^^^^^^^ unsupported cast
96 error[E0604]: only `u8` can be cast as `char`, not `u32`
97 --> $DIR/cast-rfc0401.rs:41:13
99 LL | let _ = 0x61u32 as char;
100 | ^^^^^^^^^^^^^^^ invalid cast
102 error[E0606]: casting `bool` as `f32` is invalid
103 --> $DIR/cast-rfc0401.rs:43:13
105 LL | let _ = false as f32;
108 = help: cast through an integer first
110 error[E0606]: casting `E` as `f32` is invalid
111 --> $DIR/cast-rfc0401.rs:44:13
113 LL | let _ = E::A as f32;
116 = help: cast through an integer first
118 error[E0606]: casting `char` as `f32` is invalid
119 --> $DIR/cast-rfc0401.rs:45:13
121 LL | let _ = 'a' as f32;
124 = help: cast through an integer first
126 error[E0606]: casting `bool` as `*const u8` is invalid
127 --> $DIR/cast-rfc0401.rs:47:13
129 LL | let _ = false as *const u8;
132 error[E0606]: casting `E` as `*const u8` is invalid
133 --> $DIR/cast-rfc0401.rs:48:13
135 LL | let _ = E::A as *const u8;
138 error[E0606]: casting `char` as `*const u8` is invalid
139 --> $DIR/cast-rfc0401.rs:49:13
141 LL | let _ = 'a' as *const u8;
144 error[E0606]: casting `usize` as `*const [u8]` is invalid
145 --> $DIR/cast-rfc0401.rs:51:13
147 LL | let _ = 42usize as *const [u8];
148 | ^^^^^^^^^^^^^^^^^^^^^^
150 error[E0607]: cannot cast thin pointer `*const u8` to fat pointer `*const [u8]`
151 --> $DIR/cast-rfc0401.rs:52:13
153 LL | let _ = v as *const [u8];
156 error[E0606]: casting `&dyn Foo` as `*const str` is invalid
157 --> $DIR/cast-rfc0401.rs:54:13
159 LL | let _ = foo as *const str;
162 error[E0606]: casting `&dyn Foo` as `*mut str` is invalid
163 --> $DIR/cast-rfc0401.rs:55:13
165 LL | let _ = foo as *mut str;
168 error[E0606]: casting `fn() {main}` as `*mut str` is invalid
169 --> $DIR/cast-rfc0401.rs:56:13
171 LL | let _ = main as *mut str;
174 error[E0606]: casting `&f32` as `*mut f32` is invalid
175 --> $DIR/cast-rfc0401.rs:57:13
177 LL | let _ = &f as *mut f32;
180 error[E0606]: casting `&f32` as `*const f64` is invalid
181 --> $DIR/cast-rfc0401.rs:58:13
183 LL | let _ = &f as *const f64;
186 error[E0606]: casting `*const [i8]` as `usize` is invalid
187 --> $DIR/cast-rfc0401.rs:59:13
189 LL | let _ = fat_sv as usize;
192 = help: cast through a thin pointer first
194 error[E0606]: casting `*const dyn Foo` as `*const [u16]` is invalid
195 --> $DIR/cast-rfc0401.rs:68:13
197 LL | let _ = cf as *const [u16];
200 = note: vtable kinds may not match
202 error[E0606]: casting `*const dyn Foo` as `*const dyn Bar` is invalid
203 --> $DIR/cast-rfc0401.rs:69:13
205 LL | let _ = cf as *const dyn Bar;
206 | ^^^^^^^^^^^^^^^^^^^^
208 = note: vtable kinds may not match
210 error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
211 --> $DIR/cast-rfc0401.rs:53:13
213 LL | let _ = fat_v as *const dyn Foo;
214 | ^^^^^ doesn't have a size known at compile-time
216 = help: the trait `Sized` is not implemented for `[u8]`
217 = note: required for the cast to the object type `dyn Foo`
219 error[E0277]: the size for values of type `str` cannot be known at compilation time
220 --> $DIR/cast-rfc0401.rs:62:13
222 LL | let _ = a as *const dyn Foo;
223 | ^ doesn't have a size known at compile-time
225 = help: the trait `Sized` is not implemented for `str`
226 = note: required for the cast to the object type `dyn Foo`
228 error[E0606]: casting `&{float}` as `f32` is invalid
229 --> $DIR/cast-rfc0401.rs:71:30
231 LL | vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>();
234 | cannot cast `&{float}` as `f32`
235 | help: dereference the expression: `*s`
237 error: aborting due to 34 previous errors
239 Some errors have detailed explanations: E0054, E0277, E0604, E0605, E0606, E0607, E0609.
240 For more information about an error, try `rustc --explain E0054`.