]> git.lizzy.rs Git - rust.git/commitdiff
reorder span labels
authorgaurikholkar <f2013002@goa.bits-pilani.ac.in>
Wed, 5 Jul 2017 16:58:22 +0000 (09:58 -0700)
committergaurikholkar <f2013002@goa.bits-pilani.ac.in>
Mon, 17 Jul 2017 18:37:37 +0000 (00:07 +0530)
15 files changed:
src/librustc_errors/emitter.rs
src/test/ui/did_you_mean/issue-31424.stderr
src/test/ui/did_you_mean/issue-34126.stderr
src/test/ui/did_you_mean/issue-34337.stderr
src/test/ui/did_you_mean/issue-37139.stderr
src/test/ui/issue-40402-ref-hints/issue-40402-1.stderr
src/test/ui/mismatched_types/E0281.stderr
src/test/ui/mismatched_types/closure-mismatch.stderr
src/test/ui/mismatched_types/issue-36053-2.stderr
src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr
src/test/ui/resolve/issue-2356.stderr
src/test/ui/resolve/issue-5035.stderr
src/test/ui/resolve/privacy-struct-ctor.stderr
src/test/ui/resolve/unresolved_static_type_field.stderr
src/test/ui/type-check/assignment-in-if.stderr

index 3e8bd093f4f93f0a19ba063ae30d8179bb7c7c8c..ad2562e28fa4f5b001d88200144f0de85e01d455 100644 (file)
@@ -346,9 +346,20 @@ fn render_source_line(&self,
         // 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.
         //
index c7d43a0fc0b6f1b794dc7a49d199dec7c6c4e8e2..023f9ef1defb735d91c9c9cb49b4a64aac361ccb 100644 (file)
@@ -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
index 63d59a59238b538dd5c4869dc8f4930d1652e16e..d9ef0c45410418c057b6a83a37996ffb3930a653 100644 (file)
@@ -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
 
index 9eb88cdeddbe6d4a027cfa9fc1f4488a42fddcfc..20478165c7ea0309c6917bd4048a2d3ad7518693 100644 (file)
@@ -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
 
index 4348b6fca63b6878deba32ad226a48c910f17afd..9fc364f861275a6b977d8376a12eba1c01cf9bc0 100644 (file)
@@ -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
 
index 26f150811b7db29b9c56a9d4c7f46f35a10abf48..56d0a5351ce83ed53712282d984365f552c32064 100644 (file)
@@ -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
 
index 887412d1be7af5eba8acc1b40d44032c84e2cd27..744e8c309392513b9a2f4de9606c4e631f9786f9 100644 (file)
@@ -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`
 
index 5b3eb5931896aee60c50c0e36b8efa0c97379607..b7479f15b181294b88bb7cebba33c910d5224e65 100644 (file)
@@ -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`
index 51acdb719b69afc04c5e7bab30235d01c2a4b57e..174f7dfa0d0f5f897b93ecbb14edb66735457329 100644 (file)
@@ -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
 
index 995a12584547734a84abf2a68dec2b2aba38c496..f14e711b23a1eea02972ad127388f49442fd5cab 100644 (file)
@@ -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`
 
index 9c683f4418972918b47e6e936dd02ce43c5b89a9..ed0edd52587ec6906b5ae93b8fdcecb8c5613c72 100644 (file)
@@ -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
index 19adecc7b4bd2212c9848cf996d70a9af4150316..3c093e068c507eb9cbf708f0d2ceb8ad804cebbe 100644 (file)
@@ -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
 
index 57b143d34dbd20ef602f50944186aa9448a9dada..47141eda33c5531ae25da7dd546ed619d1a5eddd 100644 (file)
@@ -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
    |
index e598851e3628ea0201df2a8251d6aec3eb189c8f..014e03eb252beba351ea4b9d156113e77fb1756e 100644 (file)
@@ -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
 
index b740a1b776f752834a0d2096280aa4cdab2292b8..4b8a3744bcf8ad7fb40d5a8d85661d9c91871472 100644 (file)
@@ -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 `()`