提交 b6faae11 编写于 作者: M Manish Goregaokar

Rollup merge of #31211 - Manishearth:pr-30765, r=nrc

r? @EddyB or @nrc
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
use self::Destination::*; 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 diagnostics;
use errors::{Level, RenderSpan, DiagnosticBuilder}; use errors::{Level, RenderSpan, DiagnosticBuilder};
...@@ -109,8 +109,8 @@ fn emit(&mut self, ...@@ -109,8 +109,8 @@ fn emit(&mut self,
lvl: Level) { lvl: Level) {
let error = match sp { let error = match sp {
Some(COMMAND_LINE_SP) => self.emit_(FileLine(COMMAND_LINE_SP), msg, code, lvl), 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), Some(sp) => self.emit_(FullSpan(sp), msg, code, lvl),
None => print_diagnostic(&mut self.dst, "", lvl, msg, code),
}; };
if let Err(e) = error { if let Err(e) = error {
......
...@@ -2218,6 +2218,12 @@ fn parse_bottom_expr(&mut self) -> PResult<'a, P<Expr>> { ...@@ -2218,6 +2218,12 @@ fn parse_bottom_expr(&mut self) -> PResult<'a, P<Expr>> {
ex = ExprBreak(None); ex = ExprBreak(None);
} }
hi = self.last_span.hi; 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) || } else if self.check(&token::ModSep) ||
self.token.is_ident() && self.token.is_ident() &&
!self.check_keyword(keywords::True) && !self.check_keyword(keywords::True) &&
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
// ignore-cross-compile // ignore-cross-compile
// error-pattern:expected identifier, found keyword `let` // error-pattern:expected expression, found statement (`let`)
#![feature(quote, rustc_private)] #![feature(quote, rustc_private)]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册