]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-23808.rs
remove associated_consts feature gate
[rust.git] / src / test / run-pass / issue-23808.rs
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
11 #![deny(dead_code)]
12
13 // use different types / traits to test all combinations
14
15 trait Const {
16     const C: ();
17 }
18
19 trait StaticFn {
20     fn sfn();
21 }
22
23 struct ConstStruct;
24 struct StaticFnStruct;
25
26 enum ConstEnum {}
27 enum StaticFnEnum {}
28
29 struct AliasedConstStruct;
30 struct AliasedStaticFnStruct;
31
32 enum AliasedConstEnum {}
33 enum AliasedStaticFnEnum {}
34
35 type AliasConstStruct    = AliasedConstStruct;
36 type AliasStaticFnStruct = AliasedStaticFnStruct;
37 type AliasConstEnum      = AliasedConstEnum;
38 type AliasStaticFnEnum   = AliasedStaticFnEnum;
39
40 macro_rules! impl_Const {($($T:ident),*) => {$(
41     impl Const for $T {
42         const C: () = ();
43     }
44 )*}}
45
46 macro_rules! impl_StaticFn {($($T:ident),*) => {$(
47     impl StaticFn for $T {
48         fn sfn() {}
49     }
50 )*}}
51
52 impl_Const!(ConstStruct, ConstEnum, AliasedConstStruct, AliasedConstEnum);
53 impl_StaticFn!(StaticFnStruct, StaticFnEnum, AliasedStaticFnStruct, AliasedStaticFnEnum);
54
55 fn main() {
56     let _ = ConstStruct::C;
57     let _ = ConstEnum::C;
58
59     StaticFnStruct::sfn();
60     StaticFnEnum::sfn();
61
62     let _ = AliasConstStruct::C;
63     let _ = AliasConstEnum::C;
64
65     AliasStaticFnStruct::sfn();
66     AliasStaticFnEnum::sfn();
67 }