Skip to content

Commit 4a073dd

Browse files
committed
Fix rust-lang#58270, fix off-by-one error in error diagnostics.
1 parent c21fbfe commit 4a073dd

7 files changed

+19
-18
lines changed

src/librustc_errors/emitter.rs

+10
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ impl EmitterWriter {
268268
// 6..7. This is degenerate input, but it's best to degrade
269269
// gracefully -- and the parser likes to supply a span like
270270
// that for EOF, in particular.
271+
271272
if lo.col_display == hi.col_display && lo.line == hi.line {
272273
hi.col_display += 1;
273274
}
@@ -547,6 +548,15 @@ impl EmitterWriter {
547548
&& j > i // multiline lines).
548549
&& p == 0 // We're currently on the first line, move the label one line down
549550
{
551+
// If we're overlapping with an un-labelled annotation with the same span
552+
// we can just merge them in the output
553+
if next.start_col == annotation.start_col
554+
&& next.end_col == annotation.end_col
555+
&& !next.has_label()
556+
{
557+
continue;
558+
}
559+
550560
// This annotation needs a new line in the output.
551561
p += 1;
552562
break;

src/test/ui/issue-60075.stderr

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ LL | fn qux() -> Option<usize> {
1111
| - unclosed delimiter
1212
LL | let _ = if true {
1313
LL | });
14-
| ^
15-
| |
16-
| help: `}` may belong here
14+
| ^ help: `}` may belong here
1715

1816
error: expected identifier, found `;`
1917
--> $DIR/issue-60075.rs:6:11

src/test/ui/issues/issue-58856-1.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ error: expected one of `)`, `,`, or `:`, found `>`
22
--> $DIR/issue-58856-1.rs:2:14
33
|
44
LL | fn b(self>
5-
| - ^
6-
| | |
7-
| | help: `)` may belong here
5+
| - ^ help: `)` may belong here
6+
| |
87
| unclosed delimiter
98

109
error: aborting due to previous error

src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ error[E0623]: lifetime mismatch
22
--> $DIR/ex3-both-anon-regions-both-are-structs-3.rs:7:11
33
|
44
LL | fn foo(mut x: Ref) {
5-
| ---
6-
| |
7-
| this type is declared with multiple lifetimes...
5+
| --- this type is declared with multiple lifetimes...
86
LL | x.a = x.b;
97
| ^^^ ...but data with one lifetime flows into the other here
108

src/test/ui/parser/issue-10636-2.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;`
22
--> $DIR/issue-10636-2.rs:5:25
33
|
44
LL | option.map(|some| 42;
5-
| - ^
6-
| | |
7-
| | help: `)` may belong here
5+
| - ^ help: `)` may belong here
6+
| |
87
| unclosed delimiter
98

109
error: expected expression, found `)`

src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.stderr

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ error[E0623]: lifetime mismatch
22
--> $DIR/regions-variance-contravariant-use-covariant-in-second-position.rs:25:30
33
|
44
LL | fn use_<'short,'long>(c: S<'long, 'short>,
5-
| ----------------
6-
| |
7-
| this type is declared with multiple lifetimes...
5+
| ---------------- this type is declared with multiple lifetimes...
86
...
97
LL | let _: S<'long, 'long> = c;
108
| ^ ...but data with one lifetime flows into the other here

src/test/ui/resolve/token-error-correct-3.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;`
22
--> $DIR/token-error-correct-3.rs:15:35
33
|
44
LL | callback(path.as_ref();
5-
| - ^
6-
| | |
7-
| | help: `)` may belong here
5+
| - ^ help: `)` may belong here
6+
| |
87
| unclosed delimiter
98

109
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `)`

0 commit comments

Comments
 (0)