1
Fork 0

Fix invalid suggestion for mismatched types in closure arguments

The invalid suggestion came from a wrongly created span in `rustc_parse'
for closure arguments that didn't have a type specified. Specifically,
the span in this case was the last token span, but in the case of
tuples, the span represented the last parenthesis instead of the whole
tuple, which is fixed by taking the more accurate span of the pattern.
This commit is contained in:
Urgau 2023-07-30 16:42:16 +02:00
parent 04411507be
commit 8ea7e45e44
7 changed files with 78 additions and 30 deletions

View file

@ -2342,7 +2342,7 @@ impl<'a> Parser<'a> {
let ty = if this.eat(&token::Colon) {
this.parse_ty()?
} else {
this.mk_ty(this.prev_token.span, TyKind::Infer)
this.mk_ty(pat.span, TyKind::Infer)
};
Ok((