about summary refs log tree commit diff
path: root/src/libsyntax
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
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')
-rw-r--r--src/libsyntax/errors/emitter.rs4
-rw-r--r--src/libsyntax/parse/parser.rs6
2 files changed, 8 insertions, 2 deletions
diff --git a/src/libsyntax/errors/emitter.rs b/src/libsyntax/errors/emitter.rs
index c21bf1e6a1f..51013d68930 100644
--- a/src/libsyntax/errors/emitter.rs
+++ b/src/libsyntax/errors/emitter.rs
@@ -10,7 +10,7 @@
 
 use self::Destination::*;
 
-use codemap::{self, COMMAND_LINE_SP, COMMAND_LINE_EXPN, Pos, Span};
+use codemap::{self, COMMAND_LINE_SP, COMMAND_LINE_EXPN, DUMMY_SP, Pos, Span};
 use diagnostics;
 
 use errors::{Level, RenderSpan, DiagnosticBuilder};
@@ -109,8 +109,8 @@ impl Emitter for EmitterWriter {
             lvl: Level) {
         let error = match sp {
             Some(COMMAND_LINE_SP) => self.emit_(FileLine(COMMAND_LINE_SP), msg, code, lvl),
+            Some(DUMMY_SP) | None => print_diagnostic(&mut self.dst, "", lvl, msg, code),
             Some(sp) => self.emit_(FullSpan(sp), msg, code, lvl),
-            None => print_diagnostic(&mut self.dst, "", lvl, msg, code),
         };
 
         if let Err(e) = error {
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) &&