]>
git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/vector-cast-weirdness.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Issue #14893. Tests that casts from vectors don't behave strangely in the
12 // presence of the `_` type shorthand notation.
13 // Update: after a change to the way casts are done, we have more type information
14 // around and so the errors here are no longer exactly the same.
21 let x1
= X { y: [0, 0] }
;
23 // No longer a type mismatch - the `_` can be fully resolved by type inference.
24 let p1
: *const u8 = &x1
.y
as *const _
;
25 let t1
: *const [u8; 2] = &x1
.y
as *const _
;
26 let h1
: *const [u8; 2] = &x1
.y
as *const [u8; 2];
28 let mut x1
= X { y: [0, 0] }
;
30 // This is still an error since we don't allow casts from &mut [T; n] to *mut T.
31 let p1
: *mut u8 = &mut x1
.y
as *mut _
; //~ ERROR casting
32 let t1
: *mut [u8; 2] = &mut x1
.y
as *mut _
;
33 let h1
: *mut [u8; 2] = &mut x1
.y
as *mut [u8; 2];