Skip to content

Commit c8041fe

Browse files
committed
fix: Match rustc's multiline reordering
1 parent a4c20fb commit c8041fe

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

src/renderer/source_map.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,7 @@ impl<'a> SourceMap<'a> {
194194
let mut primary_spans = vec![];
195195

196196
// Find overlapping multiline annotations, put them at different depths
197-
multiline_annotations
198-
.sort_by_key(|ml| (ml.start.line, usize::MAX - ml.end.line, ml.start.byte));
197+
multiline_annotations.sort_by_key(|ml| (ml.start.line, usize::MAX - ml.end.line));
199198
for ann in multiline_annotations.clone() {
200199
if ann.kind.is_primary() {
201200
primary_spans.push((ann.start, ann.end));

tests/formatter.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -887,15 +887,15 @@ bar = { version = "0.1.0", optional = true }
887887
error: unused optional dependency
888888
|
889889
4 | bar = { version = "0.1.0", optional = true }
890-
| _________^__________________--------------^
891-
| | | |
892-
| |_________| This should also be long but not too long
890+
| __________^__________________--------------^
891+
| | | |
892+
| | _________| This should also be long but not too long
893893
| ||
894894
5 | || this is another line
895895
6 | || so is this
896896
7 | || bar = { version = "0.1.0", optional = true }
897897
| ||_________________________^________________^ I need this to be really long so I can test overlaps
898-
| |__________________________|
898+
| |_________________________|
899899
| I need this to be really long so I can test overlaps
900900
"#]];
901901
let renderer = Renderer::plain();
@@ -940,16 +940,16 @@ this is another line
940940
error: unused optional dependency
941941
|
942942
4 | bar = { version = "0.1.0", optional = true }
943-
| __________^__________________--------------^
944-
| | | |
945-
| |__________| This should also be long but not too long
943+
| ___________^__________________--------------^
944+
| | | |
945+
| | __________| This should also be long but not too long
946946
| ||
947947
5 | || this is another line
948948
| || ____^
949949
6 | ||| so is this
950950
7 | ||| bar = { version = "0.1.0", optional = true }
951951
| |||_________________________^________________^ I need this to be really long so I can test overlaps
952-
| |_|_________________________|
952+
| ||_________________________|
953953
| | I need this to be really long so I can test overlaps
954954
8 | | this is another line
955955
| |____^ I need this to be really long so I can test overlaps

tests/rustc_tests.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,19 +2087,19 @@ fn main() {
20872087
error: `Iterator::map` call that discard the iterator's values
20882088
--> $DIR/lint_map_unit_fn.rs:11:18
20892089
|
2090-
LL | x.iter_mut().map(|items| {
2091-
| ^ -------
2092-
| | |
2093-
| __________________|___this function returns `()`, which is likely not what you wanted
2094-
| |__________________|
2095-
| ||
2096-
LL | || //~^ ERROR `Iterator::map` call that discard the iterator's values
2097-
LL | || items.sort();
2098-
LL | || });
2099-
| || -^ after this call to map, the resulting iterator is `impl Iterator<Item = ()>`, which means the only information carried by the iterator is the number of items
2100-
| ||_____||
2101-
| |_____|
2102-
| called `Iterator::map` with callable that returns `()`
2090+
LL | x.iter_mut().map(|items| {
2091+
| ^ -------
2092+
| | |
2093+
| ____________________|___this function returns `()`, which is likely not what you wanted
2094+
| | __________________|
2095+
| | |
2096+
LL | | | //~^ ERROR `Iterator::map` call that discard the iterator's values
2097+
LL | | | items.sort();
2098+
LL | | | });
2099+
| | | -^ after this call to map, the resulting iterator is `impl Iterator<Item = ()>`, which means the only information carried by the iterator is the number of items
2100+
| | |_____||
2101+
| |_______|
2102+
| called `Iterator::map` with callable that returns `()`
21032103
|
21042104
= note: `Iterator::map`, like many of the methods on `Iterator`, gets executed lazily, meaning that its effects won't be visible until it is iterated
21052105
help: you might have meant to use `Iterator::for_each`

0 commit comments

Comments
 (0)