]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/array-slice-vec/vector-cast-weirdness.rs
1 // Issue #14893. Tests that casts from vectors don't behave strangely in the
2 // presence of the `_` type shorthand notation.
4 // Update: after a change to the way casts are done, we have more type information
5 // around and so the errors here are no longer exactly the same.
7 // Update: With PR #81479 some of the previously rejected cases are now allowed.
8 // New test cases added.
15 let x1
= X { y: [0, 0] }
;
17 // No longer a type mismatch - the `_` can be fully resolved by type inference.
18 let p1
: *const u8 = &x1
.y
as *const _
;
19 let p1
: *mut u8 = &x1
.y
as *mut _
;
20 //~^ ERROR: casting `&[u8; 2]` as `*mut u8` is invalid
21 let t1
: *const [u8; 2] = &x1
.y
as *const _
;
22 let t1
: *mut [u8; 2] = &x1
.y
as *mut _
;
23 //~^ ERROR: casting `&[u8; 2]` as `*mut [u8; 2]` is invalid
24 let h1
: *const [u8; 2] = &x1
.y
as *const [u8; 2];
25 let t1
: *mut [u8; 2] = &x1
.y
as *mut [u8; 2];
26 //~^ ERROR: casting `&[u8; 2]` as `*mut [u8; 2]` is invalid
28 let mut x1
= X { y: [0, 0] }
;
30 let p1
: *mut u8 = &mut x1
.y
as *mut _
;
31 let p2
: *const u8 = &mut x1
.y
as *const _
;
32 let t1
: *mut [u8; 2] = &mut x1
.y
as *mut _
;
33 let h1
: *mut [u8; 2] = &mut x1
.y
as *mut [u8; 2];