]>
Commit | Line | Data |
---|---|---|
d9579d0f AL |
1 | // Copyright 2015 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 | ||
7453a54e SL |
11 | // aux-build:empty-struct.rs |
12 | ||
d9579d0f | 13 | |
7453a54e SL |
14 | extern crate empty_struct; |
15 | use empty_struct::XEmpty2 as XFoo; | |
16 | ||
d9579d0f AL |
17 | struct Foo; |
18 | ||
54a0048b | 19 | #[derive(PartialEq, Eq)] |
d9579d0f AL |
20 | enum Bar { |
21 | Var1, | |
22 | Var2, | |
23 | } | |
24 | ||
25 | // Use inherent and trait impls to test UFCS syntax. | |
26 | impl Foo { | |
27 | const MYBAR: Bar = Bar::Var2; | |
28 | } | |
29 | ||
30 | trait HasBar { | |
31 | const THEBAR: Bar; | |
32 | } | |
33 | ||
34 | impl HasBar for Foo { | |
35 | const THEBAR: Bar = Bar::Var1; | |
36 | } | |
37 | ||
7453a54e SL |
38 | impl HasBar for XFoo { |
39 | const THEBAR: Bar = Bar::Var1; | |
40 | } | |
41 | ||
d9579d0f AL |
42 | fn main() { |
43 | // Inherent impl | |
44 | assert!(match Bar::Var2 { | |
45 | Foo::MYBAR => true, | |
46 | _ => false, | |
47 | }); | |
48 | assert!(match Bar::Var2 { | |
49 | <Foo>::MYBAR => true, | |
50 | _ => false, | |
51 | }); | |
52 | // Trait impl | |
53 | assert!(match Bar::Var1 { | |
54 | Foo::THEBAR => true, | |
55 | _ => false, | |
56 | }); | |
57 | assert!(match Bar::Var1 { | |
58 | <Foo>::THEBAR => true, | |
59 | _ => false, | |
60 | }); | |
61 | assert!(match Bar::Var1 { | |
62 | <Foo as HasBar>::THEBAR => true, | |
63 | _ => false, | |
64 | }); | |
7453a54e SL |
65 | assert!(match Bar::Var1 { |
66 | XFoo::THEBAR => true, | |
67 | _ => false, | |
68 | }); | |
69 | assert!(match Bar::Var1 { | |
70 | <XFoo>::THEBAR => true, | |
71 | _ => false, | |
72 | }); | |
73 | assert!(match Bar::Var1 { | |
74 | <XFoo as HasBar>::THEBAR => true, | |
75 | _ => false, | |
76 | }); | |
d9579d0f | 77 | } |