Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libsyntax/errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-fail-fulldeps/qquote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// ignore-cross-compile

// error-pattern:expected identifier, found keyword `let`
// error-pattern:expected expression, found statement (`let`)

#![feature(quote, rustc_private)]

Expand Down