]> git.lizzy.rs Git - rust.git/blob - tests/ui/parser/issues/issue-87086-colon-path-sep.rs
Rollup merge of #106144 - tgross35:patch-1, r=Mark-Simulacrum
[rust.git] / tests / ui / parser / issues / issue-87086-colon-path-sep.rs
1 // Tests that a suggestion is issued if the user wrote a colon instead of
2 // a path separator in a match arm.
3
4 mod qux {
5     pub enum Foo {
6         Bar,
7         Baz,
8     }
9 }
10
11 use qux::Foo;
12
13 fn f() -> Foo { Foo::Bar }
14
15 fn g1() {
16     match f() {
17         Foo:Bar => {}
18         //~^ ERROR: expected one of
19         //~| HELP: maybe write a path separator here
20         _ => {}
21     }
22     match f() {
23         qux::Foo:Bar => {}
24         //~^ ERROR: expected one of
25         //~| HELP: maybe write a path separator here
26         _ => {}
27     }
28     match f() {
29         qux:Foo::Baz => {}
30         //~^ ERROR: expected one of
31         //~| HELP: maybe write a path separator here
32         _ => {}
33     }
34     match f() {
35         qux: Foo::Baz if true => {}
36         //~^ ERROR: expected one of
37         //~| HELP: maybe write a path separator here
38         _ => {}
39     }
40     if let Foo:Bar = f() {
41     //~^ ERROR: expected one of
42     //~| HELP: maybe write a path separator here
43     }
44 }
45
46 fn g1_neg() {
47     match f() {
48         ref qux: Foo::Baz => {}
49         //~^ ERROR: expected one of
50         //~| HELP: maybe write a path separator here
51         _ => {}
52     }
53 }
54
55 fn g2_neg() {
56     match f() {
57         mut qux: Foo::Baz => {}
58         //~^ ERROR: expected one of
59         //~| HELP: maybe write a path separator here
60         _ => {}
61     }
62 }
63
64 fn main() {
65     let myfoo = Foo::Bar;
66     match myfoo {
67         Foo::Bar => {}
68         Foo:Bar::Baz => {}
69         //~^ ERROR: expected one of
70         //~| HELP: maybe write a path separator here
71         //~| ERROR: failed to resolve: `Bar` is a variant, not a module
72     }
73     match myfoo {
74         Foo::Bar => {}
75         Foo:Bar => {}
76         //~^ ERROR: expected one of
77         //~| HELP: maybe write a path separator here
78     }
79 }