Avoid type mismatch error where a variable is bound with different ref-ness
a20a97b
Opened by Nick Cameron at
e.g.,
match x {
opts::a(ref i) | opts::b(i) => {}
//~^ ERROR variable `i` is bound with different mode in pattern #2 than in pattern #1
//~^^ ERROR mismatched types
Where the field of a and b has the same type
cc #30320
-
error[E0409]: variable `i` is bound in inconsistent ways within the same match arm --> src/main.rs:8:32 | 8 | opts::a(ref i) | opts::b(i) => {} | - ^ bound in different ways | | | first binding error[E0308]: mismatched types --> src/main.rs:8:32 | 8 | opts::a(ref i) | opts::b(i) => {} | ^ expected &isize, found isize | = note: expected type `&isize` found type `isize`Esteban Kuber at 2018-03-15 01:14:46
Current output:
error[E0409]: variable `i` is bound inconsistently across alternatives separated by `|` --> src/lib.rs:8:32 | 8 | opts::a(ref i) | opts::b(i) => {} | - ^ bound in different ways | | | first binding error[E0308]: mismatched types --> src/lib.rs:8:32 | 7 | match x { | - this expression has type `opts` 8 | opts::a(ref i) | opts::b(i) => {} | ----- ^ expected `&isize`, found `isize` | | | first introduced with type `&isize` here | = note: in the same arm, a binding must have the same type in all alternatives help: consider adding `ref` | 8 | opts::a(ref i) | opts::b(ref i) => {} | +++I don't know what else we can do here beyond silencing the E0409.
Esteban Kuber at 2022-12-28 22:59:31