diff options
| author | Hidehito Yabuuchi <hdht.ybuc@gmail.com> | 2018-03-22 20:57:12 +0900 |
|---|---|---|
| committer | Hidehito Yabuuchi <hdht.ybuc@gmail.com> | 2018-03-24 07:54:20 +0900 |
| commit | 3bfed9e43f5ebe76719e3c30c8c8cefc81b08f80 (patch) | |
| tree | 16bd8a1e6b3f06212408a9d0397230079e9c3bfd /src/libsyntax/parse | |
| parent | c08480fce0f39f5c9c6db6dde0dccb375ca0ab14 (diff) | |
| download | rust-3bfed9e43f5ebe76719e3c30c8c8cefc81b08f80.tar.gz rust-3bfed9e43f5ebe76719e3c30c8c8cefc81b08f80.zip | |
Better diagnostics for '..' pattern fragment not in the last position
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a07279acae2..98e2528d30f 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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; |
