]> git.lizzy.rs Git - rust.git/blob - src/test/ui/cast/fat-ptr-cast.stderr
Rollup merge of #97066 - petrochenkov:nofragkind, r=camelid
[rust.git] / src / test / ui / cast / fat-ptr-cast.stderr
1 error[E0606]: casting `&[i32]` as `usize` is invalid
2   --> $DIR/fat-ptr-cast.rs:10:5
3    |
4 LL |     a as usize;
5    |     ^^^^^^^^^^
6    |
7    = help: cast through a raw pointer first
8
9 error[E0606]: casting `&[i32]` as `isize` is invalid
10   --> $DIR/fat-ptr-cast.rs:11:5
11    |
12 LL |     a as isize;
13    |     ^^^^^^^^^^
14    |
15    = help: cast through a raw pointer first
16
17 error[E0606]: casting `&[i32]` as `i16` is invalid
18   --> $DIR/fat-ptr-cast.rs:12:5
19    |
20 LL |     a as i16;
21    |     ^^^^^^^^
22    |
23    = help: cast through a raw pointer first
24
25 error[E0606]: casting `&[i32]` as `u32` is invalid
26   --> $DIR/fat-ptr-cast.rs:13:5
27    |
28 LL |     a as u32;
29    |     ^^^^^^^^
30    |
31    = help: cast through a raw pointer first
32
33 error[E0605]: non-primitive cast: `Box<[i32]>` as `usize`
34   --> $DIR/fat-ptr-cast.rs:14:5
35    |
36 LL |     b as usize;
37    |     ^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
38
39 error[E0606]: casting `*const [i32]` as `usize` is invalid
40   --> $DIR/fat-ptr-cast.rs:15:5
41    |
42 LL |     p as usize;
43    |     ^^^^^^^^^^
44    |
45    = help: cast through a thin pointer first
46
47 error[E0607]: cannot cast thin pointer `*const i32` to fat pointer `*const [i32]`
48   --> $DIR/fat-ptr-cast.rs:19:5
49    |
50 LL |     q as *const [i32];
51    |     ^^^^^^^^^^^^^^^^^
52
53 error[E0606]: cannot cast `usize` to a pointer that is wide
54   --> $DIR/fat-ptr-cast.rs:22:46
55    |
56 LL |     let t: *mut (dyn Trait + 'static) = 0 as *mut _;
57    |                                         -    ^^^^^^ creating a `*mut (dyn Trait + 'static)` requires both an address and a vtable
58    |                                         |
59    |                                         consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts`
60
61 error[E0606]: cannot cast `usize` to a pointer that is wide
62   --> $DIR/fat-ptr-cast.rs:24:37
63    |
64 LL |     let mut fail: *const str = 0 as *const str;
65    |                                -    ^^^^^^^^^^ creating a `*const str` requires both an address and a length
66    |                                |
67    |                                consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts`
68
69 error[E0606]: cannot cast `isize` to a pointer that is wide
70   --> $DIR/fat-ptr-cast.rs:26:43
71    |
72 LL |     let mut fail2: *const str = 0isize as *const str;
73    |                                 ------    ^^^^^^^^^^ creating a `*const str` requires both an address and a length
74    |                                 |
75    |                                 consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts`
76
77 error[E0606]: cannot cast `usize` to a pointer that may be wide
78   --> $DIR/fat-ptr-cast.rs:31:18
79    |
80 LL |     let s = 0 as *const T;
81    |             -    ^^^^^^^^ creating a `*const T` requires both an address and type-specific metadata
82    |             |
83    |             consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts`
84
85 error: aborting due to 11 previous errors
86
87 Some errors have detailed explanations: E0605, E0606, E0607.
88 For more information about an error, try `rustc --explain E0605`.