2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2018-11-27 02:59:49 +00:00
|
|
|
|
2015-08-11 22:15:00 +00:00
|
|
|
#![deny(dead_code)]
|
|
|
|
|
|
|
|
// use different types / traits to test all combinations
|
|
|
|
|
|
|
|
trait Const {
|
|
|
|
const C: ();
|
|
|
|
}
|
|
|
|
|
|
|
|
trait StaticFn {
|
|
|
|
fn sfn();
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ConstStruct;
|
|
|
|
struct StaticFnStruct;
|
|
|
|
|
|
|
|
enum ConstEnum {}
|
|
|
|
enum StaticFnEnum {}
|
|
|
|
|
|
|
|
struct AliasedConstStruct;
|
|
|
|
struct AliasedStaticFnStruct;
|
|
|
|
|
|
|
|
enum AliasedConstEnum {}
|
|
|
|
enum AliasedStaticFnEnum {}
|
|
|
|
|
|
|
|
type AliasConstStruct = AliasedConstStruct;
|
|
|
|
type AliasStaticFnStruct = AliasedStaticFnStruct;
|
|
|
|
type AliasConstEnum = AliasedConstEnum;
|
|
|
|
type AliasStaticFnEnum = AliasedStaticFnEnum;
|
|
|
|
|
|
|
|
macro_rules! impl_Const {($($T:ident),*) => {$(
|
|
|
|
impl Const for $T {
|
|
|
|
const C: () = ();
|
|
|
|
}
|
|
|
|
)*}}
|
|
|
|
|
|
|
|
macro_rules! impl_StaticFn {($($T:ident),*) => {$(
|
|
|
|
impl StaticFn for $T {
|
|
|
|
fn sfn() {}
|
|
|
|
}
|
|
|
|
)*}}
|
|
|
|
|
|
|
|
impl_Const!(ConstStruct, ConstEnum, AliasedConstStruct, AliasedConstEnum);
|
|
|
|
impl_StaticFn!(StaticFnStruct, StaticFnEnum, AliasedStaticFnStruct, AliasedStaticFnEnum);
|
|
|
|
|
|
|
|
fn main() {
|
2023-06-12 08:55:36 +00:00
|
|
|
let () = ConstStruct::C;
|
|
|
|
let () = ConstEnum::C;
|
2015-08-11 22:15:00 +00:00
|
|
|
|
|
|
|
StaticFnStruct::sfn();
|
|
|
|
StaticFnEnum::sfn();
|
|
|
|
|
2023-06-12 08:55:36 +00:00
|
|
|
let () = AliasConstStruct::C;
|
|
|
|
let () = AliasConstEnum::C;
|
2015-08-11 22:15:00 +00:00
|
|
|
|
|
|
|
AliasStaticFnStruct::sfn();
|
|
|
|
AliasStaticFnEnum::sfn();
|
|
|
|
}
|