diff options
| author | Kevin Butler <haqkrs@gmail.com> | 2015-10-27 13:41:55 +0000 |
|---|---|---|
| committer | Kevin Butler <haqkrs@gmail.com> | 2015-10-28 22:32:07 +0000 |
| commit | 99ecf4e2c94a72a68294111ecdf6a82c150c378a (patch) | |
| tree | ec1bceda822241a263a3929e09dc051bfa2ae8d9 /src/libsyntax/parse/parser.rs | |
| parent | 65623dba0d0c39de0e7cc66a31bce45328c3caa8 (diff) | |
| download | rust-99ecf4e2c94a72a68294111ecdf6a82c150c378a.tar.gz rust-99ecf4e2c94a72a68294111ecdf6a82c150c378a.zip | |
libsyntax: improve error message when a statement is prefixed with a match keyword
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6cee7b86a61..d1fc8ac2002 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2941,9 +2941,15 @@ impl<'a> Parser<'a> { } fn parse_match_expr(&mut self) -> PResult<P<Expr>> { + let match_span = self.last_span; let lo = self.last_span.lo; let discriminant = try!(self.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL)); - try!(self.commit_expr_expecting(&*discriminant, token::OpenDelim(token::Brace))); + if let Err(e) = self.commit_expr_expecting(&*discriminant, token::OpenDelim(token::Brace)) { + if self.token == token::Token::Semi { + self.span_note(match_span, "did you mean to remove this `match` keyword?"); + } + return Err(e) + } let mut arms: Vec<Arm> = Vec::new(); while self.token != token::CloseDelim(token::Brace) { arms.push(try!(self.parse_arm_nopanic())); |
