Skip to content

Commit

Permalink
repairing broken error message and rustfix application for the new test
Browse files Browse the repository at this point in the history
case
  • Loading branch information
ad-anssi committed Sep 11, 2020
1 parent f9059a4 commit 62068a5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
6 changes: 5 additions & 1 deletion compiler/rustc_parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,13 @@ impl<'a> Parser<'a> {
Ok(t) => {
// Parsed successfully, therefore most probably the code only
// misses a separator.
let mut exp_span = self.sess.source_map().next_point(sp);
if self.sess.source_map().is_multiline(exp_span) {
exp_span = sp;
}
expect_err
.span_suggestion_short(
self.sess.source_map().next_point(sp),
exp_span,
&format!("missing `{}`", token_str),
token_str,
Applicability::MaybeIncorrect,
Expand Down
11 changes: 11 additions & 0 deletions src/test/ui/issue-76597.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// run-rustfix

#![allow(dead_code)]
#![allow(unused_variables)]
fn f(
x: u8,
y: u8,
) {}
//~^^ ERROR: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `y`

fn main() {}
4 changes: 4 additions & 0 deletions src/test/ui/issue-76597.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// run-rustfix

#![allow(dead_code)]
#![allow(unused_variables)]
fn f(
x: u8
y: u8,
Expand Down
17 changes: 8 additions & 9 deletions src/test/ui/issue-76597.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `y`
--> $DIR/issue-76597.rs:3:38
--> $DIR/issue-76597.rs:7:38
|
LL | ... x: u8
| - expected one of 7 possible tokens
| ____________________________|
| |
LL | | ... y: u8,
| | | ^ unexpected token
| | |
| help: missing `,`
LL | ... x: u8
| -
| |
| expected one of 7 possible tokens
| help: missing `,`
LL | ... y: u8,
| ^ unexpected token

error: aborting due to previous error

0 comments on commit 62068a5

Please sign in to comment.