From aabacf791abb5d50ca1cf0239268b8ef72f8faaa Mon Sep 17 00:00:00 2001 From: colinmarsh19 <32608057+colinmarsh19@users.noreply.github.com> Date: Sat, 25 Nov 2017 08:38:30 -0700 Subject: [PATCH 01/10] Remove semicolon note Added note that specifies a semicolon should be removed after a given struct --- src/libsyntax/parse/parser.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 0b03429ea2e52..7a3009215f277 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5486,7 +5486,11 @@ 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)); + if token_str == ";" { + err.note("consider removing the semicolon"); + } + return Err(); } let hi = if self.span == syntax_pos::DUMMY_SP { From ba40f5c4ef4e2292ff92546236ef507438459eee Mon Sep 17 00:00:00 2001 From: colinmarsh19 <32608057+colinmarsh19@users.noreply.github.com> Date: Sat, 25 Nov 2017 08:40:42 -0700 Subject: [PATCH 02/10] Test for issue #46186 --- src/test/parse-fail/issue-46186.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/test/parse-fail/issue-46186.rs diff --git a/src/test/parse-fail/issue-46186.rs b/src/test/parse-fail/issue-46186.rs new file mode 100644 index 0000000000000..3f3dceeec5e9c --- /dev/null +++ b/src/test/parse-fail/issue-46186.rs @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +struct Struct { + a: usize, +} //~ ERROR expected item, found ';' +//~| NOTE consider removing the semicolon + +fn main() {} From 306f4da69a89f45b9c06ac742f337e6de0445845 Mon Sep 17 00:00:00 2001 From: colinmarsh19 <32608057+colinmarsh19@users.noreply.github.com> Date: Sat, 25 Nov 2017 08:47:05 -0700 Subject: [PATCH 03/10] Fixed Err by passing "err" --- src/libsyntax/parse/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7a3009215f277..1c64b36d960c4 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5490,7 +5490,7 @@ impl<'a> Parser<'a> { if token_str == ";" { err.note("consider removing the semicolon"); } - return Err(); + return Err(err); } let hi = if self.span == syntax_pos::DUMMY_SP { From 8e60f720fb6cf18e9530f4301c2f599357b8a277 Mon Sep 17 00:00:00 2001 From: colinmarsh19 <32608057+colinmarsh19@users.noreply.github.com> Date: Sat, 25 Nov 2017 09:06:06 -0700 Subject: [PATCH 04/10] Added ; --- src/test/parse-fail/issue-46186.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/parse-fail/issue-46186.rs b/src/test/parse-fail/issue-46186.rs index 3f3dceeec5e9c..49ecc76886499 100644 --- a/src/test/parse-fail/issue-46186.rs +++ b/src/test/parse-fail/issue-46186.rs @@ -12,7 +12,7 @@ struct Struct { a: usize, -} //~ ERROR expected item, found ';' +}; //~ ERROR expected item, found ';' //~| NOTE consider removing the semicolon fn main() {} From 3e8883e2aa425147d219e174788e2c1062d7d61f Mon Sep 17 00:00:00 2001 From: colinmarsh19 <32608057+colinmarsh19@users.noreply.github.com> Date: Sat, 25 Nov 2017 18:34:20 -0700 Subject: [PATCH 05/10] Changed from note to span_suggestion_short --- src/libsyntax/parse/parser.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1c64b36d960c4..0f32d588b372f 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5487,8 +5487,9 @@ impl<'a> Parser<'a> { if !self.eat(term) { let token_str = self.this_token_to_string(); let mut err = self.fatal(&format!("expected item, found `{}`", token_str)); + let msg = "consider removing this semicolon"; if token_str == ";" { - err.note("consider removing the semicolon"); + err.span_suggestion_short(self.span, msg, "".to_string()); } return Err(err); } From 477989933ddcab1c5a007a3b65a495ec3081047a Mon Sep 17 00:00:00 2001 From: colinmarsh19 <32608057+colinmarsh19@users.noreply.github.com> Date: Sat, 25 Nov 2017 19:26:47 -0700 Subject: [PATCH 06/10] UI test 46186 --- src/test/ui/issue-46186 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/test/ui/issue-46186 diff --git a/src/test/ui/issue-46186 b/src/test/ui/issue-46186 new file mode 100644 index 0000000000000..2924bec567fb4 --- /dev/null +++ b/src/test/ui/issue-46186 @@ -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 or the MIT license +// , 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() {} From bbe4c85cfce314057afee571a4f5bd5333b56f6a Mon Sep 17 00:00:00 2001 From: colinmarsh19 <32608057+colinmarsh19@users.noreply.github.com> Date: Sat, 25 Nov 2017 19:30:15 -0700 Subject: [PATCH 07/10] Added 46186 stderr --- src/test/ui/issue-46186.stderr | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/test/ui/issue-46186.stderr diff --git a/src/test/ui/issue-46186.stderr b/src/test/ui/issue-46186.stderr new file mode 100644 index 0000000000000..3cc9531bb5b86 --- /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 + From 50537e37f0c51b0ade967c7e6ad76395eb9c9be2 Mon Sep 17 00:00:00 2001 From: colinmarsh19 <32608057+colinmarsh19@users.noreply.github.com> Date: Sat, 25 Nov 2017 21:14:15 -0700 Subject: [PATCH 08/10] Delete bad test file --- src/test/parse-fail/issue-46186.rs | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 src/test/parse-fail/issue-46186.rs diff --git a/src/test/parse-fail/issue-46186.rs b/src/test/parse-fail/issue-46186.rs deleted file mode 100644 index 49ecc76886499..0000000000000 --- a/src/test/parse-fail/issue-46186.rs +++ /dev/null @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -struct Struct { - a: usize, -}; //~ ERROR expected item, found ';' -//~| NOTE consider removing the semicolon - -fn main() {} From f6b80d4164f5ef21c66164e56ddbb5743c0f1011 Mon Sep 17 00:00:00 2001 From: colinmarsh19 <32608057+colinmarsh19@users.noreply.github.com> Date: Sun, 26 Nov 2017 07:36:56 -0700 Subject: [PATCH 09/10] Added .rs extension --- src/test/ui/{issue-46186 => issue-46186.rs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/test/ui/{issue-46186 => issue-46186.rs} (100%) diff --git a/src/test/ui/issue-46186 b/src/test/ui/issue-46186.rs similarity index 100% rename from src/test/ui/issue-46186 rename to src/test/ui/issue-46186.rs From 096e698e4e8e48bd38a2002107616f4ad194e8eb Mon Sep 17 00:00:00 2001 From: colinmarsh19 <32608057+colinmarsh19@users.noreply.github.com> Date: Sun, 26 Nov 2017 07:40:29 -0700 Subject: [PATCH 10/10] Changed to correct quotes ` ` --- src/test/ui/issue-46186.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ui/issue-46186.rs b/src/test/ui/issue-46186.rs index 2924bec567fb4..1440b9e8cdc5f 100644 --- a/src/test/ui/issue-46186.rs +++ b/src/test/ui/issue-46186.rs @@ -10,6 +10,6 @@ struct Struct { a: usize, -}; //~ ERROR expected item, found ';' +}; //~ ERROR expected item, found `;` fn main() {}