]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/shape_intrinsic_tag_then_rec.rs
058041ff7107ea81975fa9f49f20e26eeb322b98
[rust.git] / src / test / run-pass / shape_intrinsic_tag_then_rec.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 #[feature(managed_boxes)];
12
13 // Exercises a bug in the shape code that was exposed
14 // on x86_64: when there is a enum embedded in an
15 // interior record which is then itself interior to
16 // something else, shape calculations were off.
17
18 #[deriving(Clone)]
19 enum opt_span {
20     //hack (as opposed to option), to make `span` compile
21     os_none,
22     os_some(@Span),
23 }
24
25 #[deriving(Clone)]
26 struct Span {
27     lo: uint,
28     hi: uint,
29     expanded_from: opt_span,
30 }
31
32 #[deriving(Clone)]
33 struct Spanned<T> {
34     data: T,
35     span: Span,
36 }
37
38 type ty_ = uint;
39
40 #[deriving(Clone)]
41 struct Path_ {
42     global: bool,
43     idents: Vec<~str> ,
44     types: vec!(@ty),
45 }
46
47 type path = Spanned<Path_>;
48 type ty = Spanned<ty_>;
49
50 #[deriving(Clone)]
51 struct X {
52     sp: Span,
53     path: path,
54 }
55
56 pub fn main() {
57     let sp: Span = Span {lo: 57451u, hi: 57542u, expanded_from: os_none};
58     let t: @ty = @Spanned { data: 3u, span: sp };
59     let p_: Path_ = Path_ { global: true, idents: vec!(~"hi"), types: Vec<t> };
60     let p: path = Spanned { data: p_, span: sp };
61     let x = X { sp: sp, path: p };
62     println!("{:?}", x.path.clone());
63     println!("{:?}", x.clone());
64 }