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