Skip to content

Commit 9e25598

Browse files
committed
fix: Match rustc's annotation overlap
1 parent 268088f commit 9e25598

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/renderer/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ impl Renderer {
11671167
// otherwise the lines would end up needing to go over a message.
11681168

11691169
let mut annotations = line_info.annotations.clone();
1170-
annotations.sort_by_key(|a| Reverse(a.start.display));
1170+
annotations.sort_by_key(|a| Reverse((a.start.display, a.start.char)));
11711171

11721172
// First, figure out where each label will be positioned.
11731173
//
@@ -1250,7 +1250,9 @@ impl Renderer {
12501250
// If we're overlapping with an un-labelled annotation with the same span
12511251
// we can just merge them in the output
12521252
if next.start.display == annotation.start.display
1253+
&& next.start.char == annotation.start.char
12531254
&& next.end.display == annotation.end.display
1255+
&& next.end.char == annotation.end.char
12541256
&& !next.has_label()
12551257
{
12561258
continue;
@@ -1284,7 +1286,7 @@ impl Renderer {
12841286
&& next.takes_space())
12851287
|| (annotation.takes_space() && next.takes_space())
12861288
|| (overlaps(next, annotation, l)
1287-
&& next.end.display <= annotation.end.display
1289+
&& (next.end.display, next.end.char) <= (annotation.end.display, annotation.end.char)
12881290
&& next.has_label()
12891291
&& p == 0)
12901292
// Avoid #42595.

tests/rustc_tests.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3500,8 +3500,9 @@ error: extern blocks should be unsafe
35003500
--> $DIR/unsafe-extern-suggestion.rs:6:1
35013501
|
35023502
LL | extern "C" {
3503-
| ^ help: needs `unsafe` before the extern keyword: `unsafe`
3504-
| _|
3503+
| ^
3504+
| |
3505+
| _help: needs `unsafe` before the extern keyword: `unsafe`
35053506
| |
35063507
LL | | //~^ ERROR extern blocks should be unsafe [missing_unsafe_on_extern]
35073508
LL | | //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!

0 commit comments

Comments
 (0)