Closed
Description
Given:
enum E {
Foo(String, String, String),
}
fn main() {
match E::Foo("".into(), "".into(), "".into()) {
E::Foo(a, b, ref c) => {}
}
}
the current pattern check emits one diagnostic per mismatched usage:
error[E0009]: cannot bind by-move and by-ref in the same pattern
--> file.rs:7:16
|
7 | E::Foo(a, b, ref c) => {}
| ^ ----- both by-ref and by-move used
| |
| by-move pattern here
error[E0009]: cannot bind by-move and by-ref in the same pattern
--> file.rs:7:19
|
7 | E::Foo(a, b, ref c) => {}
| ^ ----- both by-ref and by-move used
| |
| by-move pattern here
Ideally, the pattern check should collect all problematic patterns when possible to reduce how many diagnostics are emitted:
error[E0009]: cannot bind by-move and by-ref in the same pattern
--> file.rs:7:16
|
7 | E::Foo(a, b, ref c) => {}
| ^ ^ ----- both by-ref and by-move used
| | |
| | by-move pattern here
| by-move pattern here
|
help: use by-ref everywhere
|
7 | E::Foo(ref a, ref b, ref c) => {}
| ^^^ ^^^