Closed
Description
Given the following code:
use Foo::FooB;
enum Foo {
FooB { x: i32, y: i32 }
}
fn main() {
let f = FooB { x: 3, y: 4 };
match f {
FooB(a, b) => println!("{} {}", a, b),
//~^ ERROR expected tuple struct or tuple variant, found variant `FooB`
}
}
The current output is:
error[E0532]: expected tuple struct or tuple variant, found variant `FooB`
--> src/main.rs:10:9
|
4 | FooB { x: i32, y: i32 }
| ----------------------- `FooB` defined here
...
10 | FooB(a, b) => println!("{} {}", a, b),
| ^^^^^^^^^^ help: use struct pattern syntax instead: `FooB { x, y }`
Currently, this will fail to apply because we name the bindings x and y, but end up using a and b. I wonder if we can make the suggestion more clever to actually work around this so that this can be automatically applied.