Improve error message for let-in-expr-position
This commit is contained in:
parent
d829019ff4
commit
065e47eb3b
2 changed files with 4 additions and 3 deletions
|
@ -2221,8 +2221,9 @@ impl<'a> Parser<'a> {
|
||||||
} else if self.token.is_keyword(keywords::Let) {
|
} else if self.token.is_keyword(keywords::Let) {
|
||||||
// Catch this syntax error here, instead of in `check_strict_keywords`, so
|
// 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
|
// that we can explicitly mention that let is not to be used as an expression
|
||||||
let msg = "`let` is not an expression, so it cannot be used in this way";
|
let mut db = self.fatal("expected expression, found statement (`let`)");
|
||||||
return Err(self.fatal(&msg));
|
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 @@
|
||||||
|
|
||||||
// ignore-cross-compile
|
// ignore-cross-compile
|
||||||
|
|
||||||
// error-pattern:`let` is not an expression, so it cannot be used in this way
|
// error-pattern:expected expression, found statement (`let`)
|
||||||
|
|
||||||
#![feature(quote, rustc_private)]
|
#![feature(quote, rustc_private)]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue