Skip to content

Commit

Permalink
Rollup merge of rust-lang#46258 - colinmarsh19:master, r=estebank
Browse files Browse the repository at this point in the history
Remove semicolon note

In reference to issue rust-lang#46186
r? @estebank

First time doing a pull request, if there are any suggestions on how to improve this please let me know.
@jjolly
  • Loading branch information
kennytm authored Nov 27, 2017
2 parents a60ffa0 + 096e698 commit f33edd2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/issue-46186.rs
Original file line number Diff line number Diff line change
@@ -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() {}
8 changes: 8 additions & 0 deletions src/test/ui/issue-46186.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f33edd2

Please sign in to comment.