about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorkeatinge <willy.keatinge@gmail.com>2018-01-06 07:41:36 -0500
committerkeatinge <willy.keatinge@gmail.com>2018-01-06 07:47:51 -0500
commit41f58a7cf69d14151070996de50eb7f8587f6b1d (patch)
tree9a62e740e4593e79ba146980b3fac9554061326c /src/libsyntax/parse
parent90e019bacd9e5d231e5292b393269ce7ada4940d (diff)
downloadrust-41f58a7cf69d14151070996de50eb7f8587f6b1d.tar.gz
rust-41f58a7cf69d14151070996de50eb7f8587f6b1d.zip
Add help message for incorrect pattern syntax
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);
+            }
         };
     }