Skip to content

Commit

Permalink
libsyntax: move check for keyword Let to a more logical spot
Browse files Browse the repository at this point in the history
  • Loading branch information
dsprenkels authored and Manishearth committed Jan 25, 2016
1 parent 082c03b commit 79f2cff
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/libsyntax/parse/parser.rs
Expand Up @@ -2134,6 +2134,12 @@ impl<'a> Parser<'a> {
}
hi = self.last_span.hi;
}
_ 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.diagnostic().struct_span_err(self.span, &msg));
},
_ => {
if self.eat_lt() {
let (qself, path) =
Expand Down Expand Up @@ -2199,12 +2205,6 @@ impl<'a> Parser<'a> {
UnsafeBlock(ast::UserProvided),
attrs);
}
if self.eat_keyword(keywords::Let) {
return Err(self.span_fatal(self.span,
"`let` is not an expression, so it cannot \
be used in this way"))

}
if self.eat_keyword(keywords::Return) {
if self.token.can_begin_expr() {
let e = try!(self.parse_expr());
Expand Down

0 comments on commit 79f2cff

Please sign in to comment.