summaryrefslogtreecommitdiff
path: root/src/test/ui/enum-variant-generic-args.rs
blob: 2ae4b756b7c05d70094f6262380107ad6bbe048c (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
#![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 arguments are not allowed on this entity [E0109]
        Self::<()>::TSVariant(());
        //~^ ERROR type arguments are not allowed on this entity [E0109]
        Self::<()>::TSVariant::<()>(());
        //~^ ERROR type arguments are not allowed on this entity [E0109]
        //~^^ ERROR type arguments are not allowed on this entity [E0109]
    }

    fn s_variant() {
        Self::SVariant::<()>(());
        //~^ ERROR type arguments are not allowed on this entity [E0109]
        Self::<()>::SVariant(());
        //~^ ERROR type arguments are not allowed on this entity [E0109]
        Self::<()>::SVariant::<()>(());
        //~^ ERROR type arguments are not allowed on this entity [E0109]
        //~^^ ERROR type arguments are not allowed on this entity [E0109]
    }
}

fn main() {
    // Tuple struct variant

    Enum::<()>::TSVariant::<()>(());
    //~^ ERROR type arguments are not allowed on this entity [E0109]

    Alias::TSVariant::<()>(());
    //~^ ERROR type arguments are not allowed on this entity [E0109]
    Alias::<()>::TSVariant::<()>(());
    //~^ ERROR type arguments are not allowed on this entity [E0109]

    AliasFixed::TSVariant::<()>(());
    //~^ ERROR type arguments are not allowed on this entity [E0109]
    AliasFixed::<()>::TSVariant(());
    //~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
    AliasFixed::<()>::TSVariant::<()>(());
    //~^ ERROR type arguments are not allowed on this entity [E0109]
    //~^^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]

    // Struct variant

    Enum::<()>::SVariant::<()>(());
    //~^ ERROR type arguments are not allowed on this entity [E0109]

    Alias::SVariant::<()>(());
    //~^ ERROR type arguments are not allowed on this entity [E0109]
    Alias::<()>::SVariant::<()>(());
    //~^ ERROR type arguments are not allowed on this entity [E0109]

    AliasFixed::SVariant::<()>(());
    //~^ ERROR type arguments are not allowed on this entity [E0109]
    AliasFixed::<()>::SVariant(());
    //~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
    AliasFixed::<()>::SVariant::<()>(());
    //~^ ERROR type arguments are not allowed on this entity [E0109]
    //~^^ ERROR wrong number of type arguments: expected 0, found 1 [E0107]
}