do not additionally note about unexpected identifier after unexpected let
error, by moving unexpected let check into the proper if-else clause
This commit is contained in:
parent
2b1e273293
commit
1745153eae
1 changed files with 5 additions and 6 deletions
|
@ -2156,12 +2156,6 @@ impl<'a> Parser<'a> {
|
||||||
let lo = self.last_span.lo;
|
let lo = self.last_span.lo;
|
||||||
return self.parse_while_expr(None, lo, attrs);
|
return self.parse_while_expr(None, lo, attrs);
|
||||||
}
|
}
|
||||||
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 msg = "`let` is not an expression, so it cannot be used in this way";
|
|
||||||
self.span_err(self.span, msg);
|
|
||||||
}
|
|
||||||
if self.token.is_lifetime() {
|
if self.token.is_lifetime() {
|
||||||
let lifetime = self.get_lifetime();
|
let lifetime = self.get_lifetime();
|
||||||
let lo = self.span.lo;
|
let lo = self.span.lo;
|
||||||
|
@ -2224,6 +2218,11 @@ impl<'a> Parser<'a> {
|
||||||
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 msg = "`let` is not an expression, so it cannot be used in this way";
|
||||||
|
return Err(self.fatal(&msg));
|
||||||
} 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) &&
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue