diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2016-01-26 13:53:28 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2016-01-26 13:55:46 +0530 |
| commit | 065e47eb3b23a9bd3074d3406157f0aafc575150 (patch) | |
| tree | 41afb4ebda1bd4e6e7db4f697f4cb78a2552f24d | |
| parent | d829019ff4874e2a4f1b6780c442dfa524e75d38 (diff) | |
| download | rust-065e47eb3b23a9bd3074d3406157f0aafc575150.tar.gz rust-065e47eb3b23a9bd3074d3406157f0aafc575150.zip | |
Improve error message for let-in-expr-position
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 5 | ||||
| -rw-r--r-- | src/test/run-fail-fulldeps/qquote.rs | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index daa13885e0d..4ee3ce63a8d 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2221,8 +2221,9 @@ impl<'a> Parser<'a> { } 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)); + let mut db = self.fatal("expected expression, found statement (`let`)"); + db.note("variable declaration using `let` is a statement"); + return Err(db); } else if self.check(&token::ModSep) || self.token.is_ident() && !self.check_keyword(keywords::True) && diff --git a/src/test/run-fail-fulldeps/qquote.rs b/src/test/run-fail-fulldeps/qquote.rs index 297a1da25b5..41a6fd05c37 100644 --- a/src/test/run-fail-fulldeps/qquote.rs +++ b/src/test/run-fail-fulldeps/qquote.rs @@ -10,7 +10,7 @@ // ignore-cross-compile -// error-pattern:`let` is not an expression, so it cannot be used in this way +// error-pattern:expected expression, found statement (`let`) #![feature(quote, rustc_private)] |
