]> git.lizzy.rs Git - rust.git/blob - src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.rs
Rollup merge of #95534 - jyn514:std-mem-copy, r=joshtriplett
[rust.git] / src / test / ui / type-alias-enum-variants / incorrect-variant-form-through-alias-caught.rs
1 // Check that creating/matching on an enum variant through an alias with
2 // the wrong braced/unit form is caught as an error.
3
4 enum Enum { Braced {}, Unit, Tuple() }
5 type Alias = Enum;
6
7 fn main() {
8     Alias::Braced;
9     //~^ ERROR expected unit struct, unit variant or constant, found struct variant `Alias::Braced` [E0533]
10     let Alias::Braced = panic!();
11     //~^ ERROR expected unit struct, unit variant or constant, found struct variant `Alias::Braced` [E0533]
12     let Alias::Braced(..) = panic!();
13     //~^ ERROR expected tuple struct or tuple variant, found struct variant `Alias::Braced` [E0164]
14
15     Alias::Unit();
16     //~^ ERROR expected function, found enum variant `Alias::Unit`
17     let Alias::Unit() = panic!();
18     //~^ ERROR expected tuple struct or tuple variant, found unit variant `Alias::Unit` [E0164]
19 }