2021-07-13 06:18:03 -05:00
|
|
|
// Tests that a suggestion is issued if the user wrote a colon instead of
|
|
|
|
// a path separator in a match arm.
|
|
|
|
|
2021-07-15 10:36:19 -05:00
|
|
|
mod qux {
|
|
|
|
pub enum Foo {
|
|
|
|
Bar,
|
|
|
|
Baz,
|
|
|
|
}
|
2021-07-13 06:18:03 -05:00
|
|
|
}
|
|
|
|
|
2021-07-15 10:36:19 -05:00
|
|
|
use qux::Foo;
|
|
|
|
|
2021-07-13 06:18:03 -05:00
|
|
|
fn f() -> Foo { Foo::Bar }
|
|
|
|
|
|
|
|
fn g1() {
|
|
|
|
match f() {
|
|
|
|
Foo:Bar => {}
|
|
|
|
//~^ ERROR: expected one of
|
|
|
|
//~| HELP: maybe write a path separator here
|
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
match f() {
|
2021-07-15 10:36:19 -05:00
|
|
|
qux::Foo:Bar => {}
|
2021-07-13 06:18:03 -05:00
|
|
|
//~^ ERROR: expected one of
|
|
|
|
//~| HELP: maybe write a path separator here
|
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
match f() {
|
2021-07-15 10:36:19 -05:00
|
|
|
qux:Foo::Baz => {}
|
2021-07-13 06:18:03 -05:00
|
|
|
//~^ ERROR: expected one of
|
|
|
|
//~| HELP: maybe write a path separator here
|
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
match f() {
|
2021-07-15 10:36:19 -05:00
|
|
|
qux: Foo::Baz if true => {}
|
2021-07-13 06:18:03 -05:00
|
|
|
//~^ ERROR: expected one of
|
|
|
|
//~| HELP: maybe write a path separator here
|
|
|
|
_ => {}
|
|
|
|
}
|
2021-07-15 10:36:19 -05:00
|
|
|
if let Foo:Bar = f() {
|
2021-07-13 06:18:03 -05:00
|
|
|
//~^ ERROR: expected one of
|
|
|
|
//~| HELP: maybe write a path separator here
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn g1_neg() {
|
|
|
|
match f() {
|
2021-07-15 10:36:19 -05:00
|
|
|
ref qux: Foo::Baz => {}
|
2021-07-13 06:18:03 -05:00
|
|
|
//~^ ERROR: expected one of
|
2021-07-15 10:36:19 -05:00
|
|
|
//~| HELP: maybe write a path separator here
|
2021-07-13 06:18:03 -05:00
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn g2_neg() {
|
|
|
|
match f() {
|
2021-07-15 10:36:19 -05:00
|
|
|
mut qux: Foo::Baz => {}
|
2021-07-13 06:18:03 -05:00
|
|
|
//~^ ERROR: expected one of
|
2021-07-15 10:36:19 -05:00
|
|
|
//~| HELP: maybe write a path separator here
|
2021-07-13 06:18:03 -05:00
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let myfoo = Foo::Bar;
|
|
|
|
match myfoo {
|
|
|
|
Foo::Bar => {}
|
|
|
|
Foo:Bar::Baz => {}
|
|
|
|
//~^ ERROR: expected one of
|
|
|
|
//~| HELP: maybe write a path separator here
|
2021-07-15 10:36:19 -05:00
|
|
|
}
|
|
|
|
match myfoo {
|
|
|
|
Foo::Bar => {}
|
|
|
|
Foo:Bar => {}
|
|
|
|
//~^ ERROR: expected one of
|
|
|
|
//~| HELP: maybe write a path separator here
|
2021-07-13 06:18:03 -05:00
|
|
|
}
|
|
|
|
}
|