diff --git a/src/test/ui/type-alias-enum-variants/type-alias-enum-variants-panic.rs b/src/test/ui/type-alias-enum-variants/type-alias-enum-variants-panic.rs index c75fe6a8fd9..f474c078ba4 100644 --- a/src/test/ui/type-alias-enum-variants/type-alias-enum-variants-panic.rs +++ b/src/test/ui/type-alias-enum-variants/type-alias-enum-variants-panic.rs @@ -1,15 +1,23 @@ // ignore-tidy-linelength +// Check that creating/matching on an enum variant through an alias with +// the wrong braced/unit form is caught as an error. + #![allow(unreachable_code)] -enum Enum { Variant {} } +enum Enum { Braced {}, Unit, Tuple() } type Alias = Enum; fn main() { - Alias::Variant; - //~^ ERROR expected unit struct/variant or constant, found struct variant `::Variant` [E0533] - let Alias::Variant = panic!(); - //~^ ERROR expected unit struct/variant or constant, found struct variant `::Variant` [E0533] - let Alias::Variant(..) = panic!(); - //~^ ERROR expected tuple struct/variant, found struct variant `::Variant` [E0164] + Alias::Braced; + //~^ ERROR expected unit struct/variant or constant, found struct variant `::Braced` [E0533] + let Alias::Braced = panic!(); + //~^ ERROR expected unit struct/variant or constant, found struct variant `::Braced` [E0533] + let Alias::Braced(..) = panic!(); + //~^ ERROR expected tuple struct/variant, found struct variant `::Braced` [E0164] + + Alias::Unit(); + //~^ ERROR expected function, found enum variant `::Unit` + let Alias::Unit() = panic!(); + //~^ ERROR expected tuple struct/variant, found unit variant `::Unit` [E0164] } diff --git a/src/test/ui/type-alias-enum-variants/type-alias-enum-variants-panic.stderr b/src/test/ui/type-alias-enum-variants/type-alias-enum-variants-panic.stderr index 7a17596cd4a..fcc13c0360d 100644 --- a/src/test/ui/type-alias-enum-variants/type-alias-enum-variants-panic.stderr +++ b/src/test/ui/type-alias-enum-variants/type-alias-enum-variants-panic.stderr @@ -1,21 +1,43 @@ -error[E0533]: expected unit struct/variant or constant, found struct variant `::Variant` - --> $DIR/type-alias-enum-variants-panic.rs:9:5 +error[E0533]: expected unit struct/variant or constant, found struct variant `::Braced` + --> $DIR/type-alias-enum-variants-panic.rs:12:5 | -LL | Alias::Variant; - | ^^^^^^^^^^^^^^ +LL | Alias::Braced; + | ^^^^^^^^^^^^^ -error[E0533]: expected unit struct/variant or constant, found struct variant `::Variant` - --> $DIR/type-alias-enum-variants-panic.rs:11:9 +error[E0533]: expected unit struct/variant or constant, found struct variant `::Braced` + --> $DIR/type-alias-enum-variants-panic.rs:14:9 | -LL | let Alias::Variant = panic!(); - | ^^^^^^^^^^^^^^ +LL | let Alias::Braced = panic!(); + | ^^^^^^^^^^^^^ -error[E0164]: expected tuple struct/variant, found struct variant `::Variant` - --> $DIR/type-alias-enum-variants-panic.rs:13:9 +error[E0164]: expected tuple struct/variant, found struct variant `::Braced` + --> $DIR/type-alias-enum-variants-panic.rs:16:9 | -LL | let Alias::Variant(..) = panic!(); - | ^^^^^^^^^^^^^^^^^^ not a tuple variant or struct +LL | let Alias::Braced(..) = panic!(); + | ^^^^^^^^^^^^^^^^^ not a tuple variant or struct -error: aborting due to 3 previous errors +error[E0618]: expected function, found enum variant `::Unit` + --> $DIR/type-alias-enum-variants-panic.rs:19:5 + | +LL | enum Enum { Braced {}, Unit, Tuple() } + | ---- `::Unit` defined here +... +LL | Alias::Unit(); + | ^^^^^^^^^^^-- + | | + | call expression requires function +help: `::Unit` is a unit variant, you need to write it without the parenthesis + | +LL | ::Unit; + | ^^^^^^^^^^^^^ -For more information about this error, try `rustc --explain E0164`. +error[E0164]: expected tuple struct/variant, found unit variant `::Unit` + --> $DIR/type-alias-enum-variants-panic.rs:21:9 + | +LL | let Alias::Unit() = panic!(); + | ^^^^^^^^^^^^^ not a tuple variant or struct + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0164, E0618. +For more information about an error, try `rustc --explain E0164`.