diff options
| author | kennytm <kennytm@gmail.com> | 2017-11-28 03:16:47 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-11-28 03:16:47 +0800 |
| commit | f33edd2ed09cdbf6dff6b8de757ad63535277297 (patch) | |
| tree | ffbb351d4bad821be545d413a47d7cc9a3fe175c | |
| parent | a60ffa06aebeb87acfd6c3226a91ed508b124e21 (diff) | |
| parent | 096e698e4e8e48bd38a2002107616f4ad194e8eb (diff) | |
Rollup merge of #46258 - colinmarsh19:master, r=estebank
Remove semicolon note In reference to issue #46186 r? @estebank First time doing a pull request, if there are any suggestions on how to improve this please let me know. @jjolly
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 7 | ||||
| -rw-r--r-- | src/test/ui/issue-46186.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/issue-46186.stderr | 8 |
3 files changed, 29 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 0b03429ea2e..0f32d588b37 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5486,7 +5486,12 @@ impl<'a> Parser<'a> { if !self.eat(term) { let token_str = self.this_token_to_string(); - return Err(self.fatal(&format!("expected item, found `{}`", token_str))); + let mut err = self.fatal(&format!("expected item, found `{}`", token_str)); + let msg = "consider removing this semicolon"; + if token_str == ";" { + err.span_suggestion_short(self.span, msg, "".to_string()); + } + return Err(err); } let hi = if self.span == syntax_pos::DUMMY_SP { diff --git a/src/test/ui/issue-46186.rs b/src/test/ui/issue-46186.rs new file mode 100644 index 00000000000..1440b9e8cdc --- /dev/null +++ b/src/test/ui/issue-46186.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Struct { + a: usize, +}; //~ ERROR expected item, found `;` + +fn main() {} diff --git a/src/test/ui/issue-46186.stderr b/src/test/ui/issue-46186.stderr new file mode 100644 index 00000000000..3cc9531bb5b --- /dev/null +++ b/src/test/ui/issue-46186.stderr @@ -0,0 +1,8 @@ +error: expected item, found `;` + --> $DIR/issue-46186.rs:13:2 + | +13 | }; //~ ERROR expected item, found `;` + | ^ help: consider removing this semicolon + +error: aborting due to previous error + |
