about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-01-26 13:26:08 +0000
committerbors <bors@rust-lang.org>2016-01-26 13:26:08 +0000
commit5d6e8fcedac1184a28031ee0cf63e2d862e4536f (patch)
tree73ca828212a1d995b4cab760b207964f9c6e8231 /src/libsyntax/parse/parser.rs
parent43c1a173a874f5513db58b2f5321489a00087484 (diff)
parentb6faae11f46b18221555759d3e6fad12cbd0ee97 (diff)
downloadrust-5d6e8fcedac1184a28031ee0cf63e2d862e4536f.tar.gz
rust-5d6e8fcedac1184a28031ee0cf63e2d862e4536f.zip
Auto merge of #31214 - Manishearth:rollup, r=Manishearth
- Successful merges: #31172, #31177, #31211
- Failed merges:
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
-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) &&