diff options
| author | Pramod Bisht <pramodpsb@outlook.com> | 2018-08-14 19:05:27 +0000 |
|---|---|---|
| committer | Pramod Bisht <pramodpsb@outlook.com> | 2018-08-14 19:05:27 +0000 |
| commit | b70be5bc7953007c333db510b5784c7a051a9b27 (patch) | |
| tree | dad1f0e7a5e06a423f2d9e49876eba6ebe1383c6 /src/libsyntax/parse/parser.rs | |
| parent | 23f09bbed4ef12c5f9db198c22f50b608ea6c6d5 (diff) | |
| download | rust-b70be5bc7953007c333db510b5784c7a051a9b27.tar.gz rust-b70be5bc7953007c333db510b5784c7a051a9b27.zip | |
Adddressed #51602
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 0e45cacaf38..8e11104b3f6 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4719,7 +4719,12 @@ impl<'a> Parser<'a> { if !self.eat(&token::OpenDelim(token::Brace)) { let sp = self.span; let tok = self.this_token_to_string(); + let mut do_not_suggest_help = false; let mut e = self.span_fatal(sp, &format!("expected `{{`, found `{}`", tok)); + if self.token.is_keyword(keywords::In) || self.token == token::Colon { + do_not_suggest_help = true; + e.span_label(sp, "expected `{`"); + } // Check to see if the user has written something like // @@ -4729,7 +4734,8 @@ impl<'a> Parser<'a> { // Which is valid in other languages, but not Rust. match self.parse_stmt_without_recovery(false) { Ok(Some(stmt)) => { - if self.look_ahead(1, |t| t == &token::OpenDelim(token::Brace)) { + if self.look_ahead(1, |t| t == &token::OpenDelim(token::Brace)) + || do_not_suggest_help { // if the next token is an open brace (e.g., `if a b {`), the place- // inside-a-block suggestion would be more likely wrong than right return Err(e); |
