]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/vector-cast-weirdness.rs
da0f0f5f7c94bef708f8c783b6ec2956e9389cfc
[rust.git] / 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.
4 //
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.
10
11 // Issue #14893. Tests that casts from vectors don't behave strangely in the
12 // presence of the `_` type shorthand notation.
13
14 struct X {
15     y: [u8, ..2],
16 }
17
18 fn main() {
19     let x1 = X { y: [0, 0] };
20
21     let p1: *u8 = &x1.y as *_;  //~ ERROR mismatched types
22     let t1: *[u8, ..2] = &x1.y as *_;
23     let h1: *[u8, ..2] = &x1.y as *[u8, ..2];
24
25     let mut x1 = X { y: [0, 0] };
26
27     let p1: *mut u8 = &mut x1.y as *mut _;  //~ ERROR mismatched types
28     let t1: *mut [u8, ..2] = &mut x1.y as *mut _;
29     let h1: *mut [u8, ..2] = &mut x1.y as *mut [u8, ..2];
30 }
31