Closed
Description
Given the following code:
struct S(u32, Vec<i32>);
fn foo(x: &S) {
match x {
S(& (mut y), v) => {
}
}
}
The current output is:
error[[E0308]](https://doc.rust-lang.org/nightly/error-index.html#E0308): mismatched types
--> src/lib.rs:5:11
|
4 | match x {
| - this expression has type `&S`
5 | S(& (mut y), v) => {
| ^^^^^^^^^ expected `u32`, found reference
|
= note: expected type `u32`
found reference `&_`
help: consider removing `&` from the pattern
|
5 - S(& (mut y), v) => {
5 + S(mut y), v) => {
|
Note that the suggestion is wrong, it removes the (
but left in the matching )
. Applying that suggestion leads to invalid code:
struct S(u32, Vec<i32>);
fn foo(x: &S) {
match x {
S(mut y), v) => {
}
}
}
It should instead suggest
5 - S(& (mut y), v) => {
5 + S(mut y, v) => {