diff options
| author | Daan Sprenkels <dsprenkels@gmail.com> | 2016-01-08 00:01:59 +0100 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2016-01-25 20:56:10 +0530 |
| commit | 79f2cff44ec62cf42f6c97d28dc4286de683b1e5 (patch) | |
| tree | f2456de6e9737122d5c672e1a0555e8140b3e8eb /src/libsyntax/parse | |
| parent | 082c03b0780b2de24b68be04e96d1596a7c5b3cf (diff) | |
| download | rust-79f2cff44ec62cf42f6c97d28dc4286de683b1e5.tar.gz rust-79f2cff44ec62cf42f6c97d28dc4286de683b1e5.zip | |
libsyntax: move check for keyword Let to a more logical spot
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index edb1f7eb926..f3809455fe0 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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) = @@ -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()); |
