+++ /dev/null
-#![feature(type_alias_enum_variants)]
-
-#[derive(Debug, PartialEq, Eq)]
-enum Foo {
- Bar(i32),
- Baz { i: i32 },
-}
-
-type FooAlias = Foo;
-type OptionAlias = Option<i32>;
-
-impl Foo {
- fn foo() -> Self {
- Self::Bar(3)
- }
-}
-
-fn main() {
- let t = FooAlias::Bar(1);
- assert_eq!(t, Foo::Bar(1));
- let t = FooAlias::Baz { i: 2 };
- assert_eq!(t, Foo::Baz { i: 2 });
- match t {
- FooAlias::Bar(_i) => {}
- FooAlias::Baz { i } => { assert_eq!(i, 2); }
- }
- assert_eq!(Foo::foo(), Foo::Bar(3));
-
- assert_eq!(OptionAlias::Some(4), Option::Some(4));
-}
+++ /dev/null
-#![feature(type_alias_enum_variants)]
-
-#[derive(Debug, PartialEq, Eq)]
-enum Foo {
- Bar(i32),
- Baz { i: i32 },
-}
-
-type FooAlias = Foo;
-type OptionAlias = Option<i32>;
-
-impl Foo {
- fn foo() -> Self {
- Self::Bar(3)
- }
-}
-
-fn main() {
- let t = FooAlias::Bar(1);
- assert_eq!(t, Foo::Bar(1));
- let t = FooAlias::Baz { i: 2 };
- assert_eq!(t, Foo::Baz { i: 2 });
- match t {
- FooAlias::Bar(_i) => {}
- FooAlias::Baz { i } => { assert_eq!(i, 2); }
- }
- assert_eq!(Foo::foo(), Foo::Bar(3));
-
- assert_eq!(OptionAlias::Some(4), Option::Some(4));
-}
+++ /dev/null
-#![feature(type_alias_enum_variants)]
-
-enum Enum<T> { TSVariant(T), SVariant { v: T } }
-type Alias<T> = Enum<T>;
-type AliasFixed = Enum<()>;
-
-impl<T> Enum<T> {
- fn ts_variant() {
- Self::TSVariant(());
- //~^ ERROR mismatched types [E0308]
- Self::TSVariant::<()>(());
- //~^ ERROR type arguments are not allowed for this type [E0109]
- Self::<()>::TSVariant(());
- //~^ ERROR type arguments are not allowed for this type [E0109]
- //~^^ ERROR mismatched types [E0308]
- Self::<()>::TSVariant::<()>(());
- //~^ ERROR type arguments are not allowed for this type [E0109]
- //~^^ ERROR type arguments are not allowed for this type [E0109]
- }
-
- fn s_variant() {
- Self::SVariant { v: () };
- //~^ ERROR mismatched types [E0308]
- Self::SVariant::<()> { v: () };
- //~^ ERROR type arguments are not allowed for this type [E0109]
- //~^^ ERROR mismatched types [E0308]
- Self::<()>::SVariant { v: () };
- //~^ ERROR type arguments are not allowed for this type [E0109]
- //~^^ ERROR mismatched types [E0308]
- Self::<()>::SVariant::<()> { v: () };
- //~^ ERROR type arguments are not allowed for this type [E0109]
- //~^^ ERROR type arguments are not allowed for this type [E0109]
- //~^^^ ERROR mismatched types [E0308]
- }
-}
-
-fn main() {
- // Tuple struct variant
-
- Enum::<()>::TSVariant::<()>(());
- //~^ ERROR type arguments are not allowed for this type [E0109]
-
- Alias::TSVariant::<()>(());
- //~^ ERROR type arguments are not allowed for this type [E0109]
- Alias::<()>::TSVariant::<()>(());
- //~^ ERROR type arguments are not allowed for this type [E0109]
-
- AliasFixed::TSVariant::<()>(());
- //~^ ERROR type arguments are not allowed for this type [E0109]
- AliasFixed::<()>::TSVariant(());
- //~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
- AliasFixed::<()>::TSVariant::<()>(());
- //~^ ERROR type arguments are not allowed for this type [E0109]
- //~^^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
-
- // Struct variant
-
- Enum::<()>::SVariant::<()> { v: () };
- //~^ ERROR type arguments are not allowed for this type [E0109]
-
- Alias::SVariant::<()> { v: () };
- //~^ ERROR type arguments are not allowed for this type [E0109]
- Alias::<()>::SVariant::<()> { v: () };
- //~^ ERROR type arguments are not allowed for this type [E0109]
-
- AliasFixed::SVariant::<()> { v: () };
- //~^ ERROR type arguments are not allowed for this type [E0109]
- AliasFixed::<()>::SVariant { v: () };
- //~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
- AliasFixed::<()>::SVariant::<()> { v: () };
- //~^ ERROR type arguments are not allowed for this type [E0109]
- //~^^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
-}
+++ /dev/null
-error[E0308]: mismatched types
- --> $DIR/enum-variant-generic-args.rs:9:25
- |
-LL | Self::TSVariant(());
- | ^^ expected type parameter, found ()
- |
- = note: expected type `T`
- found type `()`
-
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/enum-variant-generic-args.rs:11:27
- |
-LL | Self::TSVariant::<()>(());
- | ^^ type argument not allowed
-
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/enum-variant-generic-args.rs:13:16
- |
-LL | Self::<()>::TSVariant(());
- | ^^ type argument not allowed
-
-error[E0308]: mismatched types
- --> $DIR/enum-variant-generic-args.rs:13:31
- |
-LL | Self::<()>::TSVariant(());
- | ^^ expected type parameter, found ()
- |
- = note: expected type `T`
- found type `()`
-
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/enum-variant-generic-args.rs:16:16
- |
-LL | Self::<()>::TSVariant::<()>(());
- | ^^ type argument not allowed
-
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/enum-variant-generic-args.rs:16:33
- |
-LL | Self::<()>::TSVariant::<()>(());
- | ^^ type argument not allowed
-
-error[E0308]: mismatched types
- --> $DIR/enum-variant-generic-args.rs:22:29
- |
-LL | Self::SVariant { v: () };
- | ^^ expected type parameter, found ()
- |
- = note: expected type `T`
- found type `()`
-
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/enum-variant-generic-args.rs:24:26
- |
-LL | Self::SVariant::<()> { v: () };
- | ^^ type argument not allowed
-
-error[E0308]: mismatched types
- --> $DIR/enum-variant-generic-args.rs:24:35
- |
-LL | Self::SVariant::<()> { v: () };
- | ^^ expected type parameter, found ()
- |
- = note: expected type `T`
- found type `()`
-
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/enum-variant-generic-args.rs:27:16
- |
-LL | Self::<()>::SVariant { v: () };
- | ^^ type argument not allowed
-
-error[E0308]: mismatched types
- --> $DIR/enum-variant-generic-args.rs:27:35
- |
-LL | Self::<()>::SVariant { v: () };
- | ^^ expected type parameter, found ()
- |
- = note: expected type `T`
- found type `()`
-
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/enum-variant-generic-args.rs:30:16
- |
-LL | Self::<()>::SVariant::<()> { v: () };
- | ^^ type argument not allowed
-
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/enum-variant-generic-args.rs:30:32
- |
-LL | Self::<()>::SVariant::<()> { v: () };
- | ^^ type argument not allowed
-
-error[E0308]: mismatched types
- --> $DIR/enum-variant-generic-args.rs:30:41
- |
-LL | Self::<()>::SVariant::<()> { v: () };
- | ^^ expected type parameter, found ()
- |
- = note: expected type `T`
- found type `()`
-
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/enum-variant-generic-args.rs:40:29
- |
-LL | Enum::<()>::TSVariant::<()>(());
- | ^^ type argument not allowed
-
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/enum-variant-generic-args.rs:43:24
- |
-LL | Alias::TSVariant::<()>(());
- | ^^ type argument not allowed
-
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/enum-variant-generic-args.rs:45:30
- |
-LL | Alias::<()>::TSVariant::<()>(());
- | ^^ type argument not allowed
-
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/enum-variant-generic-args.rs:48:29
- |
-LL | AliasFixed::TSVariant::<()>(());
- | ^^ type argument not allowed
-
-error[E0107]: wrong number of type arguments: expected 0, found 1
- --> $DIR/enum-variant-generic-args.rs:50:18
- |
-LL | AliasFixed::<()>::TSVariant(());
- | ^^ unexpected type argument
-
-error[E0107]: wrong number of type arguments: expected 0, found 1
- --> $DIR/enum-variant-generic-args.rs:52:18
- |
-LL | AliasFixed::<()>::TSVariant::<()>(());
- | ^^ unexpected type argument
-
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/enum-variant-generic-args.rs:52:35
- |
-LL | AliasFixed::<()>::TSVariant::<()>(());
- | ^^ type argument not allowed
-
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/enum-variant-generic-args.rs:58:28
- |
-LL | Enum::<()>::SVariant::<()> { v: () };
- | ^^ type argument not allowed
-
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/enum-variant-generic-args.rs:61:23
- |
-LL | Alias::SVariant::<()> { v: () };
- | ^^ type argument not allowed
-
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/enum-variant-generic-args.rs:63:29
- |
-LL | Alias::<()>::SVariant::<()> { v: () };
- | ^^ type argument not allowed
-
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/enum-variant-generic-args.rs:66:28
- |
-LL | AliasFixed::SVariant::<()> { v: () };
- | ^^ type argument not allowed
-
-error[E0107]: wrong number of type arguments: expected 0, found 1
- --> $DIR/enum-variant-generic-args.rs:68:18
- |
-LL | AliasFixed::<()>::SVariant { v: () };
- | ^^ unexpected type argument
-
-error[E0107]: wrong number of type arguments: expected 0, found 1
- --> $DIR/enum-variant-generic-args.rs:70:18
- |
-LL | AliasFixed::<()>::SVariant::<()> { v: () };
- | ^^ unexpected type argument
-
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/enum-variant-generic-args.rs:70:34
- |
-LL | AliasFixed::<()>::SVariant::<()> { v: () };
- | ^^ type argument not allowed
-
-error: aborting due to 28 previous errors
-
-Some errors have detailed explanations: E0107, E0109, E0308.
-For more information about an error, try `rustc --explain E0107`.
+++ /dev/null
-// compile-pass
-
-#![feature(type_alias_enum_variants)]
-
-enum Outer<T> {
- A(T)
-}
-
-enum Inner {
- A(i32)
-}
-
-type OuterAlias = Outer<Inner>;
-
-fn ice(x: OuterAlias) {
- // Fine
- match x {
- OuterAlias::A(Inner::A(_)) => (),
- }
- // Not fine
- match x {
- OuterAlias::A(Inner::A(y)) => (),
- }
-}
-
-fn main() {}
+++ /dev/null
-#![feature(type_alias_enum_variants)]
-pub enum Enum {
- A(usize),
-}
-
-impl Enum {
- fn foo(&self) -> () {
- match self {
- Self::A => (),
- //~^ ERROR expected unit struct/variant or constant, found tuple variant
- }
- }
-}
-
-fn main() {}
+++ /dev/null
-error[E0533]: expected unit struct/variant or constant, found tuple variant `<Self>::A`
- --> $DIR/issue-58006.rs:9:13
- |
-LL | Self::A => (),
- | ^^^^^^^
-
-error: aborting due to previous error
-
+++ /dev/null
-// run-pass
-
-#![feature(type_alias_enum_variants)]
-
-#![allow(irrefutable_let_patterns)]
-
-#[allow(dead_code)]
-enum Enum<T> { TSVariant(T), SVariant { v: T } }
-type Alias<T> = Enum<T>;
-type AliasFixed = Enum<()>;
-
-macro_rules! is_variant {
- (TSVariant, $expr:expr) => (is_variant!(@check TSVariant, (_), $expr));
- (SVariant, $expr:expr) => (is_variant!(@check SVariant, { v: _ }, $expr));
- (@check $variant:ident, $matcher:tt, $expr:expr) => (
- assert!(if let Enum::$variant::<()> $matcher = $expr { true } else { false },
- "expr does not have correct type");
- );
-}
-
-fn main() {
- // Tuple struct variant
-
- is_variant!(TSVariant, Enum::TSVariant(()));
- is_variant!(TSVariant, Enum::TSVariant::<()>(()));
- is_variant!(TSVariant, Enum::<()>::TSVariant(()));
-
- is_variant!(TSVariant, Alias::TSVariant(()));
- is_variant!(TSVariant, Alias::<()>::TSVariant(()));
-
- is_variant!(TSVariant, AliasFixed::TSVariant(()));
-
- // Struct variant
-
- is_variant!(SVariant, Enum::SVariant { v: () });
- is_variant!(SVariant, Enum::SVariant::<()> { v: () });
- is_variant!(SVariant, Enum::<()>::SVariant { v: () });
-
- is_variant!(SVariant, Alias::SVariant { v: () });
- is_variant!(SVariant, Alias::<()>::SVariant { v: () });
-
- is_variant!(SVariant, AliasFixed::SVariant { v: () });
-}
+++ /dev/null
-// ignore-tidy-linelength
-
-#![feature(type_alias_enum_variants)]
-
-#![allow(unreachable_code)]
-
-enum Enum { Variant {} }
-type Alias = Enum;
-
-fn main() {
- Alias::Variant;
- //~^ ERROR expected unit struct/variant or constant, found struct variant `<Alias>::Variant` [E0533]
- let Alias::Variant = panic!();
- //~^ ERROR expected unit struct/variant or constant, found struct variant `<Alias>::Variant` [E0533]
- let Alias::Variant(..) = panic!();
- //~^ ERROR expected tuple struct/variant, found struct variant `<Alias>::Variant` [E0164]
-}
+++ /dev/null
-error[E0533]: expected unit struct/variant or constant, found struct variant `<Alias>::Variant`
- --> $DIR/type-alias-enum-variants-panic.rs:11:5
- |
-LL | Alias::Variant;
- | ^^^^^^^^^^^^^^
-
-error[E0533]: expected unit struct/variant or constant, found struct variant `<Alias>::Variant`
- --> $DIR/type-alias-enum-variants-panic.rs:13:9
- |
-LL | let Alias::Variant = panic!();
- | ^^^^^^^^^^^^^^
-
-error[E0164]: expected tuple struct/variant, found struct variant `<Alias>::Variant`
- --> $DIR/type-alias-enum-variants-panic.rs:15:9
- |
-LL | let Alias::Variant(..) = panic!();
- | ^^^^^^^^^^^^^^^^^^ not a tuple variant or struct
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0164`.
+++ /dev/null
-#![feature(type_alias_enum_variants)]
-
-enum E {
- V(u8)
-}
-
-impl E {
- fn V() {}
-}
-
-fn main() {
- <E>::V(); //~ ERROR this function takes 1 parameter but 0 parameters were supplied
-}
+++ /dev/null
-error[E0061]: this function takes 1 parameter but 0 parameters were supplied
- --> $DIR/type-alias-enum-variants-priority-2.rs:12:5
- |
-LL | V(u8)
- | ----- defined here
-...
-LL | <E>::V();
- | ^^^^^^^^ expected 1 parameter
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0061`.
+++ /dev/null
-#![feature(type_alias_enum_variants)]
-
-enum E {
- V
-}
-
-fn check() -> <E>::V {}
-//~^ ERROR expected type, found variant `V`
-
-fn main() {}
+++ /dev/null
-error: expected type, found variant `V`
- --> $DIR/type-alias-enum-variants-priority-3.rs:7:15
- |
-LL | fn check() -> <E>::V {}
- | ^^^^^^
-
-error: aborting due to previous error
-
+++ /dev/null
-#![feature(type_alias_enum_variants)]
-
-enum E {
- V
-}
-
-trait Tr {
- type V;
- fn f() -> Self::V;
-}
-
-impl Tr for E {
- type V = u8;
- fn f() -> Self::V { 0 }
- //~^ ERROR ambiguous associated item
- //~| WARN this was previously accepted
-}
-
-fn main() {}
+++ /dev/null
-error: ambiguous associated item
- --> $DIR/type-alias-enum-variants-priority.rs:14:15
- |
-LL | fn f() -> Self::V { 0 }
- | ^^^^^^^ help: use fully-qualified syntax: `<E as Trait>::V`
- |
- = note: #[deny(ambiguous_associated_items)] on by default
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #57644 <https://github.com/rust-lang/rust/issues/57644>
-note: `V` could refer to variant defined here
- --> $DIR/type-alias-enum-variants-priority.rs:4:5
- |
-LL | V
- | ^
-note: `V` could also refer to associated type defined here
- --> $DIR/type-alias-enum-variants-priority.rs:8:5
- |
-LL | type V;
- | ^^^^^^^
-
-error: aborting due to previous error
-
+++ /dev/null
-#![feature(type_alias_enum_variants)]
-
-type Alias<T> = Option<T>;
-
-fn main() {
- let _ = Option::<u8>::None; // OK
- let _ = Option::None::<u8>; // OK (Lint in future!)
- let _ = Alias::<u8>::None; // OK
- let _ = Alias::None::<u8>; // Error
- //~^ type arguments are not allowed for this type
-}
+++ /dev/null
-error[E0109]: type arguments are not allowed for this type
- --> $DIR/type-alias-enum-variants.rs:9:27
- |
-LL | let _ = Alias::None::<u8>; // Error
- | ^^ type argument not allowed
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0109`.
--- /dev/null
+// run-pass
+
+#![allow(irrefutable_let_patterns)]
+
+#[allow(dead_code)]
+enum Enum<T> { TSVariant(T), SVariant { v: T } }
+type Alias<T> = Enum<T>;
+type AliasFixed = Enum<()>;
+
+macro_rules! is_variant {
+ (TSVariant, $expr:expr) => (is_variant!(@check TSVariant, (_), $expr));
+ (SVariant, $expr:expr) => (is_variant!(@check SVariant, { v: _ }, $expr));
+ (@check $variant:ident, $matcher:tt, $expr:expr) => (
+ assert!(if let Enum::$variant::<()> $matcher = $expr { true } else { false },
+ "expr does not have correct type");
+ );
+}
+
+fn main() {
+ // Tuple struct variant
+
+ is_variant!(TSVariant, Enum::TSVariant(()));
+ is_variant!(TSVariant, Enum::TSVariant::<()>(()));
+ is_variant!(TSVariant, Enum::<()>::TSVariant(()));
+
+ is_variant!(TSVariant, Alias::TSVariant(()));
+ is_variant!(TSVariant, Alias::<()>::TSVariant(()));
+
+ is_variant!(TSVariant, AliasFixed::TSVariant(()));
+
+ // Struct variant
+
+ is_variant!(SVariant, Enum::SVariant { v: () });
+ is_variant!(SVariant, Enum::SVariant::<()> { v: () });
+ is_variant!(SVariant, Enum::<()>::SVariant { v: () });
+
+ is_variant!(SVariant, Alias::SVariant { v: () });
+ is_variant!(SVariant, Alias::<()>::SVariant { v: () });
+
+ is_variant!(SVariant, AliasFixed::SVariant { v: () });
+}
--- /dev/null
+enum Enum<T> { TSVariant(T), SVariant { v: T } }
+type Alias<T> = Enum<T>;
+type AliasFixed = Enum<()>;
+
+impl<T> Enum<T> {
+ fn ts_variant() {
+ Self::TSVariant(());
+ //~^ ERROR mismatched types [E0308]
+ Self::TSVariant::<()>(());
+ //~^ ERROR type arguments are not allowed for this type [E0109]
+ Self::<()>::TSVariant(());
+ //~^ ERROR type arguments are not allowed for this type [E0109]
+ //~^^ ERROR mismatched types [E0308]
+ Self::<()>::TSVariant::<()>(());
+ //~^ ERROR type arguments are not allowed for this type [E0109]
+ //~^^ ERROR type arguments are not allowed for this type [E0109]
+ }
+
+ fn s_variant() {
+ Self::SVariant { v: () };
+ //~^ ERROR mismatched types [E0308]
+ Self::SVariant::<()> { v: () };
+ //~^ ERROR type arguments are not allowed for this type [E0109]
+ //~^^ ERROR mismatched types [E0308]
+ Self::<()>::SVariant { v: () };
+ //~^ ERROR type arguments are not allowed for this type [E0109]
+ //~^^ ERROR mismatched types [E0308]
+ Self::<()>::SVariant::<()> { v: () };
+ //~^ ERROR type arguments are not allowed for this type [E0109]
+ //~^^ ERROR type arguments are not allowed for this type [E0109]
+ //~^^^ ERROR mismatched types [E0308]
+ }
+}
+
+fn main() {
+ // Tuple struct variant
+
+ Enum::<()>::TSVariant::<()>(());
+ //~^ ERROR type arguments are not allowed for this type [E0109]
+
+ Alias::TSVariant::<()>(());
+ //~^ ERROR type arguments are not allowed for this type [E0109]
+ Alias::<()>::TSVariant::<()>(());
+ //~^ ERROR type arguments are not allowed for this type [E0109]
+
+ AliasFixed::TSVariant::<()>(());
+ //~^ ERROR type arguments are not allowed for this type [E0109]
+ AliasFixed::<()>::TSVariant(());
+ //~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
+ AliasFixed::<()>::TSVariant::<()>(());
+ //~^ ERROR type arguments are not allowed for this type [E0109]
+ //~^^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
+
+ // Struct variant
+
+ Enum::<()>::SVariant::<()> { v: () };
+ //~^ ERROR type arguments are not allowed for this type [E0109]
+
+ Alias::SVariant::<()> { v: () };
+ //~^ ERROR type arguments are not allowed for this type [E0109]
+ Alias::<()>::SVariant::<()> { v: () };
+ //~^ ERROR type arguments are not allowed for this type [E0109]
+
+ AliasFixed::SVariant::<()> { v: () };
+ //~^ ERROR type arguments are not allowed for this type [E0109]
+ AliasFixed::<()>::SVariant { v: () };
+ //~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
+ AliasFixed::<()>::SVariant::<()> { v: () };
+ //~^ ERROR type arguments are not allowed for this type [E0109]
+ //~^^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
+}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/enum-variant-generic-args.rs:7:25
+ |
+LL | Self::TSVariant(());
+ | ^^ expected type parameter, found ()
+ |
+ = note: expected type `T`
+ found type `()`
+
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/enum-variant-generic-args.rs:9:27
+ |
+LL | Self::TSVariant::<()>(());
+ | ^^ type argument not allowed
+
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/enum-variant-generic-args.rs:11:16
+ |
+LL | Self::<()>::TSVariant(());
+ | ^^ type argument not allowed
+
+error[E0308]: mismatched types
+ --> $DIR/enum-variant-generic-args.rs:11:31
+ |
+LL | Self::<()>::TSVariant(());
+ | ^^ expected type parameter, found ()
+ |
+ = note: expected type `T`
+ found type `()`
+
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/enum-variant-generic-args.rs:14:16
+ |
+LL | Self::<()>::TSVariant::<()>(());
+ | ^^ type argument not allowed
+
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/enum-variant-generic-args.rs:14:33
+ |
+LL | Self::<()>::TSVariant::<()>(());
+ | ^^ type argument not allowed
+
+error[E0308]: mismatched types
+ --> $DIR/enum-variant-generic-args.rs:20:29
+ |
+LL | Self::SVariant { v: () };
+ | ^^ expected type parameter, found ()
+ |
+ = note: expected type `T`
+ found type `()`
+
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/enum-variant-generic-args.rs:22:26
+ |
+LL | Self::SVariant::<()> { v: () };
+ | ^^ type argument not allowed
+
+error[E0308]: mismatched types
+ --> $DIR/enum-variant-generic-args.rs:22:35
+ |
+LL | Self::SVariant::<()> { v: () };
+ | ^^ expected type parameter, found ()
+ |
+ = note: expected type `T`
+ found type `()`
+
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/enum-variant-generic-args.rs:25:16
+ |
+LL | Self::<()>::SVariant { v: () };
+ | ^^ type argument not allowed
+
+error[E0308]: mismatched types
+ --> $DIR/enum-variant-generic-args.rs:25:35
+ |
+LL | Self::<()>::SVariant { v: () };
+ | ^^ expected type parameter, found ()
+ |
+ = note: expected type `T`
+ found type `()`
+
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/enum-variant-generic-args.rs:28:16
+ |
+LL | Self::<()>::SVariant::<()> { v: () };
+ | ^^ type argument not allowed
+
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/enum-variant-generic-args.rs:28:32
+ |
+LL | Self::<()>::SVariant::<()> { v: () };
+ | ^^ type argument not allowed
+
+error[E0308]: mismatched types
+ --> $DIR/enum-variant-generic-args.rs:28:41
+ |
+LL | Self::<()>::SVariant::<()> { v: () };
+ | ^^ expected type parameter, found ()
+ |
+ = note: expected type `T`
+ found type `()`
+
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/enum-variant-generic-args.rs:38:29
+ |
+LL | Enum::<()>::TSVariant::<()>(());
+ | ^^ type argument not allowed
+
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/enum-variant-generic-args.rs:41:24
+ |
+LL | Alias::TSVariant::<()>(());
+ | ^^ type argument not allowed
+
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/enum-variant-generic-args.rs:43:30
+ |
+LL | Alias::<()>::TSVariant::<()>(());
+ | ^^ type argument not allowed
+
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/enum-variant-generic-args.rs:46:29
+ |
+LL | AliasFixed::TSVariant::<()>(());
+ | ^^ type argument not allowed
+
+error[E0107]: wrong number of type arguments: expected 0, found 1
+ --> $DIR/enum-variant-generic-args.rs:48:18
+ |
+LL | AliasFixed::<()>::TSVariant(());
+ | ^^ unexpected type argument
+
+error[E0107]: wrong number of type arguments: expected 0, found 1
+ --> $DIR/enum-variant-generic-args.rs:50:18
+ |
+LL | AliasFixed::<()>::TSVariant::<()>(());
+ | ^^ unexpected type argument
+
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/enum-variant-generic-args.rs:50:35
+ |
+LL | AliasFixed::<()>::TSVariant::<()>(());
+ | ^^ type argument not allowed
+
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/enum-variant-generic-args.rs:56:28
+ |
+LL | Enum::<()>::SVariant::<()> { v: () };
+ | ^^ type argument not allowed
+
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/enum-variant-generic-args.rs:59:23
+ |
+LL | Alias::SVariant::<()> { v: () };
+ | ^^ type argument not allowed
+
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/enum-variant-generic-args.rs:61:29
+ |
+LL | Alias::<()>::SVariant::<()> { v: () };
+ | ^^ type argument not allowed
+
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/enum-variant-generic-args.rs:64:28
+ |
+LL | AliasFixed::SVariant::<()> { v: () };
+ | ^^ type argument not allowed
+
+error[E0107]: wrong number of type arguments: expected 0, found 1
+ --> $DIR/enum-variant-generic-args.rs:66:18
+ |
+LL | AliasFixed::<()>::SVariant { v: () };
+ | ^^ unexpected type argument
+
+error[E0107]: wrong number of type arguments: expected 0, found 1
+ --> $DIR/enum-variant-generic-args.rs:68:18
+ |
+LL | AliasFixed::<()>::SVariant::<()> { v: () };
+ | ^^ unexpected type argument
+
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/enum-variant-generic-args.rs:68:34
+ |
+LL | AliasFixed::<()>::SVariant::<()> { v: () };
+ | ^^ type argument not allowed
+
+error: aborting due to 28 previous errors
+
+Some errors have detailed explanations: E0107, E0109, E0308.
+For more information about an error, try `rustc --explain E0107`.
--- /dev/null
+// compile-pass
+
+enum Outer<T> {
+ A(T)
+}
+
+enum Inner {
+ A(i32)
+}
+
+type OuterAlias = Outer<Inner>;
+
+fn ice(x: OuterAlias) {
+ // Fine
+ match x {
+ OuterAlias::A(Inner::A(_)) => (),
+ }
+ // Not fine
+ match x {
+ OuterAlias::A(Inner::A(y)) => (),
+ }
+}
+
+fn main() {}
--- /dev/null
+pub enum Enum {
+ A(usize),
+}
+
+impl Enum {
+ fn foo(&self) -> () {
+ match self {
+ Self::A => (),
+ //~^ ERROR expected unit struct/variant or constant, found tuple variant
+ }
+ }
+}
+
+fn main() {}
--- /dev/null
+error[E0533]: expected unit struct/variant or constant, found tuple variant `<Self>::A`
+ --> $DIR/issue-58006.rs:8:13
+ |
+LL | Self::A => (),
+ | ^^^^^^^
+
+error: aborting due to previous error
+
// compile-pass
-#![feature(type_alias_enum_variants)]
-
enum Opt<T> {
N,
S(T),
--- /dev/null
+// ignore-tidy-linelength
+
+#![allow(unreachable_code)]
+
+enum Enum { Variant {} }
+type Alias = Enum;
+
+fn main() {
+ Alias::Variant;
+ //~^ ERROR expected unit struct/variant or constant, found struct variant `<Alias>::Variant` [E0533]
+ let Alias::Variant = panic!();
+ //~^ ERROR expected unit struct/variant or constant, found struct variant `<Alias>::Variant` [E0533]
+ let Alias::Variant(..) = panic!();
+ //~^ ERROR expected tuple struct/variant, found struct variant `<Alias>::Variant` [E0164]
+}
--- /dev/null
+error[E0533]: expected unit struct/variant or constant, found struct variant `<Alias>::Variant`
+ --> $DIR/type-alias-enum-variants-panic.rs:9:5
+ |
+LL | Alias::Variant;
+ | ^^^^^^^^^^^^^^
+
+error[E0533]: expected unit struct/variant or constant, found struct variant `<Alias>::Variant`
+ --> $DIR/type-alias-enum-variants-panic.rs:11:9
+ |
+LL | let Alias::Variant = panic!();
+ | ^^^^^^^^^^^^^^
+
+error[E0164]: expected tuple struct/variant, found struct variant `<Alias>::Variant`
+ --> $DIR/type-alias-enum-variants-panic.rs:13:9
+ |
+LL | let Alias::Variant(..) = panic!();
+ | ^^^^^^^^^^^^^^^^^^ not a tuple variant or struct
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0164`.
--- /dev/null
+// run-pass
+
+#[derive(Debug, PartialEq, Eq)]
+enum Foo {
+ Bar(i32),
+ Baz { i: i32 },
+}
+
+type FooAlias = Foo;
+type OptionAlias = Option<i32>;
+
+impl Foo {
+ fn foo() -> Self {
+ Self::Bar(3)
+ }
+}
+
+fn main() {
+ let t = FooAlias::Bar(1);
+ assert_eq!(t, Foo::Bar(1));
+ let t = FooAlias::Baz { i: 2 };
+ assert_eq!(t, Foo::Baz { i: 2 });
+ match t {
+ FooAlias::Bar(_i) => {}
+ FooAlias::Baz { i } => { assert_eq!(i, 2); }
+ }
+ assert_eq!(Foo::foo(), Foo::Bar(3));
+
+ assert_eq!(OptionAlias::Some(4), Option::Some(4));
+}
--- /dev/null
+// run-pass
+
+#[derive(Debug, PartialEq, Eq)]
+enum Foo {
+ Bar(i32),
+ Baz { i: i32 },
+}
+
+type FooAlias = Foo;
+type OptionAlias = Option<i32>;
+
+impl Foo {
+ fn foo() -> Self {
+ Self::Bar(3)
+ }
+}
+
+fn main() {
+ let t = FooAlias::Bar(1);
+ assert_eq!(t, Foo::Bar(1));
+ let t = FooAlias::Baz { i: 2 };
+ assert_eq!(t, Foo::Baz { i: 2 });
+ match t {
+ FooAlias::Bar(_i) => {}
+ FooAlias::Baz { i } => { assert_eq!(i, 2); }
+ }
+ assert_eq!(Foo::foo(), Foo::Bar(3));
+
+ assert_eq!(OptionAlias::Some(4), Option::Some(4));
+}
--- /dev/null
+enum E {
+ V(u8)
+}
+
+impl E {
+ fn V() {}
+}
+
+fn main() {
+ <E>::V(); //~ ERROR this function takes 1 parameter but 0 parameters were supplied
+}
--- /dev/null
+error[E0061]: this function takes 1 parameter but 0 parameters were supplied
+ --> $DIR/type-alias-enum-variants-priority-2.rs:10:5
+ |
+LL | V(u8)
+ | ----- defined here
+...
+LL | <E>::V();
+ | ^^^^^^^^ expected 1 parameter
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0061`.
--- /dev/null
+enum E {
+ V
+}
+
+fn check() -> <E>::V {}
+//~^ ERROR expected type, found variant `V`
+
+fn main() {}
--- /dev/null
+error: expected type, found variant `V`
+ --> $DIR/type-alias-enum-variants-priority-3.rs:5:15
+ |
+LL | fn check() -> <E>::V {}
+ | ^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+enum E {
+ V
+}
+
+trait Tr {
+ type V;
+ fn f() -> Self::V;
+}
+
+impl Tr for E {
+ type V = u8;
+ fn f() -> Self::V { 0 }
+ //~^ ERROR ambiguous associated item
+ //~| WARN this was previously accepted
+}
+
+fn main() {}
--- /dev/null
+error: ambiguous associated item
+ --> $DIR/type-alias-enum-variants-priority.rs:12:15
+ |
+LL | fn f() -> Self::V { 0 }
+ | ^^^^^^^ help: use fully-qualified syntax: `<E as Trait>::V`
+ |
+ = note: #[deny(ambiguous_associated_items)] on by default
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #57644 <https://github.com/rust-lang/rust/issues/57644>
+note: `V` could refer to variant defined here
+ --> $DIR/type-alias-enum-variants-priority.rs:2:5
+ |
+LL | V
+ | ^
+note: `V` could also refer to associated type defined here
+ --> $DIR/type-alias-enum-variants-priority.rs:6:5
+ |
+LL | type V;
+ | ^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+type Alias<T> = Option<T>;
+
+fn main() {
+ let _ = Option::<u8>::None; // OK
+ let _ = Option::None::<u8>; // OK (Lint in future!)
+ let _ = Alias::<u8>::None; // OK
+ let _ = Alias::None::<u8>; // Error
+ //~^ type arguments are not allowed for this type
+}
--- /dev/null
+error[E0109]: type arguments are not allowed for this type
+ --> $DIR/type-alias-enum-variants.rs:7:27
+ |
+LL | let _ = Alias::None::<u8>; // Error
+ | ^^ type argument not allowed
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0109`.