From 0c9afa87ba8145d09a2c4af7b15a9a23ad470fc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 18 Feb 2018 14:36:35 -0800 Subject: [PATCH 1/5] Provide missing comma in match arm suggestion When finding: ```rust match &Some(3) { &None => 1 &Some(2) => { 3 } _ => 2 } ``` provide the following diagnostic: ``` error: expected one of `,`, `.`, `?`, `}`, or an operator, found `=>` --> $DIR/missing-comma-in-match.rs:15:18 | X | &None => 1 | -- - help: missing comma | | | while parsing the match arm starting here X | &Some(2) => { 3 } | ^^ expected one of `,`, `.`, `?`, `}`, or an operator here ``` --- src/libsyntax/parse/parser.rs | 38 ++++++++++++++++++- .../ui/suggestions/missing-comma-in-match.rs | 20 ++++++++++ .../suggestions/missing-comma-in-match.stderr | 12 ++++++ 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 src/test/ui/suggestions/missing-comma-in-match.rs create mode 100644 src/test/ui/suggestions/missing-comma-in-match.stderr diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 09dd00fa5fa3a..2046bbfa713a5 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3404,14 +3404,48 @@ impl<'a> Parser<'a> { } else { None }; + let arrow_span = self.span; self.expect(&token::FatArrow)?; - let expr = self.parse_expr_res(Restrictions::STMT_EXPR, None)?; + let arm_start_span = self.span; + + let expr = self.parse_expr_res(Restrictions::STMT_EXPR, None) + .map_err(|mut err| { + err.span_label(arrow_span, "while parsing the match arm starting here"); + err + })?; let require_comma = classify::expr_requires_semi_to_be_stmt(&expr) && self.token != token::CloseDelim(token::Brace); if require_comma { - self.expect_one_of(&[token::Comma], &[token::CloseDelim(token::Brace)])?; + let cm = self.sess.codemap(); + self.expect_one_of(&[token::Comma], &[token::CloseDelim(token::Brace)]) + .map_err(|mut err| { + err.span_label(arrow_span, "while parsing the match arm starting here"); + match (cm.span_to_lines(expr.span), cm.span_to_lines(arm_start_span)) { + (Ok(ref expr_lines), Ok(ref arm_start_lines)) + if arm_start_lines.lines[0].end_col == expr_lines.lines[0].end_col + && expr_lines.lines.len() == 2 + && self.token == token::FatArrow => { + // We check wether there's any trailing code in the parse span, if there + // isn't, we very likely have the following: + // + // X | &Y => "y" + // | -- - missing comma + // | | + // | arrow_span + // X | &X => "x" + // | - ^^ self.span + // | | + // | parsed until here as `"y" & X` + err.span_suggestion_short(cm.next_point(arm_start_span), + "missing a comma here to end this match arm", + ",".to_owned()); + } + _ => {} + } + err + })?; } else { self.eat(&token::Comma); } diff --git a/src/test/ui/suggestions/missing-comma-in-match.rs b/src/test/ui/suggestions/missing-comma-in-match.rs new file mode 100644 index 0000000000000..e02a8df3343b3 --- /dev/null +++ b/src/test/ui/suggestions/missing-comma-in-match.rs @@ -0,0 +1,20 @@ +// Copyright 2018 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. + +fn main() { + match &Some(3) { + &None => 1 + &Some(2) => { 3 } + //~^ ERROR expected one of `,`, `.`, `?`, `}`, or an operator, found `=>` + //~| NOTE expected one of `,`, `.`, `?`, `}`, or an operator here + //~^^^^ NOTE while parsing the match arm starting here + _ => 2 + }; +} diff --git a/src/test/ui/suggestions/missing-comma-in-match.stderr b/src/test/ui/suggestions/missing-comma-in-match.stderr new file mode 100644 index 0000000000000..864fde49a5e51 --- /dev/null +++ b/src/test/ui/suggestions/missing-comma-in-match.stderr @@ -0,0 +1,12 @@ +error: expected one of `,`, `.`, `?`, `}`, or an operator, found `=>` + --> $DIR/missing-comma-in-match.rs:14:18 + | +13 | &None => 1 + | -- - help: missing a comma here to end this match arm + | | + | while parsing the match arm starting here +14 | &Some(2) => { 3 } + | ^^ expected one of `,`, `.`, `?`, `}`, or an operator here + +error: aborting due to previous error + From ba7039cfd6331fb532c8a68aa79e6af4ef9b62df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 18 Feb 2018 16:59:33 -0800 Subject: [PATCH 2/5] Detect missing `if` blocks When unnecessarily using a fat arrow after an if condition, suggest the removal of it. When finding an if statement with no block, point at the `if` keyword to provide more context. --- src/libsyntax/parse/parser.rs | 35 ++++++++++++++++----- src/test/ui/did_you_mean/issue-40006.stderr | 2 +- src/test/ui/if-without-block.rs | 18 +++++++++++ src/test/ui/if-without-block.stderr | 11 +++++++ src/test/ui/missing-block-hint.stderr | 4 ++- 5 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 src/test/ui/if-without-block.rs create mode 100644 src/test/ui/if-without-block.stderr diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 2046bbfa713a5..9aba2e9d52322 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -652,9 +652,11 @@ impl<'a> Parser<'a> { } else { let token_str = Parser::token_to_string(t); let this_token_str = self.this_token_to_string(); - Err(self.fatal(&format!("expected `{}`, found `{}`", - token_str, - this_token_str))) + let mut err = self.fatal(&format!("expected `{}`, found `{}`", + token_str, + this_token_str)); + err.span_label(self.span, format!("expected `{}`", token_str)); + Err(err) } } else { self.expect_one_of(unsafe { slice::from_raw_parts(t, 1) }, &[]) @@ -1172,7 +1174,7 @@ impl<'a> Parser<'a> { sep: SeqSep, f: F) -> PResult<'a, Vec> where - F: FnMut(&mut Parser<'a>) -> PResult<'a, T>, + F: FnMut(&mut Parser<'a>) -> PResult<'a, T>, { self.expect(bra)?; let result = self.parse_seq_to_before_end(ket, sep, f)?; @@ -1190,7 +1192,7 @@ impl<'a> Parser<'a> { sep: SeqSep, f: F) -> PResult<'a, Spanned>> where - F: FnMut(&mut Parser<'a>) -> PResult<'a, T>, + F: FnMut(&mut Parser<'a>) -> PResult<'a, T>, { let lo = self.span; self.expect(bra)?; @@ -3212,7 +3214,23 @@ impl<'a> Parser<'a> { err.span_label(sp, "expected if condition here"); return Err(err) } - let thn = self.parse_block()?; + let not_block = self.token != token::OpenDelim(token::Brace); + let fat_arrow_sp = if self.token == token::FatArrow { + Some(self.span) + } else { + None + }; + let thn = self.parse_block().map_err(|mut err| { + if let Some(sp) = fat_arrow_sp { + // if cond => expr + err.span_suggestion(sp, + "only necessary in match arms, not before if blocks", + "".to_string()); + } else if not_block { + err.span_label(lo, "this `if` statement has a condition, but no block"); + } + err + })?; let mut els: Option> = None; let mut hi = thn.span; if self.eat_keyword(keywords::Else) { @@ -3629,8 +3647,9 @@ impl<'a> Parser<'a> { self.bump(); if self.token != token::CloseDelim(token::Brace) { let token_str = self.this_token_to_string(); - return Err(self.fatal(&format!("expected `{}`, found `{}`", "}", - token_str))) + let mut err = self.fatal(&format!("expected `{}`, found `{}`", "}", token_str)); + err.span_label(self.span, "expected `}`"); + return Err(err); } etc = true; break; diff --git a/src/test/ui/did_you_mean/issue-40006.stderr b/src/test/ui/did_you_mean/issue-40006.stderr index 301441c5622f9..e576393500fea 100644 --- a/src/test/ui/did_you_mean/issue-40006.stderr +++ b/src/test/ui/did_you_mean/issue-40006.stderr @@ -19,7 +19,7 @@ error: expected `[`, found `#` --> $DIR/issue-40006.rs:20:17 | LL | fn xxx() { ### } //~ ERROR missing - | ^ + | ^ expected `[` error: missing `fn`, `type`, or `const` for trait-item declaration --> $DIR/issue-40006.rs:20:21 diff --git a/src/test/ui/if-without-block.rs b/src/test/ui/if-without-block.rs new file mode 100644 index 0000000000000..ce3de3b302dd3 --- /dev/null +++ b/src/test/ui/if-without-block.rs @@ -0,0 +1,18 @@ +// Copyright 2018 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. + +fn main() { + let n = 1; + if 5 == { + //~^ NOTE this `if` statement has a condition, but no block + println!("five"); + } +} +//~^ ERROR expected `{`, found `}` diff --git a/src/test/ui/if-without-block.stderr b/src/test/ui/if-without-block.stderr new file mode 100644 index 0000000000000..8f6e53bd28bf3 --- /dev/null +++ b/src/test/ui/if-without-block.stderr @@ -0,0 +1,11 @@ +error: expected `{`, found `}` + --> $DIR/if-without-block.rs:17:1 + | +13 | if 5 == { + | -- this `if` statement has a condition, but no block +... +17 | } + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/missing-block-hint.stderr b/src/test/ui/missing-block-hint.stderr index 54f394a4220dd..ae583d0d4ba4d 100644 --- a/src/test/ui/missing-block-hint.stderr +++ b/src/test/ui/missing-block-hint.stderr @@ -2,11 +2,13 @@ error: expected `{`, found `=>` --> $DIR/missing-block-hint.rs:13:18 | LL | if (foo) => {} //~ ERROR expected `{`, found `=>` - | ^^ + | ^^ help: only necessary in match arms, not before if blocks error: expected `{`, found `bar` --> $DIR/missing-block-hint.rs:17:13 | +LL | if (foo) + | -- this `if` statement has a condition, but no block LL | bar; //~ ERROR expected `{`, found `bar` | ^^^- | | From 36baa81be9f430329f5ea7b6bbb539e41105bfe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 18 Feb 2018 23:08:23 -0800 Subject: [PATCH 3/5] Add label to primary span in some parse errors --- src/libsyntax/parse/parser.rs | 85 ++++++++++++++----- src/test/ui/cross-file-errors/main.stderr | 2 +- src/test/ui/macro-context.stderr | 2 +- .../ui/resolve/token-error-correct.stderr | 2 +- src/test/ui/token/issue-10636-2.stderr | 2 +- 5 files changed, 68 insertions(+), 25 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9aba2e9d52322..6653e6672183e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1487,7 +1487,10 @@ impl<'a> Parser<'a> { } _ => { let token_str = self.this_token_to_string(); - return Err(self.fatal(&format!("expected `;` or `{{`, found `{}`", token_str))); + let mut err = self.fatal(&format!("expected `;` or `{{`, found `{}`", + token_str)); + err.span_label(self.span, "expected `;` or `{`"); + return Err(err); } }; (ident, ast::TraitItemKind::Method(sig, body), generics) @@ -2218,7 +2221,12 @@ impl<'a> Parser<'a> { TokenTree::Delimited(_, delimited) => Ok((delim, delimited.stream().into())), _ => unreachable!(), }, - _ => Err(self.fatal("expected open delimiter")), + _ => { + let msg = "expected open delimiter"; + let mut err = self.fatal(msg); + err.span_label(self.span, msg); + Err(err) + } } } @@ -2351,7 +2359,10 @@ impl<'a> Parser<'a> { if self.eat_keyword(keywords::Loop) { return self.parse_loop_expr(Some(label), lo, attrs) } - return Err(self.fatal("expected `while`, `for`, or `loop` after a label")) + let msg = "expected `while`, `for`, or `loop` after a label"; + let mut err = self.fatal(msg); + err.span_label(self.span, msg); + return Err(err); } if self.eat_keyword(keywords::Loop) { let lo = self.prev_span; @@ -2410,6 +2421,7 @@ impl<'a> Parser<'a> { // Catch this syntax error here, instead of in `parse_ident`, so // that we can explicitly mention that let is not to be used as an expression let mut db = self.fatal("expected expression, found statement (`let`)"); + db.span_label(self.span, "expected expression"); db.note("variable declaration using `let` is a statement"); return Err(db); } else if self.token.is_path_start() { @@ -2445,7 +2457,9 @@ impl<'a> Parser<'a> { self.cancel(&mut err); let msg = format!("expected expression, found {}", self.this_token_descr()); - return Err(self.fatal(&msg)); + let mut err = self.fatal(&msg); + err.span_label(self.span, "expected expression"); + return Err(err); } } } @@ -2735,7 +2749,9 @@ impl<'a> Parser<'a> { self.look_ahead(1, |t| t.is_ident()) => { self.bump(); let name = match self.token { token::Ident(ident) => ident, _ => unreachable!() }; - self.fatal(&format!("unknown macro variable `{}`", name)).emit(); + let mut err = self.fatal(&format!("unknown macro variable `{}`", name)); + err.span_label(self.span, "unknown macro variable"); + err.emit(); return } token::Interpolated(ref nt) => { @@ -3760,7 +3776,10 @@ impl<'a> Parser<'a> { self.expect_and()?; let mutbl = self.parse_mutability(); if let token::Lifetime(ident) = self.token { - return Err(self.fatal(&format!("unexpected lifetime `{}` in pattern", ident))); + let mut err = self.fatal(&format!("unexpected lifetime `{}` in pattern", + ident)); + err.span_label(self.span, "unexpected lifetime"); + return Err(err); } let subpat = self.parse_pat()?; pat = PatKind::Ref(subpat, mutbl); @@ -3843,7 +3862,10 @@ impl<'a> Parser<'a> { } token::OpenDelim(token::Brace) => { if qself.is_some() { - return Err(self.fatal("unexpected `{` after qualified path")); + let msg = "unexpected `{` after qualified path"; + let mut err = self.fatal(msg); + err.span_label(self.span, msg); + return Err(err); } // Parse struct pattern self.bump(); @@ -3857,7 +3879,10 @@ impl<'a> Parser<'a> { } token::OpenDelim(token::Paren) => { if qself.is_some() { - return Err(self.fatal("unexpected `(` after qualified path")); + let msg = "unexpected `(` after qualified path"; + let mut err = self.fatal(msg); + err.span_label(self.span, msg); + return Err(err); } // Parse tuple struct or enum pattern self.bump(); @@ -3889,7 +3914,9 @@ impl<'a> Parser<'a> { Err(mut err) => { self.cancel(&mut err); let msg = format!("expected pattern, found {}", self.this_token_descr()); - return Err(self.fatal(&msg)); + let mut err = self.fatal(&msg); + err.span_label(self.span, "expected pattern"); + return Err(err); } } } @@ -4289,9 +4316,11 @@ impl<'a> Parser<'a> { "" }; let tok_str = self.this_token_to_string(); - return Err(self.fatal(&format!("expected {}`(` or `{{`, found `{}`", - ident_str, - tok_str))) + let mut err = self.fatal(&format!("expected {}`(` or `{{`, found `{}`", + ident_str, + tok_str)); + err.span_label(self.span, format!("expected {}`(` or `{{`", ident_str)); + return Err(err) }, }; @@ -5598,8 +5627,12 @@ impl<'a> Parser<'a> { body } else { let token_str = self.this_token_to_string(); - return Err(self.fatal(&format!("expected `where`, `{{`, `(`, or `;` after struct \ - name, found `{}`", token_str))) + let mut err = self.fatal(&format!( + "expected `where`, `{{`, `(`, or `;` after struct name, found `{}`", + token_str + )); + err.span_label(self.span, "expected `where`, `{`, `(`, or `;` after struct name"); + return Err(err); }; Ok((class_name, ItemKind::Struct(vdata, generics), None)) @@ -5618,8 +5651,10 @@ impl<'a> Parser<'a> { VariantData::Struct(self.parse_record_struct_body()?, ast::DUMMY_NODE_ID) } else { let token_str = self.this_token_to_string(); - return Err(self.fatal(&format!("expected `where` or `{{` after union \ - name, found `{}`", token_str))) + let mut err = self.fatal(&format!( + "expected `where` or `{{` after union name, found `{}`", token_str)); + err.span_label(self.span, "expected `where` or `{` after union name"); + return Err(err); }; Ok((class_name, ItemKind::Union(vdata, generics), None)) @@ -5666,9 +5701,10 @@ impl<'a> Parser<'a> { self.eat(&token::CloseDelim(token::Brace)); } else { let token_str = self.this_token_to_string(); - return Err(self.fatal(&format!("expected `where`, or `{{` after struct \ - name, found `{}`", - token_str))); + let mut err = self.fatal(&format!( + "expected `where`, or `{{` after struct name, found `{}`", token_str)); + err.span_label(self.span, "expected `where`, or `{` after struct name"); + return Err(err); } Ok(fields) @@ -5841,9 +5877,11 @@ 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 == ";" { + let msg = "consider removing this semicolon"; err.span_suggestion_short(self.span, msg, "".to_string()); + } else { + err.span_label(self.span, "expected item"); } return Err(err); } @@ -7000,7 +7038,12 @@ impl<'a> Parser<'a> { self.expect_no_suffix(sp, "string literal", suf); Ok((s, style)) } - _ => Err(self.fatal("expected string literal")) + _ => { + let msg = "expected string literal"; + let mut err = self.fatal(msg); + err.span_label(self.span, msg); + Err(err) + } } } } diff --git a/src/test/ui/cross-file-errors/main.stderr b/src/test/ui/cross-file-errors/main.stderr index 9eeea28be8fec..a9db5214e6a2e 100644 --- a/src/test/ui/cross-file-errors/main.stderr +++ b/src/test/ui/cross-file-errors/main.stderr @@ -2,7 +2,7 @@ error: expected expression, found `_` --> $DIR/underscore.rs:18:9 | LL | _ - | ^ + | ^ expected expression | ::: $DIR/main.rs:15:5 | diff --git a/src/test/ui/macro-context.stderr b/src/test/ui/macro-context.stderr index 65bbe09a212da..4dc6bbe4d656c 100644 --- a/src/test/ui/macro-context.stderr +++ b/src/test/ui/macro-context.stderr @@ -38,7 +38,7 @@ error: expected expression, found reserved keyword `typeof` --> $DIR/macro-context.rs:13:17 | LL | () => ( i ; typeof ); //~ ERROR expected expression, found reserved keyword `typeof` - | ^^^^^^ + | ^^^^^^ expected expression ... LL | m!(); | ----- in this macro invocation diff --git a/src/test/ui/resolve/token-error-correct.stderr b/src/test/ui/resolve/token-error-correct.stderr index 344c288b596e0..c6d32c6726ea5 100644 --- a/src/test/ui/resolve/token-error-correct.stderr +++ b/src/test/ui/resolve/token-error-correct.stderr @@ -26,7 +26,7 @@ error: expected expression, found `;` --> $DIR/token-error-correct.rs:14:13 | LL | foo(bar(; - | ^ + | ^ expected expression error: aborting due to 3 previous errors diff --git a/src/test/ui/token/issue-10636-2.stderr b/src/test/ui/token/issue-10636-2.stderr index fcd2c10594a3c..26816ca0ca22a 100644 --- a/src/test/ui/token/issue-10636-2.stderr +++ b/src/test/ui/token/issue-10636-2.stderr @@ -20,7 +20,7 @@ error: expected expression, found `)` --> $DIR/issue-10636-2.rs:18:1 | LL | } //~ ERROR: incorrect close delimiter - | ^ + | ^ expected expression error[E0601]: main function not found From d63d363ef9d6627dc9649477b337a3f915d0660e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 23 Feb 2018 19:38:36 -0800 Subject: [PATCH 4/5] Diagnostic tweaks (review) --- src/libsyntax/parse/parser.rs | 28 ++++++++----------- src/test/ui/missing-block-hint.stderr | 4 ++- .../ui/suggestions/missing-comma-in-match.rs | 1 - .../suggestions/missing-comma-in-match.stderr | 4 +-- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6653e6672183e..69b2723449849 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3231,18 +3231,8 @@ impl<'a> Parser<'a> { return Err(err) } let not_block = self.token != token::OpenDelim(token::Brace); - let fat_arrow_sp = if self.token == token::FatArrow { - Some(self.span) - } else { - None - }; let thn = self.parse_block().map_err(|mut err| { - if let Some(sp) = fat_arrow_sp { - // if cond => expr - err.span_suggestion(sp, - "only necessary in match arms, not before if blocks", - "".to_string()); - } else if not_block { + if not_block { err.span_label(lo, "this `if` statement has a condition, but no block"); } err @@ -3444,7 +3434,7 @@ impl<'a> Parser<'a> { let expr = self.parse_expr_res(Restrictions::STMT_EXPR, None) .map_err(|mut err| { - err.span_label(arrow_span, "while parsing the match arm starting here"); + err.span_label(arrow_span, "while parsing the `match` arm starting here"); err })?; @@ -3455,7 +3445,6 @@ impl<'a> Parser<'a> { let cm = self.sess.codemap(); self.expect_one_of(&[token::Comma], &[token::CloseDelim(token::Brace)]) .map_err(|mut err| { - err.span_label(arrow_span, "while parsing the match arm starting here"); match (cm.span_to_lines(expr.span), cm.span_to_lines(arm_start_span)) { (Ok(ref expr_lines), Ok(ref arm_start_lines)) if arm_start_lines.lines[0].end_col == expr_lines.lines[0].end_col @@ -3472,11 +3461,16 @@ impl<'a> Parser<'a> { // | - ^^ self.span // | | // | parsed until here as `"y" & X` - err.span_suggestion_short(cm.next_point(arm_start_span), - "missing a comma here to end this match arm", - ",".to_owned()); + err.span_suggestion_short( + cm.next_point(arm_start_span), + "missing a comma here to end this `match` arm", + ",".to_owned() + ); + } + _ => { + err.span_label(arrow_span, + "while parsing the `match` arm starting here"); } - _ => {} } err })?; diff --git a/src/test/ui/missing-block-hint.stderr b/src/test/ui/missing-block-hint.stderr index ae583d0d4ba4d..a48eff890b331 100644 --- a/src/test/ui/missing-block-hint.stderr +++ b/src/test/ui/missing-block-hint.stderr @@ -2,7 +2,9 @@ error: expected `{`, found `=>` --> $DIR/missing-block-hint.rs:13:18 | LL | if (foo) => {} //~ ERROR expected `{`, found `=>` - | ^^ help: only necessary in match arms, not before if blocks + | -- ^^ + | | + | this `if` statement has a condition, but no block error: expected `{`, found `bar` --> $DIR/missing-block-hint.rs:17:13 diff --git a/src/test/ui/suggestions/missing-comma-in-match.rs b/src/test/ui/suggestions/missing-comma-in-match.rs index e02a8df3343b3..6f86cdea3cf5e 100644 --- a/src/test/ui/suggestions/missing-comma-in-match.rs +++ b/src/test/ui/suggestions/missing-comma-in-match.rs @@ -14,7 +14,6 @@ fn main() { &Some(2) => { 3 } //~^ ERROR expected one of `,`, `.`, `?`, `}`, or an operator, found `=>` //~| NOTE expected one of `,`, `.`, `?`, `}`, or an operator here - //~^^^^ NOTE while parsing the match arm starting here _ => 2 }; } diff --git a/src/test/ui/suggestions/missing-comma-in-match.stderr b/src/test/ui/suggestions/missing-comma-in-match.stderr index 864fde49a5e51..71123a160a5f8 100644 --- a/src/test/ui/suggestions/missing-comma-in-match.stderr +++ b/src/test/ui/suggestions/missing-comma-in-match.stderr @@ -2,9 +2,7 @@ error: expected one of `,`, `.`, `?`, `}`, or an operator, found `=>` --> $DIR/missing-comma-in-match.rs:14:18 | 13 | &None => 1 - | -- - help: missing a comma here to end this match arm - | | - | while parsing the match arm starting here + | - help: missing a comma here to end this `match` arm 14 | &Some(2) => { 3 } | ^^ expected one of `,`, `.`, `?`, `}`, or an operator here From 24be75d420bf316cb09c179781d6c1c63636fbc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 28 Feb 2018 10:56:07 -0800 Subject: [PATCH 5/5] fix rebase --- src/test/ui/if-without-block.stderr | 4 ++-- src/test/ui/suggestions/missing-comma-in-match.stderr | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/ui/if-without-block.stderr b/src/test/ui/if-without-block.stderr index 8f6e53bd28bf3..bc8e7310ce371 100644 --- a/src/test/ui/if-without-block.stderr +++ b/src/test/ui/if-without-block.stderr @@ -1,10 +1,10 @@ error: expected `{`, found `}` --> $DIR/if-without-block.rs:17:1 | -13 | if 5 == { +LL | if 5 == { | -- this `if` statement has a condition, but no block ... -17 | } +LL | } | ^ error: aborting due to previous error diff --git a/src/test/ui/suggestions/missing-comma-in-match.stderr b/src/test/ui/suggestions/missing-comma-in-match.stderr index 71123a160a5f8..b71a50b66318e 100644 --- a/src/test/ui/suggestions/missing-comma-in-match.stderr +++ b/src/test/ui/suggestions/missing-comma-in-match.stderr @@ -1,9 +1,9 @@ error: expected one of `,`, `.`, `?`, `}`, or an operator, found `=>` --> $DIR/missing-comma-in-match.rs:14:18 | -13 | &None => 1 +LL | &None => 1 | - help: missing a comma here to end this `match` arm -14 | &Some(2) => { 3 } +LL | &Some(2) => { 3 } | ^^ expected one of `,`, `.`, `?`, `}`, or an operator here error: aborting due to previous error