1
Fork 0

Better diagnostics for '..' pattern fragment not in the last position

This commit is contained in:
Hidehito Yabuuchi 2018-03-22 20:57:12 +09:00
parent c08480fce0
commit 3bfed9e43f
3 changed files with 51 additions and 1 deletions

View file

@ -3675,7 +3675,13 @@ impl<'a> Parser<'a> {
if self.token != token::CloseDelim(token::Brace) {
let token_str = self.this_token_to_string();
let mut err = self.fatal(&format!("expected `{}`, found `{}`", "}", token_str));
err.span_label(self.span, "expected `}`");
if self.token == token::Comma { // Issue #49257
err.span_label(self.span,
"`..` must be in the last position, \
and cannot have a trailing comma");
} else {
err.span_label(self.span, "expected `}`");
}
return Err(err);
}
etc = true;