Skip to content

Commit 1745153

Browse files
dsprenkelsManishearth
authored andcommitted
do not additionally note about unexpected identifier after unexpected let
error, by moving unexpected let check into the proper if-else clause
1 parent 2b1e273 commit 1745153

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/libsyntax/parse/parser.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -2156,12 +2156,6 @@ impl<'a> Parser<'a> {
21562156
let lo = self.last_span.lo;
21572157
return self.parse_while_expr(None, lo, attrs);
21582158
}
2159-
if self.token.is_keyword(keywords::Let) {
2160-
// Catch this syntax error here, instead of in `check_strict_keywords`, so
2161-
// that we can explicitly mention that let is not to be used as an expression
2162-
let msg = "`let` is not an expression, so it cannot be used in this way";
2163-
self.span_err(self.span, msg);
2164-
}
21652159
if self.token.is_lifetime() {
21662160
let lifetime = self.get_lifetime();
21672161
let lo = self.span.lo;
@@ -2224,6 +2218,11 @@ impl<'a> Parser<'a> {
22242218
ex = ExprBreak(None);
22252219
}
22262220
hi = self.last_span.hi;
2221+
} else if self.token.is_keyword(keywords::Let) {
2222+
// Catch this syntax error here, instead of in `check_strict_keywords`, so
2223+
// 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));
22272226
} else if self.check(&token::ModSep) ||
22282227
self.token.is_ident() &&
22292228
!self.check_keyword(keywords::True) &&

0 commit comments

Comments
 (0)