]> git.lizzy.rs Git - rust.git/blob - tests/ui/array-slice-vec/check-static-slice.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / array-slice-vec / check-static-slice.rs
1 // run-pass
2
3 // Check that the various ways of getting to a reference to a vec (both sized
4 // and unsized) work properly.
5
6
7 const AA: [isize; 3] = [1, 2, 3];
8 const AB: &'static [isize; 3] = &AA;
9 const AC: &'static [isize] = AB;
10 const AD: &'static [isize] = &AA;
11 const AE: &'static [isize; 3] = &[1, 2, 3];
12 const AF: &'static [isize] = &[1, 2, 3];
13
14 static CA: isize = AA[0];
15 static CB: isize = AB[1];
16 static CC: isize = AC[2];
17 static CD: isize = AD[0];
18 static CE: isize = AE[1];
19 static CF: isize = AF[2];
20
21 static AG: &'static isize = &AA[2];
22
23 fn main () {
24     let b: &[isize] = &[1, 2, 3];
25     assert_eq!(AC, b);
26     assert_eq!(AD, b);
27     assert_eq!(AF, b);
28     assert_eq!(*AG, 3);
29
30     assert_eq!(CA, 1);
31     assert_eq!(CB, 2);
32     assert_eq!(CC, 3);
33     assert_eq!(CD, 1);
34     assert_eq!(CE, 2);
35     assert_eq!(CF, 3);
36 }