]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/check-static-slice.rs
Imported Upstream version 1.0.0~beta.3
[rustc.git] / src / test / run-pass / check-static-slice.rs
CommitLineData
1a4d82fc
JJ
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
1a4d82fc 14
c34b1796
AL
15const aa: [isize; 3] = [1, 2, 3];
16const ab: &'static [isize; 3] = &aa;
17const ac: &'static [isize] = ab;
18const ad: &'static [isize] = &aa;
19const ae: &'static [isize; 3] = &[1, 2, 3];
20const af: &'static [isize] = &[1, 2, 3];
21
22static ca: isize = aa[0];
23static cb: isize = ab[1];
24static cc: isize = ac[2];
25static cd: isize = ad[0];
26static ce: isize = ae[1];
27static cf: isize = af[2];
1a4d82fc
JJ
28
29fn main () {
c34b1796 30 let b: &[isize] = &[1, 2, 3];
1a4d82fc
JJ
31 assert!(ac == b);
32 assert!(ad == b);
33 assert!(af == b);
34
35 assert!(ca == 1);
36 assert!(cb == 2);
37 assert!(cc == 3);
38 assert!(cd == 1);
39 assert!(ce == 2);
40 assert!(cf == 3);
41}