about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2016-01-26 18:55:39 +0530
committerManish Goregaokar <manishsmail@gmail.com>2016-01-26 18:55:39 +0530
commitb6faae11f46b18221555759d3e6fad12cbd0ee97 (patch)
tree73ca828212a1d995b4cab760b207964f9c6e8231 /src/libsyntax/parse
parentef96037f7e95f344d34252fa70bb10109ad5b285 (diff)
parent065e47eb3b23a9bd3074d3406157f0aafc575150 (diff)
downloadrust-b6faae11f46b18221555759d3e6fad12cbd0ee97.tar.gz
rust-b6faae11f46b18221555759d3e6fad12cbd0ee97.zip
Rollup merge of #31211 - Manishearth:pr-30765, r=nrc
r? @eddyb or @nrc
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index acce6ed87d0..2249faac6d7 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -2218,6 +2218,12 @@ impl<'a> Parser<'a> {
                         ex = ExprBreak(None);
                     }
                     hi = self.last_span.hi;
+                } else if self.token.is_keyword(keywords::Let) {
+                    // Catch this syntax error here, instead of in `check_strict_keywords`, so
+                    // that we can explicitly mention that let is not to be used as an expression
+                    let mut db = self.fatal("expected expression, found statement (`let`)");
+                    db.note("variable declaration using `let` is a statement");
+                    return Err(db);
                 } else if self.check(&token::ModSep) ||
                         self.token.is_ident() &&
                         !self.check_keyword(keywords::True) &&