]> git.lizzy.rs Git - rust.git/blob - src/test/ui/mismatched_types/cast-rfc0401.stderr
f94dfd100a6f4dff17580d211659a5e2ee014fd3
[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:3:5
3    |
4 LL |     u as *const V
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:8:5
11    |
12 LL |     u as *const str
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:65:18
19    |
20 LL |     let _ = main.f as *const u32;
21    |                  ^
22
23 error[E0605]: non-primitive cast: `*const u8` as `&u8`
24   --> $DIR/cast-rfc0401.rs:29:13
25    |
26 LL |     let _ = v as &u8;
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:30:13
33    |
34 LL |     let _ = v as E;
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:31:13
41    |
42 LL |     let _ = v as fn();
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:32:13
49    |
50 LL |     let _ = v as (u32,);
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:33:13
57    |
58 LL |     let _ = Some(&v) as *const u8;
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:35:13
65    |
66 LL |     let _ = v as f32;
67    |             ^^^^^^^^
68
69 error[E0606]: casting `fn() {main}` as `f64` is invalid
70   --> $DIR/cast-rfc0401.rs:36:13
71    |
72 LL |     let _ = main as f64;
73    |             ^^^^^^^^^^^
74
75 error[E0606]: casting `&*const u8` as `usize` is invalid
76   --> $DIR/cast-rfc0401.rs:37:13
77    |
78 LL |     let _ = &v as usize;
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:38:13
85    |
86 LL |     let _ = f as *const u8;
87    |             ^^^^^^^^^^^^^^
88
89 error[E0054]: cannot cast as `bool`
90   --> $DIR/cast-rfc0401.rs:39:13
91    |
92 LL |     let _ = 3_i32 as bool;
93    |             ^^^^^^^^^^^^^ help: compare with zero instead: `3_i32 != 0`
94
95 error[E0054]: cannot cast as `bool`
96   --> $DIR/cast-rfc0401.rs:40:13
97    |
98 LL |     let _ = E::A as bool;
99    |             ^^^^^^^^^^^^ unsupported cast
100
101 error[E0604]: only `u8` can be cast as `char`, not `u32`
102   --> $DIR/cast-rfc0401.rs:41:13
103    |
104 LL |     let _ = 0x61u32 as char;
105    |             ^^^^^^^^^^^^^^^
106
107 error[E0606]: casting `bool` as `f32` is invalid
108   --> $DIR/cast-rfc0401.rs:43:13
109    |
110 LL |     let _ = false as f32;
111    |             ^^^^^^^^^^^^
112    |
113    = help: cast through an integer first
114
115 error[E0606]: casting `E` as `f32` is invalid
116   --> $DIR/cast-rfc0401.rs:44:13
117    |
118 LL |     let _ = E::A as f32;
119    |             ^^^^^^^^^^^
120    |
121    = help: cast through an integer first
122
123 error[E0606]: casting `char` as `f32` is invalid
124   --> $DIR/cast-rfc0401.rs:45:13
125    |
126 LL |     let _ = 'a' as f32;
127    |             ^^^^^^^^^^
128    |
129    = help: cast through an integer first
130
131 error[E0606]: casting `bool` as `*const u8` is invalid
132   --> $DIR/cast-rfc0401.rs:47:13
133    |
134 LL |     let _ = false as *const u8;
135    |             ^^^^^^^^^^^^^^^^^^
136
137 error[E0606]: casting `E` as `*const u8` is invalid
138   --> $DIR/cast-rfc0401.rs:48:13
139    |
140 LL |     let _ = E::A as *const u8;
141    |             ^^^^^^^^^^^^^^^^^
142
143 error[E0606]: casting `char` as `*const u8` is invalid
144   --> $DIR/cast-rfc0401.rs:49:13
145    |
146 LL |     let _ = 'a' as *const u8;
147    |             ^^^^^^^^^^^^^^^^
148
149 error[E0606]: casting `usize` as `*const [u8]` is invalid
150   --> $DIR/cast-rfc0401.rs:51:13
151    |
152 LL |     let _ = 42usize as *const [u8];
153    |             ^^^^^^^^^^^^^^^^^^^^^^
154
155 error[E0607]: cannot cast thin pointer `*const u8` to fat pointer `*const [u8]`
156   --> $DIR/cast-rfc0401.rs:52:13
157    |
158 LL |     let _ = v as *const [u8];
159    |             ^^^^^^^^^^^^^^^^
160
161 error[E0606]: casting `&dyn Foo` as `*const str` is invalid
162   --> $DIR/cast-rfc0401.rs:54:13
163    |
164 LL |     let _ = foo as *const str;
165    |             ^^^^^^^^^^^^^^^^^
166
167 error[E0606]: casting `&dyn Foo` as `*mut str` is invalid
168   --> $DIR/cast-rfc0401.rs:55:13
169    |
170 LL |     let _ = foo as *mut str;
171    |             ^^^^^^^^^^^^^^^
172
173 error[E0606]: casting `fn() {main}` as `*mut str` is invalid
174   --> $DIR/cast-rfc0401.rs:56:13
175    |
176 LL |     let _ = main as *mut str;
177    |             ^^^^^^^^^^^^^^^^
178
179 error[E0606]: casting `&f32` as `*mut f32` is invalid
180   --> $DIR/cast-rfc0401.rs:57:13
181    |
182 LL |     let _ = &f as *mut f32;
183    |             ^^^^^^^^^^^^^^
184
185 error[E0606]: casting `&f32` as `*const f64` is invalid
186   --> $DIR/cast-rfc0401.rs:58:13
187    |
188 LL |     let _ = &f as *const f64;
189    |             ^^^^^^^^^^^^^^^^
190
191 error[E0606]: casting `*const [i8]` as `usize` is invalid
192   --> $DIR/cast-rfc0401.rs:59:13
193    |
194 LL |     let _ = fat_sv as usize;
195    |             ^^^^^^^^^^^^^^^
196    |
197    = help: cast through a thin pointer first
198
199 error[E0606]: casting `*const dyn Foo` as `*const [u16]` is invalid
200   --> $DIR/cast-rfc0401.rs:68:13
201    |
202 LL |     let _ = cf as *const [u16];
203    |             ^^^^^^^^^^^^^^^^^^
204    |
205    = note: vtable kinds may not match
206
207 error[E0606]: casting `*const dyn Foo` as `*const dyn Bar` is invalid
208   --> $DIR/cast-rfc0401.rs:69:13
209    |
210 LL |     let _ = cf as *const dyn Bar;
211    |             ^^^^^^^^^^^^^^^^^^^^
212    |
213    = note: vtable kinds may not match
214
215 error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
216   --> $DIR/cast-rfc0401.rs:53:13
217    |
218 LL |     let _ = fat_v as *const dyn Foo;
219    |             ^^^^^ doesn't have a size known at compile-time
220    |
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`
224
225 error[E0277]: the size for values of type `str` cannot be known at compilation time
226   --> $DIR/cast-rfc0401.rs:62:13
227    |
228 LL |     let _ = a as *const dyn Foo;
229    |             ^ doesn't have a size known at compile-time
230    |
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`
234
235 error[E0606]: casting `&{float}` as `f32` is invalid
236   --> $DIR/cast-rfc0401.rs:71:30
237    |
238 LL |     vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>();
239    |                              -^^^^^^^
240    |                              |
241    |                              cannot cast `&{float}` as `f32`
242    |                              help: dereference the expression: `*s`
243
244 error: aborting due to 34 previous errors
245
246 Some errors have detailed explanations: E0054, E0277, E0604, E0605, E0606, E0607, E0609.
247 For more information about an error, try `rustc --explain E0054`.