reorder span labels
This commit is contained in:
parent
5803f99bd4
commit
26a8357f5c
@ -346,9 +346,20 @@ impl EmitterWriter {
|
||||
// and "annotations lines", where the highlight lines have the `^`.
|
||||
|
||||
// Sort the annotations by (start, end col)
|
||||
// The labels are reversed, sort and then reversed again.
|
||||
// Consider a list of annotations (A1, A2, C1, C2, B1, B2) where
|
||||
// the letter signifies the span. Here we are only sorting by the
|
||||
// span and hence, the order of the elements with the same span will
|
||||
// not change. On reversing the ordering (|a, b| but b.cmp(a)), you get
|
||||
// (C1, C2, B1, B2, A1, A2). All the elements with the same span are
|
||||
// still ordered first to last, but all the elements with different
|
||||
// spans are ordered by their spans in last to first order. Last to
|
||||
// first order is important, because the jiggly lines and | are on
|
||||
// the left, so the rightmost span needs to be rendered first,
|
||||
// otherwise the lines would end up needing to go over a message.
|
||||
|
||||
let mut annotations = line.annotations.clone();
|
||||
annotations.sort();
|
||||
annotations.reverse();
|
||||
annotations.sort_by(|a,b| b.start_col.cmp(&a.start_col));
|
||||
|
||||
// First, figure out where each label will be positioned.
|
||||
//
|
||||
|
@ -4,8 +4,8 @@ error[E0596]: cannot borrow immutable argument `self` as mutable
|
||||
17 | (&mut self).bar();
|
||||
| ^^^^
|
||||
| |
|
||||
| try removing `&mut` here
|
||||
| cannot reborrow mutably
|
||||
| try removing `&mut` here
|
||||
|
||||
error[E0596]: cannot borrow immutable argument `self` as mutable
|
||||
--> $DIR/issue-31424.rs:23:15
|
||||
|
@ -4,8 +4,8 @@ error[E0596]: cannot borrow immutable argument `self` as mutable
|
||||
16 | self.run(&mut self);
|
||||
| ^^^^
|
||||
| |
|
||||
| try removing `&mut` here
|
||||
| cannot reborrow mutably
|
||||
| try removing `&mut` here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -4,8 +4,8 @@ error[E0596]: cannot borrow immutable local variable `key` as mutable
|
||||
16 | get(&mut key);
|
||||
| ^^^
|
||||
| |
|
||||
| try removing `&mut` here
|
||||
| cannot reborrow mutably
|
||||
| try removing `&mut` here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -4,8 +4,8 @@ error[E0596]: cannot borrow immutable local variable `x` as mutable
|
||||
22 | test(&mut x);
|
||||
| ^
|
||||
| |
|
||||
| try removing `&mut` here
|
||||
| cannot reborrow mutably
|
||||
| try removing `&mut` here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -4,8 +4,8 @@ error[E0507]: cannot move out of indexed content
|
||||
19 | let e = f.v[0];
|
||||
| ^^^^^^
|
||||
| |
|
||||
| help: consider using a reference instead: `&f.v[0]`
|
||||
| cannot move out of indexed content
|
||||
| help: consider using a reference instead: `&f.v[0]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -4,8 +4,8 @@ error[E0281]: type mismatch: `[closure@$DIR/E0281.rs:14:9: 14:24]` implements th
|
||||
14 | foo(|y: String| { });
|
||||
| ^^^ --------------- implements `std::ops::Fn<(std::string::String,)>`
|
||||
| |
|
||||
| requires `std::ops::Fn<(usize,)>`
|
||||
| expected usize, found struct `std::string::String`
|
||||
| requires `std::ops::Fn<(usize,)>`
|
||||
|
|
||||
= note: required by `foo`
|
||||
|
||||
|
@ -14,8 +14,8 @@ error[E0281]: type mismatch: `[closure@$DIR/closure-mismatch.rs:18:9: 18:15]` im
|
||||
18 | baz(|_| ());
|
||||
| ^^^ ------ implements `std::ops::Fn<(_,)>`
|
||||
| |
|
||||
| requires `for<'r> std::ops::Fn<(&'r (),)>`
|
||||
| expected concrete lifetime, found bound lifetime parameter
|
||||
| requires `for<'r> std::ops::Fn<(&'r (),)>`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `Foo` for `[closure@$DIR/closure-mismatch.rs:18:9: 18:15]`
|
||||
= note: required by `baz`
|
||||
|
@ -14,8 +14,8 @@ error[E0281]: type mismatch: `[closure@$DIR/issue-36053-2.rs:17:39: 17:53]` impl
|
||||
17 | once::<&str>("str").fuse().filter(|a: &str| true).count();
|
||||
| ^^^^^^ -------------- implements `for<'r> std::ops::FnMut<(&'r str,)>`
|
||||
| |
|
||||
| requires `for<'r> std::ops::FnMut<(&'r &str,)>`
|
||||
| expected &str, found str
|
||||
| requires `for<'r> std::ops::FnMut<(&'r &str,)>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -7,8 +7,8 @@ error[E0281]: type mismatch: `[closure@$DIR/unboxed-closures-vtable-mismatch.rs:
|
||||
25 | let z = call_it(3, f);
|
||||
| ^^^^^^^
|
||||
| |
|
||||
| requires `std::ops::FnMut<(isize, isize)>`
|
||||
| expected isize, found usize
|
||||
| requires `std::ops::FnMut<(isize, isize)>`
|
||||
|
|
||||
= note: required by `call_it`
|
||||
|
||||
|
@ -22,8 +22,8 @@ error[E0425]: cannot find value `whiskers` in this scope
|
||||
52 | whiskers -= other;
|
||||
| ^^^^^^^^
|
||||
| |
|
||||
| help: try: `self.whiskers`
|
||||
| `self` value is only available in methods with `self` parameter
|
||||
| help: try: `self.whiskers`
|
||||
|
||||
error[E0425]: cannot find function `shave` in this scope
|
||||
--> $DIR/issue-2356.rs:57:5
|
||||
@ -91,8 +91,8 @@ error[E0425]: cannot find value `whiskers` in this scope
|
||||
110 | whiskers = 4;
|
||||
| ^^^^^^^^
|
||||
| |
|
||||
| help: try: `self.whiskers`
|
||||
| `self` value is only available in methods with `self` parameter
|
||||
| help: try: `self.whiskers`
|
||||
|
||||
error[E0425]: cannot find function `purr_louder` in this scope
|
||||
--> $DIR/issue-2356.rs:115:5
|
||||
|
@ -10,8 +10,8 @@ error[E0404]: expected trait, found type alias `K`
|
||||
13 | impl K for isize {} //~ ERROR expected trait, found type alias `K`
|
||||
| ^
|
||||
| |
|
||||
| type aliases cannot be used for traits
|
||||
| did you mean `I`?
|
||||
| type aliases cannot be used for traits
|
||||
|
||||
error: cannot continue compilation due to previous error
|
||||
|
||||
|
@ -4,9 +4,9 @@ error[E0423]: expected value, found struct `Z`
|
||||
26 | Z;
|
||||
| ^
|
||||
| |
|
||||
| did you mean `Z { /* fields */ }`?
|
||||
| did you mean `S`?
|
||||
| constructor is not visible here due to private fields
|
||||
| did you mean `Z { /* fields */ }`?
|
||||
|
|
||||
help: possible better candidate is found in another module, you can import it into scope
|
||||
|
|
||||
@ -19,8 +19,8 @@ error[E0423]: expected value, found struct `S`
|
||||
36 | S;
|
||||
| ^
|
||||
| |
|
||||
| did you mean `S { /* fields */ }`?
|
||||
| constructor is not visible here due to private fields
|
||||
| did you mean `S { /* fields */ }`?
|
||||
|
|
||||
help: possible better candidate is found in another module, you can import it into scope
|
||||
|
|
||||
@ -33,8 +33,8 @@ error[E0423]: expected value, found struct `xcrate::S`
|
||||
42 | xcrate::S;
|
||||
| ^^^^^^^^^
|
||||
| |
|
||||
| did you mean `xcrate::S { /* fields */ }`?
|
||||
| constructor is not visible here due to private fields
|
||||
| did you mean `xcrate::S { /* fields */ }`?
|
||||
|
|
||||
help: possible better candidate is found in another module, you can import it into scope
|
||||
|
|
||||
|
@ -4,8 +4,8 @@ error[E0425]: cannot find value `cx` in this scope
|
||||
19 | f(cx);
|
||||
| ^^
|
||||
| |
|
||||
| help: try: `self.cx`
|
||||
| `self` value is only available in methods with `self` parameter
|
||||
| help: try: `self.cx`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -4,8 +4,8 @@ error[E0308]: mismatched types
|
||||
25 | if x = x {
|
||||
| ^^^^^
|
||||
| |
|
||||
| help: did you mean to compare equality?: `x == x`
|
||||
| expected bool, found ()
|
||||
| help: did you mean to compare equality?: `x == x`
|
||||
|
|
||||
= note: expected type `bool`
|
||||
found type `()`
|
||||
@ -16,8 +16,8 @@ error[E0308]: mismatched types
|
||||
31 | if (x = x) {
|
||||
| ^^^^^^^
|
||||
| |
|
||||
| help: did you mean to compare equality?: `x == x`
|
||||
| expected bool, found ()
|
||||
| help: did you mean to compare equality?: `x == x`
|
||||
|
|
||||
= note: expected type `bool`
|
||||
found type `()`
|
||||
@ -28,8 +28,8 @@ error[E0308]: mismatched types
|
||||
37 | if y = (Foo { foo: x }) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: did you mean to compare equality?: `y == (Foo { foo: x })`
|
||||
| expected bool, found ()
|
||||
| help: did you mean to compare equality?: `y == (Foo { foo: x })`
|
||||
|
|
||||
= note: expected type `bool`
|
||||
found type `()`
|
||||
@ -40,8 +40,8 @@ error[E0308]: mismatched types
|
||||
43 | if 3 = x {
|
||||
| ^^^^^
|
||||
| |
|
||||
| help: did you mean to compare equality?: `3 == x`
|
||||
| expected bool, found ()
|
||||
| help: did you mean to compare equality?: `3 == x`
|
||||
|
|
||||
= note: expected type `bool`
|
||||
found type `()`
|
||||
|
Loading…
Reference in New Issue
Block a user