mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-05 21:24:12 +00:00
edafbaffb2
- Either explicitly annotate `let x: () = expr;` where `x` has unit type, or remove the unit binding to leave only `expr;` instead. - Fix disjoint-capture-in-same-closure test
60 lines
1.2 KiB
Rust
60 lines
1.2 KiB
Rust
// run-pass
|
|
|
|
#![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() {
|
|
let () = ConstStruct::C;
|
|
let () = ConstEnum::C;
|
|
|
|
StaticFnStruct::sfn();
|
|
StaticFnEnum::sfn();
|
|
|
|
let () = AliasConstStruct::C;
|
|
let () = AliasConstEnum::C;
|
|
|
|
AliasStaticFnStruct::sfn();
|
|
AliasStaticFnEnum::sfn();
|
|
}
|