Skip to content

Commit 8d4d1f6

Browse files
committed
Fix wrong span for hightlight for duplicated diff lines
1 parent 2cb4e7d commit 8d4d1f6

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

compiler/rustc_errors/src/emitter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2412,7 +2412,7 @@ impl HumanEmitter {
24122412
// too bad to begin with, so we side-step that issue here.
24132413
for (i, line) in snippet.lines().enumerate() {
24142414
let line = normalize_whitespace(line);
2415-
let row = row_num - 2 - (newlines - i - 1);
2415+
let row = (row_num - 2 - (newlines - i - 1)).max(2);
24162416
// On the first line, we highlight between the start of the part
24172417
// span, and the end of that line.
24182418
// On the last line, we highlight between the start of the line, and
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
struct Thingie;
2+
3+
impl Thingie {
4+
pub(crate) fn new(
5+
_a: String,
6+
_b: String,
7+
_c: String,
8+
_d: String,
9+
_e: String,
10+
_f: String,
11+
) -> Self {
12+
unimplemented!()
13+
}
14+
}
15+
16+
fn main() {
17+
let foo = Thingie::new( //~ ERROR: this function takes 6 arguments but 7 arguments were supplied
18+
String::from(""),
19+
String::from(""),
20+
String::from(""),
21+
String::from(""),
22+
String::from(""),
23+
String::from(""),
24+
String::from(""),
25+
);
26+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error[E0061]: this function takes 6 arguments but 7 arguments were supplied
2+
--> $DIR/wrong-highlight-span-extra-arguments-147070.rs:17:15
3+
|
4+
LL | let foo = Thingie::new(
5+
| ^^^^^^^^^^^^
6+
...
7+
LL | String::from(""),
8+
| ---------------- unexpected argument #7 of type `String`
9+
|
10+
note: associated function defined here
11+
--> $DIR/wrong-highlight-span-extra-arguments-147070.rs:4:19
12+
|
13+
LL | pub(crate) fn new(
14+
| ^^^
15+
help: remove the extra argument
16+
|
17+
LL - String::from(""),
18+
|
19+
20+
error: aborting due to 1 previous error
21+
22+
For more information about this error, try `rustc --explain E0061`.

0 commit comments

Comments
 (0)