mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-27 07:03:45 +00:00
Expanded tests for enum variants with generic args.
This commit is contained in:
parent
66409e0334
commit
37e7f0a629
@ -1,34 +0,0 @@
|
||||
#![feature(irrefutable_let_patterns)]
|
||||
#![feature(type_alias_enum_variants)]
|
||||
|
||||
#![allow(irrefutable_let_patterns)]
|
||||
|
||||
enum Enum<T> { Variant(T) }
|
||||
type Alias<T> = Enum<T>;
|
||||
type AliasFixed = Enum<()>;
|
||||
|
||||
macro_rules! is_variant {
|
||||
($expr:expr) => (
|
||||
assert!(if let Enum::Variant::<()>(_) = $expr { true } else { false },
|
||||
"expr does not have correct type");
|
||||
)
|
||||
}
|
||||
|
||||
impl<T> Enum<T> {
|
||||
fn foo() {
|
||||
is_variant!(Self::Variant(()));
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
is_variant!(Enum::Variant(()));
|
||||
is_variant!(Enum::Variant::<()>(()));
|
||||
is_variant!(Enum::<()>::Variant(()));
|
||||
|
||||
is_variant!(Alias::Variant(()));
|
||||
is_variant!(Alias::<()>::Variant(()));
|
||||
|
||||
is_variant!(AliasFixed::Variant(()));
|
||||
|
||||
Enum::<()>::foo();
|
||||
}
|
55
src/test/run-pass/enum-variant-generic-args.rs
Normal file
55
src/test/run-pass/enum-variant-generic-args.rs
Normal file
@ -0,0 +1,55 @@
|
||||
#![feature(irrefutable_let_patterns)]
|
||||
#![feature(type_alias_enum_variants)]
|
||||
|
||||
#![allow(irrefutable_let_patterns)]
|
||||
|
||||
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!(@TSVariant, (_), $expr));
|
||||
(SVariant, $expr:expr) => (is_variant!(@SVariant, { v: _ }, $expr));
|
||||
(@$variant:ident, $matcher:tt, $expr:expr) => (
|
||||
assert!(if let Enum::$variant::<()> $matcher = $expr { true } else { false },
|
||||
"expr does not have correct type");
|
||||
);
|
||||
}
|
||||
|
||||
impl<T> Enum<T> {
|
||||
fn ts_variant() {
|
||||
is_variant!(TSVariant, Self::TSVariant(()));
|
||||
}
|
||||
|
||||
fn s_variant() {
|
||||
is_variant!(SVariant, Self::SVariant { v: () });
|
||||
}
|
||||
}
|
||||
|
||||
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(()));
|
||||
|
||||
Enum::<()>::ts_variant();
|
||||
|
||||
// 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: () });
|
||||
|
||||
Enum::<()>::s_variant();
|
||||
}
|
30
src/test/run-pass/type-alias-enum-variants-2.rs
Normal file
30
src/test/run-pass/type-alias-enum-variants-2.rs
Normal file
@ -0,0 +1,30 @@
|
||||
#![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));
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
#![feature(type_alias_enum_variants)]
|
||||
|
||||
enum Enum<T> { Variant(T) }
|
||||
type Alias<T> = Enum<T>;
|
||||
type AliasFixed = Enum<()>;
|
||||
|
||||
impl<T> Enum<T> {
|
||||
fn foo() {
|
||||
Self::Variant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
Self::<()>::Variant(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
Self::<()>::Variant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
//~^^ ERROR type parameters are not allowed on this type [E0109]
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
Enum::<()>::Variant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
|
||||
Alias::Variant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
Alias::<()>::Variant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
|
||||
AliasFixed::Variant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
AliasFixed::<()>::Variant(());
|
||||
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
|
||||
AliasFixed::<()>::Variant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
//~^^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-generic-args.rs:9:25
|
||||
|
|
||||
LL | Self::Variant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-generic-args.rs:11:16
|
||||
|
|
||||
LL | Self::<()>::Variant(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-generic-args.rs:13:16
|
||||
|
|
||||
LL | Self::<()>::Variant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-generic-args.rs:13:31
|
||||
|
|
||||
LL | Self::<()>::Variant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-generic-args.rs:20:27
|
||||
|
|
||||
LL | Enum::<()>::Variant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-generic-args.rs:23:22
|
||||
|
|
||||
LL | Alias::Variant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-generic-args.rs:25:28
|
||||
|
|
||||
LL | Alias::<()>::Variant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-generic-args.rs:28:27
|
||||
|
|
||||
LL | AliasFixed::Variant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0107]: wrong number of type arguments: expected 0, found 1
|
||||
--> $DIR/enum-generic-args.rs:30:18
|
||||
|
|
||||
LL | AliasFixed::<()>::Variant(());
|
||||
| ^^ unexpected type argument
|
||||
|
||||
error[E0107]: wrong number of type arguments: expected 0, found 1
|
||||
--> $DIR/enum-generic-args.rs:32:18
|
||||
|
|
||||
LL | AliasFixed::<()>::Variant::<()>(());
|
||||
| ^^ unexpected type argument
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-generic-args.rs:32:33
|
||||
|
|
||||
LL | AliasFixed::<()>::Variant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
Some errors occurred: E0107, E0109.
|
||||
For more information about an error, try `rustc --explain E0107`.
|
65
src/test/ui/enum-variant-generic-args.rs
Normal file
65
src/test/ui/enum-variant-generic-args.rs
Normal file
@ -0,0 +1,65 @@
|
||||
#![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 type parameters are not allowed on this type [E0109]
|
||||
Self::<()>::TSVariant(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
Self::<()>::TSVariant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
//~^^ ERROR type parameters are not allowed on this type [E0109]
|
||||
}
|
||||
|
||||
fn s_variant() {
|
||||
Self::SVariant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
Self::<()>::SVariant(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
Self::<()>::SVariant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
//~^^ ERROR type parameters are not allowed on this type [E0109]
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Tuple struct variant
|
||||
|
||||
Enum::<()>::TSVariant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
|
||||
Alias::TSVariant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
Alias::<()>::TSVariant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
|
||||
AliasFixed::TSVariant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
AliasFixed::<()>::TSVariant(());
|
||||
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
|
||||
AliasFixed::<()>::TSVariant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
//~^^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
|
||||
|
||||
// Struct variant
|
||||
|
||||
Enum::<()>::SVariant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
|
||||
Alias::SVariant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
Alias::<()>::SVariant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
|
||||
AliasFixed::SVariant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
AliasFixed::<()>::SVariant(());
|
||||
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
|
||||
AliasFixed::<()>::SVariant::<()>(());
|
||||
//~^ ERROR type parameters are not allowed on this type [E0109]
|
||||
//~^^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
|
||||
}
|
259
src/test/ui/enum-variant-generic-args.stderr
Normal file
259
src/test/ui/enum-variant-generic-args.stderr
Normal file
@ -0,0 +1,259 @@
|
||||
error[E0423]: expected function, found struct variant `Enum::SVariant`
|
||||
--> $DIR/enum-variant-generic-args.rs:50:5
|
||||
|
|
||||
LL | Enum::<()>::SVariant::<()>(());
|
||||
| ^^^^^^^^^^^^--------^^^^^^
|
||||
| | |
|
||||
| | did you mean `TSVariant`?
|
||||
| did you mean `Enum::SVariant { /* fields */ }`?
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-variant-generic-args.rs:9:27
|
||||
|
|
||||
LL | Self::TSVariant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-variant-generic-args.rs:11:16
|
||||
|
|
||||
LL | Self::<()>::TSVariant(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-variant-generic-args.rs:13:16
|
||||
|
|
||||
LL | Self::<()>::TSVariant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-variant-generic-args.rs:13:33
|
||||
|
|
||||
LL | Self::<()>::TSVariant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-variant-generic-args.rs:19:26
|
||||
|
|
||||
LL | Self::SVariant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0618]: expected function, found enum variant `<Self>::SVariant::<()>`
|
||||
--> $DIR/enum-variant-generic-args.rs:19:9
|
||||
|
|
||||
LL | enum Enum<T> { TSVariant(T), SVariant { v: T } }
|
||||
| ----------------- `<Self>::SVariant::<()>` defined here
|
||||
...
|
||||
LL | Self::SVariant::<()>(());
|
||||
| ^^^^^^^^^^^^^^^^^^^^----
|
||||
| |
|
||||
| call expression requires function
|
||||
help: `<Self>::SVariant::<()>` is a unit variant, you need to write it without the parenthesis
|
||||
|
|
||||
LL | <Self>::SVariant::<()>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-variant-generic-args.rs:21:16
|
||||
|
|
||||
LL | Self::<()>::SVariant(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0618]: expected function, found enum variant `<Self<()>>::SVariant`
|
||||
--> $DIR/enum-variant-generic-args.rs:21:9
|
||||
|
|
||||
LL | enum Enum<T> { TSVariant(T), SVariant { v: T } }
|
||||
| ----------------- `<Self<()>>::SVariant` defined here
|
||||
...
|
||||
LL | Self::<()>::SVariant(());
|
||||
| ^^^^^^^^^^^^^^^^^^^^----
|
||||
| |
|
||||
| call expression requires function
|
||||
help: `<Self<()>>::SVariant` is a unit variant, you need to write it without the parenthesis
|
||||
|
|
||||
LL | <Self<()>>::SVariant;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-variant-generic-args.rs:23:16
|
||||
|
|
||||
LL | Self::<()>::SVariant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-variant-generic-args.rs:23:32
|
||||
|
|
||||
LL | Self::<()>::SVariant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0618]: expected function, found enum variant `<Self<()>>::SVariant::<()>`
|
||||
--> $DIR/enum-variant-generic-args.rs:23:9
|
||||
|
|
||||
LL | enum Enum<T> { TSVariant(T), SVariant { v: T } }
|
||||
| ----------------- `<Self<()>>::SVariant::<()>` defined here
|
||||
...
|
||||
LL | Self::<()>::SVariant::<()>(());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^----
|
||||
| |
|
||||
| call expression requires function
|
||||
help: `<Self<()>>::SVariant::<()>` is a unit variant, you need to write it without the parenthesis
|
||||
|
|
||||
LL | <Self<()>>::SVariant::<()>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-variant-generic-args.rs:32:29
|
||||
|
|
||||
LL | Enum::<()>::TSVariant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-variant-generic-args.rs:35:24
|
||||
|
|
||||
LL | Alias::TSVariant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-variant-generic-args.rs:37:30
|
||||
|
|
||||
LL | Alias::<()>::TSVariant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-variant-generic-args.rs:40:29
|
||||
|
|
||||
LL | AliasFixed::TSVariant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0107]: wrong number of type arguments: expected 0, found 1
|
||||
--> $DIR/enum-variant-generic-args.rs:42:18
|
||||
|
|
||||
LL | AliasFixed::<()>::TSVariant(());
|
||||
| ^^ unexpected type argument
|
||||
|
||||
error[E0107]: wrong number of type arguments: expected 0, found 1
|
||||
--> $DIR/enum-variant-generic-args.rs:44:18
|
||||
|
|
||||
LL | AliasFixed::<()>::TSVariant::<()>(());
|
||||
| ^^ unexpected type argument
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-variant-generic-args.rs:44:35
|
||||
|
|
||||
LL | AliasFixed::<()>::TSVariant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-variant-generic-args.rs:53:23
|
||||
|
|
||||
LL | Alias::SVariant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0618]: expected function, found enum variant `<Alias>::SVariant::<()>`
|
||||
--> $DIR/enum-variant-generic-args.rs:53:5
|
||||
|
|
||||
LL | enum Enum<T> { TSVariant(T), SVariant { v: T } }
|
||||
| ----------------- `<Alias>::SVariant::<()>` defined here
|
||||
...
|
||||
LL | Alias::SVariant::<()>(());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^----
|
||||
| |
|
||||
| call expression requires function
|
||||
help: `<Alias>::SVariant::<()>` is a unit variant, you need to write it without the parenthesis
|
||||
|
|
||||
LL | <Alias>::SVariant::<()>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-variant-generic-args.rs:55:29
|
||||
|
|
||||
LL | Alias::<()>::SVariant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0618]: expected function, found enum variant `<Alias<()>>::SVariant::<()>`
|
||||
--> $DIR/enum-variant-generic-args.rs:55:5
|
||||
|
|
||||
LL | enum Enum<T> { TSVariant(T), SVariant { v: T } }
|
||||
| ----------------- `<Alias<()>>::SVariant::<()>` defined here
|
||||
...
|
||||
LL | Alias::<()>::SVariant::<()>(());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^----
|
||||
| |
|
||||
| call expression requires function
|
||||
help: `<Alias<()>>::SVariant::<()>` is a unit variant, you need to write it without the parenthesis
|
||||
|
|
||||
LL | <Alias<()>>::SVariant::<()>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-variant-generic-args.rs:58:28
|
||||
|
|
||||
LL | AliasFixed::SVariant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0618]: expected function, found enum variant `<AliasFixed>::SVariant::<()>`
|
||||
--> $DIR/enum-variant-generic-args.rs:58:5
|
||||
|
|
||||
LL | enum Enum<T> { TSVariant(T), SVariant { v: T } }
|
||||
| ----------------- `<AliasFixed>::SVariant::<()>` defined here
|
||||
...
|
||||
LL | AliasFixed::SVariant::<()>(());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^----
|
||||
| |
|
||||
| call expression requires function
|
||||
help: `<AliasFixed>::SVariant::<()>` is a unit variant, you need to write it without the parenthesis
|
||||
|
|
||||
LL | <AliasFixed>::SVariant::<()>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0107]: wrong number of type arguments: expected 0, found 1
|
||||
--> $DIR/enum-variant-generic-args.rs:60:18
|
||||
|
|
||||
LL | AliasFixed::<()>::SVariant(());
|
||||
| ^^ unexpected type argument
|
||||
|
||||
error[E0618]: expected function, found enum variant `<AliasFixed<()>>::SVariant`
|
||||
--> $DIR/enum-variant-generic-args.rs:60:5
|
||||
|
|
||||
LL | enum Enum<T> { TSVariant(T), SVariant { v: T } }
|
||||
| ----------------- `<AliasFixed<()>>::SVariant` defined here
|
||||
...
|
||||
LL | AliasFixed::<()>::SVariant(());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^----
|
||||
| |
|
||||
| call expression requires function
|
||||
help: `<AliasFixed<()>>::SVariant` is a unit variant, you need to write it without the parenthesis
|
||||
|
|
||||
LL | <AliasFixed<()>>::SVariant;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0107]: wrong number of type arguments: expected 0, found 1
|
||||
--> $DIR/enum-variant-generic-args.rs:62:18
|
||||
|
|
||||
LL | AliasFixed::<()>::SVariant::<()>(());
|
||||
| ^^ unexpected type argument
|
||||
|
||||
error[E0109]: type parameters are not allowed on this type
|
||||
--> $DIR/enum-variant-generic-args.rs:62:34
|
||||
|
|
||||
LL | AliasFixed::<()>::SVariant::<()>(());
|
||||
| ^^ type parameter not allowed
|
||||
|
||||
error[E0618]: expected function, found enum variant `<AliasFixed<()>>::SVariant::<()>`
|
||||
--> $DIR/enum-variant-generic-args.rs:62:5
|
||||
|
|
||||
LL | enum Enum<T> { TSVariant(T), SVariant { v: T } }
|
||||
| ----------------- `<AliasFixed<()>>::SVariant::<()>` defined here
|
||||
...
|
||||
LL | AliasFixed::<()>::SVariant::<()>(());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----
|
||||
| |
|
||||
| call expression requires function
|
||||
help: `<AliasFixed<()>>::SVariant::<()>` is a unit variant, you need to write it without the parenthesis
|
||||
|
|
||||
LL | <AliasFixed<()>>::SVariant::<()>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 30 previous errors
|
||||
|
||||
Some errors occurred: E0107, E0109, E0423, E0618.
|
||||
For more information about an error, try `rustc --explain E0107`.
|
10
src/test/ui/type-alias-enum-variants-panic.rs
Normal file
10
src/test/ui/type-alias-enum-variants-panic.rs
Normal file
@ -0,0 +1,10 @@
|
||||
#![feature(type_alias_enum_variants)]
|
||||
|
||||
enum Enum { Variant {} }
|
||||
type Alias = Enum;
|
||||
|
||||
fn main() {
|
||||
Alias::Variant;
|
||||
let Alias::Variant = panic!();
|
||||
let Alias::Variant(..) = panic!();
|
||||
}
|
Loading…
Reference in New Issue
Block a user