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;
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:30:13
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:31:13
42 LL | let _ = v as fn();
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:32:13
50 LL | let _ = v as (u32,);
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:33:13
58 LL | let _ = Some(&v) as *const u8;
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:35:13
66 LL | let _ = v as f32;
69 error[E0606]: casting `fn() {main}` as `f64` is invalid
70 --> $DIR/cast-rfc0401.rs:36:13
72 LL | let _ = main as f64;
75 error[E0606]: casting `&*const u8` as `usize` is invalid
76 --> $DIR/cast-rfc0401.rs:37:13
78 LL | let _ = &v as usize;
81 = help: cast through a raw pointer first
83 error[E0606]: casting `f32` as `*const u8` is invalid
84 --> $DIR/cast-rfc0401.rs:38:13
86 LL | let _ = f as *const u8;
89 error[E0054]: cannot cast as `bool`
90 --> $DIR/cast-rfc0401.rs:39:13
92 LL | let _ = 3_i32 as bool;
93 | ^^^^^^^^^^^^^ help: compare with zero instead: `3_i32 != 0`
95 error[E0054]: cannot cast as `bool`
96 --> $DIR/cast-rfc0401.rs:40:13
98 LL | let _ = E::A as bool;
99 | ^^^^^^^^^^^^ unsupported cast
101 error[E0604]: only `u8` can be cast as `char`, not `u32`
102 --> $DIR/cast-rfc0401.rs:41:13
104 LL | let _ = 0x61u32 as char;
107 error[E0606]: casting `bool` as `f32` is invalid
108 --> $DIR/cast-rfc0401.rs:43:13
110 LL | let _ = false as f32;
113 = help: cast through an integer first
115 error[E0606]: casting `E` as `f32` is invalid
116 --> $DIR/cast-rfc0401.rs:44:13
118 LL | let _ = E::A as f32;
121 = help: cast through an integer first
123 error[E0606]: casting `char` as `f32` is invalid
124 --> $DIR/cast-rfc0401.rs:45:13
126 LL | let _ = 'a' as f32;
129 = help: cast through an integer first
131 error[E0606]: casting `bool` as `*const u8` is invalid
132 --> $DIR/cast-rfc0401.rs:47:13
134 LL | let _ = false as *const u8;
137 error[E0606]: casting `E` as `*const u8` is invalid
138 --> $DIR/cast-rfc0401.rs:48:13
140 LL | let _ = E::A as *const u8;
143 error[E0606]: casting `char` as `*const u8` is invalid
144 --> $DIR/cast-rfc0401.rs:49:13
146 LL | let _ = 'a' as *const u8;
149 error[E0606]: casting `usize` as `*const [u8]` is invalid
150 --> $DIR/cast-rfc0401.rs:51:13
152 LL | let _ = 42usize as *const [u8];
153 | ^^^^^^^^^^^^^^^^^^^^^^
155 error[E0607]: cannot cast thin pointer `*const u8` to fat pointer `*const [u8]`
156 --> $DIR/cast-rfc0401.rs:52:13
158 LL | let _ = v as *const [u8];
161 error[E0606]: casting `&dyn Foo` as `*const str` is invalid
162 --> $DIR/cast-rfc0401.rs:54:13
164 LL | let _ = foo as *const str;
167 error[E0606]: casting `&dyn Foo` as `*mut str` is invalid
168 --> $DIR/cast-rfc0401.rs:55:13
170 LL | let _ = foo as *mut str;
173 error[E0606]: casting `fn() {main}` as `*mut str` is invalid
174 --> $DIR/cast-rfc0401.rs:56:13
176 LL | let _ = main as *mut str;
179 error[E0606]: casting `&f32` as `*mut f32` is invalid
180 --> $DIR/cast-rfc0401.rs:57:13
182 LL | let _ = &f as *mut f32;
185 error[E0606]: casting `&f32` as `*const f64` is invalid
186 --> $DIR/cast-rfc0401.rs:58:13
188 LL | let _ = &f as *const f64;
191 error[E0606]: casting `*const [i8]` as `usize` is invalid
192 --> $DIR/cast-rfc0401.rs:59:13
194 LL | let _ = fat_sv as usize;
197 = help: cast through a thin pointer first
199 error[E0606]: casting `*const dyn Foo` as `*const [u16]` is invalid
200 --> $DIR/cast-rfc0401.rs:68:13
202 LL | let _ = cf as *const [u16];
205 = note: vtable kinds may not match
207 error[E0606]: casting `*const dyn Foo` as `*const dyn Bar` is invalid
208 --> $DIR/cast-rfc0401.rs:69:13
210 LL | let _ = cf as *const dyn Bar;
211 | ^^^^^^^^^^^^^^^^^^^^
213 = note: vtable kinds may not match
215 error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
216 --> $DIR/cast-rfc0401.rs:53:13
218 LL | let _ = fat_v as *const dyn Foo;
219 | ^^^^^ doesn't have a size known at compile-time
221 = help: the trait `std::marker::Sized` is not implemented for `[u8]`
222 = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
223 = note: required for the cast to the object type `dyn Foo`
225 error[E0277]: the size for values of type `str` cannot be known at compilation time
226 --> $DIR/cast-rfc0401.rs:62:13
228 LL | let _ = a as *const dyn Foo;
229 | ^ doesn't have a size known at compile-time
231 = help: the trait `std::marker::Sized` is not implemented for `str`
232 = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
233 = note: required for the cast to the object type `dyn Foo`
235 error[E0606]: casting `&{float}` as `f32` is invalid
236 --> $DIR/cast-rfc0401.rs:71:30
238 LL | vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>();
241 | cannot cast `&{float}` as `f32`
242 | help: dereference the expression: `*s`
244 error: aborting due to 34 previous errors
246 Some errors have detailed explanations: E0054, E0277, E0604, E0605, E0606, E0607, E0609.
247 For more information about an error, try `rustc --explain E0054`.