Issue #50974: Suboptimal error in case of duplicate , in struct constructor

This commit is contained in:
Lamb 2018-05-29 13:19:58 +02:00 committed by Pietro Albini
parent 7dae5c0e06
commit 7969b78222
No known key found for this signature in database
GPG key ID: E8C1042DD1624519

View file

@ -776,6 +776,9 @@ impl<'a> Parser<'a> {
err.span_label(self.span, format!("expected identifier, found {}", token_descr));
} else {
err.span_label(self.span, "expected identifier");
if self.token == token::Comma {
err.span_suggestion(self.span, "try removing a comma", ",".into());
}
}
err
}
@ -2446,8 +2449,11 @@ impl<'a> Parser<'a> {
Err(mut e) => {
e.span_label(struct_sp, "while parsing this struct");
e.emit();
self.recover_stmt();
break;
if self.token != token::Comma {
self.recover_stmt();
break;
}
}
}