diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-03-06 15:54:44 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-05-26 11:11:58 +0300 |
| commit | c038b454239a30cb8a734bcb2ff8a7e5e543939a (patch) | |
| tree | 978a7e11ebc682cb15f3f3decb256c0ae2ea15cd /src/libsyntax | |
| parent | d69aeaf662c637b454e8c7a5ddbd69b4978ec211 (diff) | |
| download | rust-c038b454239a30cb8a734bcb2ff8a7e5e543939a.tar.gz rust-c038b454239a30cb8a734bcb2ff8a7e5e543939a.zip | |
Address review comments
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 6eb588767c4..7c3c33c28f6 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -631,7 +631,7 @@ pub enum PatKind { Struct(Path, Vec<Spanned<FieldPat>>, bool), /// A tuple struct/variant pattern `Variant(x, y, .., z)`. - /// If the `..` pattern fragment presents, then `Option<usize>` denotes its position. + /// If the `..` pattern fragment is present, then `Option<usize>` denotes its position. /// 0 <= position <= subpats.len() TupleStruct(Path, Vec<P<Pat>>, Option<usize>), @@ -646,7 +646,7 @@ pub enum PatKind { QPath(QSelf, Path), /// A tuple pattern `(a, b)`. - /// If the `..` pattern fragment presents, then `Option<usize>` denotes its position. + /// If the `..` pattern fragment is present, then `Option<usize>` denotes its position. /// 0 <= position <= subpats.len() Tuple(Vec<P<Pat>>, Option<usize>), /// A `box` pattern diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a4f12769b5c..943910b1570 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3426,6 +3426,10 @@ impl<'a> Parser<'a> { // `..` needs to be followed by `)` or `, pat`, `..,)` is disallowed. fields.push(self.parse_pat()?); } + } else if ddpos.is_some() && self.eat(&token::DotDot) { + // Emit a friendly error, ignore `..` and continue parsing + self.span_err(self.last_span, "`..` can only be used once per \ + tuple or tuple struct pattern"); } else { fields.push(self.parse_pat()?); } |
