Better recovery

This commit is contained in:
Michael Goulet
2025-06-26 18:08:15 +00:00
parent e63921262c
commit 4e51e67a24
3 changed files with 27 additions and 6 deletions

View File

@@ -353,6 +353,20 @@ impl<'a> Parser<'a> {
if !self.eat_keyword(exp!(Where)) {
return Ok((where_clause, None));
}
if self.eat_noexpect(&token::Colon) {
let colon_span = self.prev_token.span;
self.dcx()
.struct_span_err(colon_span, "unexpected colon after `where`")
.with_span_suggestion_short(
colon_span,
"remove the colon",
"",
Applicability::MachineApplicable,
)
.emit();
}
where_clause.has_where_token = true;
let where_lo = self.prev_token.span;