File: enum-expected-value-suggest-variants.rs

package info (click to toggle)
rustc 1.88.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 934,128 kB
  • sloc: xml: 158,127; python: 36,062; javascript: 19,855; sh: 19,700; cpp: 18,947; ansic: 12,993; asm: 4,792; makefile: 690; lisp: 29; perl: 29; ruby: 19; sql: 11
file content (58 lines) | stat: -rw-r--r-- 1,760 bytes parent folder | download | duplicates (9)
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
        _ => {}
    }
}