Skip to content

Commit 62068a5

Browse files
committed
repairing broken error message and rustfix application for the new test
case
1 parent f9059a4 commit 62068a5

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

compiler/rustc_parse/src/parser/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -694,9 +694,13 @@ impl<'a> Parser<'a> {
694694
Ok(t) => {
695695
// Parsed successfully, therefore most probably the code only
696696
// misses a separator.
697+
let mut exp_span = self.sess.source_map().next_point(sp);
698+
if self.sess.source_map().is_multiline(exp_span) {
699+
exp_span = sp;
700+
}
697701
expect_err
698702
.span_suggestion_short(
699-
self.sess.source_map().next_point(sp),
703+
exp_span,
700704
&format!("missing `{}`", token_str),
701705
token_str,
702706
Applicability::MaybeIncorrect,

src/test/ui/issue-76597.fixed

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// run-rustfix
2+
3+
#![allow(dead_code)]
4+
#![allow(unused_variables)]
5+
fn f(
6+
x: u8,
7+
y: u8,
8+
) {}
9+
//~^^ ERROR: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `y`
10+
11+
fn main() {}

src/test/ui/issue-76597.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// run-rustfix
2+
3+
#![allow(dead_code)]
4+
#![allow(unused_variables)]
15
fn f(
26
x: u8
37
y: u8,

src/test/ui/issue-76597.stderr

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `y`
2-
--> $DIR/issue-76597.rs:3:38
2+
--> $DIR/issue-76597.rs:7:38
33
|
4-
LL | ... x: u8
5-
| - expected one of 7 possible tokens
6-
| ____________________________|
7-
| |
8-
LL | | ... y: u8,
9-
| | | ^ unexpected token
10-
| | |
11-
| help: missing `,`
4+
LL | ... x: u8
5+
| -
6+
| |
7+
| expected one of 7 possible tokens
8+
| help: missing `,`
9+
LL | ... y: u8,
10+
| ^ unexpected token
1211

1312
error: aborting due to previous error
1413

0 commit comments

Comments
 (0)