Skip to content

Commit 065e47e

Browse files
committed
Improve error message for let-in-expr-position
1 parent d829019 commit 065e47e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/libsyntax/parse/parser.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2221,8 +2221,9 @@ impl<'a> Parser<'a> {
22212221
} else if self.token.is_keyword(keywords::Let) {
22222222
// Catch this syntax error here, instead of in `check_strict_keywords`, so
22232223
// that we can explicitly mention that let is not to be used as an expression
2224-
let msg = "`let` is not an expression, so it cannot be used in this way";
2225-
return Err(self.fatal(&msg));
2224+
let mut db = self.fatal("expected expression, found statement (`let`)");
2225+
db.note("variable declaration using `let` is a statement");
2226+
return Err(db);
22262227
} else if self.check(&token::ModSep) ||
22272228
self.token.is_ident() &&
22282229
!self.check_keyword(keywords::True) &&

src/test/run-fail-fulldeps/qquote.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// ignore-cross-compile
1212

13-
// error-pattern:`let` is not an expression, so it cannot be used in this way
13+
// error-pattern:expected expression, found statement (`let`)
1414

1515
#![feature(quote, rustc_private)]
1616

0 commit comments

Comments
 (0)