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: 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(-) (limited to 'src/libsyntax/parse/parser.rs') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 0b03429ea2e..7a3009215f2 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 { -- cgit 1.4.1-3-g733a5 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: Fixed Err by passing "err" --- src/libsyntax/parse/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libsyntax/parse/parser.rs') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7a3009215f2..1c64b36d960 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 { -- cgit 1.4.1-3-g733a5 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: Changed from note to span_suggestion_short --- src/libsyntax/parse/parser.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/libsyntax/parse/parser.rs') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1c64b36d960..0f32d588b37 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); } -- cgit 1.4.1-3-g733a5