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