about summary refs log tree commit diff
path: root/src/test/ui/enum-variant-generic-args.rs
blob: dd1f5f334df1d0ee5b778241b81a61e6119437f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#![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]
}