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