about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 812e3c4967a..f347f7af06d 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -3432,7 +3432,16 @@ impl<'a> Parser<'a> {
         loop {
             pats.push(self.parse_pat()?);
             if self.check(&token::BinOp(token::Or)) { self.bump();}
-            else { return Ok(pats); }
+            else {
+                // Accidental use of || instead of | inbetween patterns
+                if self.token == token::OrOr {
+                    return Err(self.span_fatal_help(
+                           self.span, "Unexpected token `||` after pattern",
+                           "Did you mean to use `|` to specify multiple patterns instead?"));
+                }
+
+                return Ok(pats);
+            }
         };
     }