]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/issue-3601.rs
return &mut T from the arenas, not &T
[rust.git] / src / test / compile-fail / issue-3601.rs
1 // Copyright 2012-2013 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
12 struct HTMLImageData {
13     image: Option<String>
14 }
15
16 struct ElementData {
17     kind: Box<ElementKind>
18 }
19
20 enum ElementKind {
21     HTMLImageElement(HTMLImageData)
22 }
23
24 enum NodeKind {
25     Element(ElementData)
26 }
27
28 struct NodeData {
29     kind: Box<NodeKind>,
30 }
31
32 fn main() {
33     let mut id = HTMLImageData { image: None };
34     let ed = ElementData { kind: box HTMLImageElement(id) };
35     let n = NodeData {kind : box Element(ed)};
36     // n.b. span could be better
37     match n.kind {
38         box Element(ed) => match ed.kind { //~ ERROR non-exhaustive patterns
39             box HTMLImageElement(ref d) if d.image.is_some() => { true }
40         },
41         _ => fail!("WAT") //~ ERROR unreachable pattern
42     };
43 }