Skip to content

Commit f64703c

Browse files
authored
Rollup merge of #147354 - chenyukang:yukang-fix-147070-wrong-highlight-span, r=estebank
Fix wrong span for hightlight for duplicated diff lines Fixes #147070 From comments: #147070 (comment) The lightlight row for diff must at least 2. r? `@estebank`
2 parents 4209a46 + 231c395 commit f64703c

File tree

3 files changed

+103
-1
lines changed

3 files changed

+103
-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: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//@ only-linux
2+
//@ compile-flags: --error-format=human --color=always
3+
4+
// The hightlight span should be correct. See #147070
5+
struct Thingie;
6+
7+
impl Thingie {
8+
pub(crate) fn new(
9+
_a: String,
10+
_b: String,
11+
_c: String,
12+
_d: String,
13+
_e: String,
14+
_f: String,
15+
) -> Self {
16+
unimplemented!()
17+
}
18+
}
19+
20+
fn main() {
21+
let foo = Thingie::new(
22+
String::from(""),
23+
String::from(""),
24+
String::from(""),
25+
String::from(""),
26+
String::from(""),
27+
String::from(""),
28+
String::from(""),
29+
);
30+
}
Lines changed: 72 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)