]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/check-static-slice.rs
Imported Upstream version 1.0.0~beta
[rustc.git] / src / test / run-pass / check-static-slice.rs
1 // Copyright 2014 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 // Check that the various ways of getting to a reference to a vec (both sized
12 // and unsized) work properly.
13
14 // pretty-expanded FIXME #23616
15
16 const aa: [isize; 3] = [1, 2, 3];
17 const ab: &'static [isize; 3] = &aa;
18 const ac: &'static [isize] = ab;
19 const ad: &'static [isize] = &aa;
20 const ae: &'static [isize; 3] = &[1, 2, 3];
21 const af: &'static [isize] = &[1, 2, 3];
22
23 static ca: isize = aa[0];
24 static cb: isize = ab[1];
25 static cc: isize = ac[2];
26 static cd: isize = ad[0];
27 static ce: isize = ae[1];
28 static cf: isize = af[2];
29
30 fn main () {
31 let b: &[isize] = &[1, 2, 3];
32 assert!(ac == b);
33 assert!(ad == b);
34 assert!(af == b);
35
36 assert!(ca == 1);
37 assert!(cb == 2);
38 assert!(cc == 3);
39 assert!(cd == 1);
40 assert!(ce == 2);
41 assert!(cf == 3);
42 }