Skip to content

Commit 46ffe9d

Browse files
committed
Prioritize Primary underline for overlapping spans of same length
1 parent b5b9299 commit 46ffe9d

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

src/librustc_errors/emitter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,8 @@ impl EmitterWriter {
678678
// | | something about `foo`
679679
// | something about `fn foo()`
680680
annotations_position.sort_by(|a, b| {
681-
// Decreasing order
682-
a.1.len().cmp(&b.1.len()).reverse()
681+
// Decreasing order. When `a` and `b` are the same length, prefer `Primary`.
682+
(a.1.len(), !a.1.is_primary).cmp(&(b.1.len(), !b.1.is_primary)).reverse()
683683
});
684684

685685
// Write the underlines.

src/test/ui/augmented-assignments.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | x //~ error: use of moved value: `x`
99
LL | | //~^ value used here after move
1010
LL | | +=
1111
LL | | x; //~ value moved here
12-
| | -
12+
| | ^
1313
| | |
1414
| |_____move out of `x` occurs here
1515
| borrow later used here

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;`
1313
--> $DIR/token-error-correct-3.rs:24:35
1414
|
1515
LL | callback(path.as_ref();
16-
| - -
16+
| - ^
1717
| | |
1818
| | expected one of `)`, `,`, `.`, `?`, or an operator here
1919
| | help: ...the missing `)` may belong here

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ error: expected expression, found `;`
1313
--> $DIR/token-error-correct.rs:14:13
1414
|
1515
LL | foo(bar(;
16-
| - -
16+
| - ^
1717
| | |
1818
| | expected expression
1919
| | help: ...the missing `)` may belong here
@@ -23,7 +23,7 @@ error: expected one of `)`, `,`, `-`, `.`, `<`, `?`, `break`, `continue`, `false
2323
--> $DIR/token-error-correct.rs:14:13
2424
|
2525
LL | foo(bar(;
26-
| --
26+
| -^
2727
| ||
2828
| |expected one of 21 possible tokens here
2929
| |help: ...the missing `)` may belong here

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;`
1313
--> $DIR/issue-10636-2.rs:15:25
1414
|
1515
LL | option.map(|some| 42;
16-
| - -
16+
| - ^
1717
| | |
1818
| | expected one of `)`, `,`, `.`, `?`, or an operator here
1919
| | help: ...the missing `)` may belong here

0 commit comments

Comments
 (0)