about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-03-25 01:26:40 +0800
committerGitHub <noreply@github.com>2018-03-25 01:26:40 +0800
commit3bc81f7f4dbf5cf0d1b87292848efe78c5fac516 (patch)
treef364e9428856fa1c47f0183f9b408a39e884d9bb /src/libsyntax
parent88277f5e4b2886617397a71a8204b32c26e454f6 (diff)
parent3d0ccb2a22a229ddee842c0c1bf4ca231e77c78b (diff)
downloadrust-3bc81f7f4dbf5cf0d1b87292848efe78c5fac516.tar.gz
rust-3bc81f7f4dbf5cf0d1b87292848efe78c5fac516.zip
Rollup merge of #49268 - ordovicia:dotdot-pattern-diag, r=petrochenkov
Better diagnostics for '..' pattern fragment not in the last position

Fixes #49257.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/parse/parser.rs8
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;