- Point at the body expression of the match arm with the type error. - Point at the prior match arms explicitely stating the evaluated type. - Point at the entire match expr in a secondary span, instead of primary. - For type errors in the first match arm, the cause is outside of the match, treat as implicit block error to give a more appropriate error.
16 lines
303 B
Rust
16 lines
303 B
Rust
fn closure_to_loc() {
|
|
let mut x = |c| c + 1;
|
|
x = |c| c + 1;
|
|
//~^ ERROR mismatched types
|
|
}
|
|
|
|
fn closure_from_match() {
|
|
let x = match 1usize {
|
|
1 => |c| c + 1,
|
|
2 => |c| c - 1,
|
|
_ => |c| c - 1
|
|
};
|
|
//~^^^ ERROR match arms have incompatible types
|
|
}
|
|
|
|
fn main() { }
|