Skip to content

Commit 5626346

Browse files
committed
Fixes to span locations
1 parent a29a624 commit 5626346

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

compiler/rustc_errors/src/emitter.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -1679,15 +1679,14 @@ impl EmitterWriter {
16791679
// Colorize addition/replacements with green.
16801680
for &SubstitutionHighlight { start, end } in highlight_parts {
16811681
// Account for tabs when highlighting (#87972).
1682-
// let tabs: usize = line
1683-
// .chars()
1684-
// .take(start)
1685-
// .map(|ch| match ch {
1686-
// '\t' => 3,
1687-
// _ => 0,
1688-
// })
1689-
// .sum();
1690-
let tabs = 0;
1682+
let tabs: usize = line
1683+
.chars()
1684+
.take(start)
1685+
.map(|ch| match ch {
1686+
'\t' => 3,
1687+
_ => 0,
1688+
})
1689+
.sum();
16911690
buffer.set_style_range(
16921691
row_num,
16931692
max_line_num_len + 3 + start + tabs,

compiler/rustc_errors/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,11 @@ impl CodeSuggestion {
297297
count -= 1;
298298
}
299299
} else {
300+
acc = 0;
300301
highlights.push(std::mem::take(&mut line_highlight));
301302
let mut count = push_trailing(&mut buf, prev_line.as_ref(), &prev_hi, None);
302303
while count > 0 {
303304
highlights.push(std::mem::take(&mut line_highlight));
304-
acc = 0;
305305
count -= 1;
306306
}
307307
// push lines between the previous and current span (if any)
@@ -310,7 +310,6 @@ impl CodeSuggestion {
310310
buf.push_str(line.as_ref());
311311
buf.push('\n');
312312
highlights.push(std::mem::take(&mut line_highlight));
313-
acc = 0;
314313
}
315314
}
316315
if let Some(cur_line) = sf.get_line(cur_lo.line - 1) {

0 commit comments

Comments
 (0)