2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2018-09-25 21:51:35 +00:00
|
|
|
#![allow(dead_code)]
|
2018-08-31 13:02:01 +00:00
|
|
|
#![allow(non_upper_case_globals)]
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
const x : [isize; 4] = [1,2,3,4];
|
|
|
|
static p : isize = x[2];
|
|
|
|
const y : &'static [isize] = &[1,2,3,4];
|
|
|
|
static q : isize = y[2];
|
2012-08-09 02:41:50 +00:00
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
struct S {a: isize, b: isize}
|
2013-01-26 06:46:32 +00:00
|
|
|
|
2014-10-07 04:16:35 +00:00
|
|
|
const s : S = S {a: 10, b: 20};
|
2015-03-26 00:06:52 +00:00
|
|
|
static t : isize = s.b;
|
2012-08-09 02:41:50 +00:00
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
struct K {a: isize, b: isize, c: D}
|
|
|
|
struct D { d: isize, e: isize }
|
2013-01-26 06:46:32 +00:00
|
|
|
|
2014-10-07 04:16:35 +00:00
|
|
|
const k : K = K {a: 10, b: 20, c: D {d: 30, e: 40}};
|
2015-03-26 00:06:52 +00:00
|
|
|
static m : isize = k.c.e;
|
2012-08-28 22:54:45 +00:00
|
|
|
|
2013-02-02 03:43:17 +00:00
|
|
|
pub fn main() {
|
2014-10-15 01:07:11 +00:00
|
|
|
println!("{}", p);
|
|
|
|
println!("{}", q);
|
|
|
|
println!("{}", t);
|
2013-05-19 02:02:45 +00:00
|
|
|
assert_eq!(p, 3);
|
|
|
|
assert_eq!(q, 3);
|
|
|
|
assert_eq!(t, 20);
|
2012-10-10 04:28:04 +00:00
|
|
|
}
|