about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-07-24 02:00:46 +0200
committerMazdak Farrokhzad <twingoow@gmail.com>2019-07-28 06:53:39 +0200
commitbecdba80ea777afb8ebcd482fc657728b1661dbf (patch)
treeaad22e7153e63d351731eaece03096daad706dfd /src/libsyntax/parse
parent397a027aa76cc3a615858d05efe34857fe4fc8dc (diff)
downloadrust-becdba80ea777afb8ebcd482fc657728b1661dbf.tar.gz
rust-becdba80ea777afb8ebcd482fc657728b1661dbf.zip
Address comments in lowering + parsing.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 34ed7f50907..8f8ed411180 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -3748,8 +3748,9 @@ impl<'a> Parser<'a> {
         })
     }
 
-    /// Parse a parentesized comma separated sequence of patterns until `delim` is reached.
-    fn parse_recover_pat_list(&mut self) -> PResult<'a, ()> {
+    /// Parse and throw away a parentesized comma separated
+    /// sequence of patterns until `)` is reached.
+    fn skip_pat_list(&mut self) -> PResult<'a, ()> {
         while !self.check(&token::CloseDelim(token::Paren)) {
             self.parse_pat(None)?;
             if !self.eat(&token::Comma) {
@@ -3772,7 +3773,7 @@ impl<'a> Parser<'a> {
             // later.
             let comma_span = self.token.span;
             self.bump();
-            if let Err(mut err) = self.parse_recover_pat_list() {
+            if let Err(mut err) = self.skip_pat_list() {
                 // We didn't expect this to work anyway; we just wanted
                 // to advance to the end of the comma-sequence so we know
                 // the span to suggest parenthesizing
@@ -3877,9 +3878,11 @@ impl<'a> Parser<'a> {
                 pat = PatKind::Ref(subpat, mutbl);
             }
             token::OpenDelim(token::Paren) => {
-                // Parse `(pat, pat, pat, ...)` as tuple pattern.
+                // Parse a tuple or parenthesis pattern.
                 let (fields, trailing_comma) = self.parse_paren_comma_seq(|p| p.parse_pat(None))?;
 
+                // Here, `(pat,)` is a tuple pattern.
+                // For backward compatibility, `(..)` is a tuple pattern as well.
                 pat = if fields.len() == 1 && !(trailing_comma || fields[0].is_rest()) {
                     PatKind::Paren(fields.into_iter().nth(0).unwrap())
                 } else {