summary refs log tree commit diff
path: root/tests/ui/resolve/enum-expected-value-suggest-variants.rs
blob: 9f86a0a1ecc76c04ba64a125a198e631822ca722 (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
enum Foo {
    //~^ HELP consider importing this tuple variant
    A(u32),
    B(u32),
}

enum Bar {
    C(u32),
    D(u32),
    E,
    F,
}

fn main() {
    let _: Foo = Foo(0);
    //~^ ERROR expected function
    //~| HELP try to construct one of the enum's variants

    let _: Foo = Foo.A(0);
    //~^ ERROR expected value, found enum `Foo`
    //~| HELP use the path separator to refer to a variant

    let _: Foo = Foo.Bad(0);
    //~^ ERROR expected value, found enum `Foo`
    //~| HELP the following enum variants are available

    let _: Bar = Bar(0);
    //~^ ERROR expected function
    //~| HELP try to construct one of the enum's variants
    //~| HELP you might have meant to construct one of the enum's non-tuple variants

    let _: Bar = Bar.C(0);
    //~^ ERROR expected value, found enum `Bar`
    //~| HELP use the path separator to refer to a variant

    let _: Bar = Bar.E;
    //~^ ERROR expected value, found enum `Bar`
    //~| HELP use the path separator to refer to a variant

    let _: Bar = Bar.Bad(0);
    //~^ ERROR expected value, found enum `Bar`
    //~| HELP you might have meant to use one of the following enum variants
    //~| HELP alternatively, the following enum variants are also available

    let _: Bar = Bar.Bad;
    //~^ ERROR expected value, found enum `Bar`
    //~| HELP you might have meant to use one of the following enum variants
    //~| HELP alternatively, the following enum variants are also available

    match Foo::A(42) {
        A(..) => {}
        //~^ ERROR cannot find tuple struct or tuple variant `A` in this scope
        Foo(..) => {}
        //~^ ERROR expected tuple struct or tuple variant
        //~| HELP try to match against one of the enum's variants
        _ => {}
    }
}