]> git.lizzy.rs Git - rust.git/commitdiff
Fix off-by-one error in column number in `explain_span`.
authorFlorian Hartwig <florian.j.hartwig@gmail.com>
Wed, 17 May 2017 19:27:58 +0000 (21:27 +0200)
committerFlorian Hartwig <florian.j.hartwig@gmail.com>
Wed, 17 May 2017 22:21:57 +0000 (00:21 +0200)
src/librustc/infer/error_reporting/mod.rs
src/test/compile-fail/issue-27942.rs
src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.stderr
src/test/ui/lifetime-errors/ex2a-push-one-existing-name.stderr
src/test/ui/lifetime-errors/ex2b-push-no-existing-names.stderr
src/test/ui/lifetime-errors/ex2c-push-inference-variable.stderr
src/test/ui/lifetime-errors/ex2d-push-inference-variable-2.stderr
src/test/ui/lifetime-errors/ex2e-push-inference-variable-3.stderr

index c07b3b3c4be90bd445a407d1d901ef1289ce843b..0515e1cc304356f738a5c009e7d266d2ac164b59 100644 (file)
@@ -113,7 +113,7 @@ fn explain_span<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
                                         heading: &str, span: Span)
                                         -> (String, Option<Span>) {
             let lo = tcx.sess.codemap().lookup_char_pos_adj(span.lo);
-            (format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize()),
+            (format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize() + 1),
              Some(span))
         }
 
index 22e7de3838dc153a89f3bde569ef2ebcb45eb2c6..0fa4184606e452b348205688ad9f851853711bde 100644 (file)
@@ -11,7 +11,7 @@
 pub trait Resources<'a> {}
 
 pub trait Buffer<'a, R: Resources<'a>> {
-    //~^ NOTE the lifetime 'a as defined on the trait at 13:0...
+    //~^ NOTE the lifetime 'a as defined on the trait at 13:1...
     //~| NOTE ...does not necessarily outlive the lifetime 'a as defined on the trait
 
     fn select(&self) -> BufferViewHandle<R>;
@@ -22,7 +22,7 @@ pub trait Buffer<'a, R: Resources<'a>> {
     //~| ERROR mismatched types
     //~| lifetime mismatch
     //~| NOTE expected type `Resources<'_>`
-    //~| NOTE the anonymous lifetime #1 defined on the method body at 17:4...
+    //~| NOTE the anonymous lifetime #1 defined on the method body at 17:5...
 }
 
 pub struct BufferViewHandle<'a, R: 'a+Resources<'a>>(&'a R);
index 55723ee8cd96416c7bcc572eff46b387c77519a4..f325d10b548735ca04af219b6f7a044777fd9786 100644 (file)
@@ -4,14 +4,14 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content...
 12 |     if x > y { x } else { y }
    |                           ^
    |
-note: ...the reference is valid for the lifetime 'a as defined on the function body at 11:0...
+note: ...the reference is valid for the lifetime 'a as defined on the function body at 11:1...
   --> $DIR/ex1-return-one-existing-name-if-else.rs:11:1
    |
 11 | / fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {
 12 | |     if x > y { x } else { y }
 13 | | }
    | |_^
-note: ...but the borrowed content is only valid for the anonymous lifetime #1 defined on the function body at 11:0
+note: ...but the borrowed content is only valid for the anonymous lifetime #1 defined on the function body at 11:1
   --> $DIR/ex1-return-one-existing-name-if-else.rs:11:1
    |
 11 | / fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {
index b7d985feca9f27dfd29ebd6556b4d2184677976d..df484a14927c737ce514e9ab27e550585b7a6330 100644 (file)
@@ -6,14 +6,14 @@ error[E0308]: mismatched types
    |
    = note: expected type `Ref<'a, _>`
               found type `Ref<'_, _>`
-note: the anonymous lifetime #2 defined on the function body at 15:0...
+note: the anonymous lifetime #2 defined on the function body at 15:1...
   --> $DIR/ex2a-push-one-existing-name.rs:15:1
    |
 15 | / fn foo<'a>(x: &mut Vec<Ref<'a, i32>>, y: Ref<i32>) {
 16 | |     x.push(y);
 17 | | }
    | |_^
-note: ...does not necessarily outlive the lifetime 'a as defined on the function body at 15:0
+note: ...does not necessarily outlive the lifetime 'a as defined on the function body at 15:1
   --> $DIR/ex2a-push-one-existing-name.rs:15:1
    |
 15 | / fn foo<'a>(x: &mut Vec<Ref<'a, i32>>, y: Ref<i32>) {
index 3a6e94f2b1c2e2da70127c5a631a22516b19a026..6764c58f4bb59aeb1b9b345eab5f840ba0032c48 100644 (file)
@@ -6,14 +6,14 @@ error[E0308]: mismatched types
    |
    = note: expected type `Ref<'_, _>`
               found type `Ref<'_, _>`
-note: the anonymous lifetime #3 defined on the function body at 15:0...
+note: the anonymous lifetime #3 defined on the function body at 15:1...
   --> $DIR/ex2b-push-no-existing-names.rs:15:1
    |
 15 | / fn foo(x: &mut Vec<Ref<i32>>, y: Ref<i32>) {
 16 | |     x.push(y);
 17 | | }
    | |_^
-note: ...does not necessarily outlive the anonymous lifetime #2 defined on the function body at 15:0
+note: ...does not necessarily outlive the anonymous lifetime #2 defined on the function body at 15:1
   --> $DIR/ex2b-push-no-existing-names.rs:15:1
    |
 15 | / fn foo(x: &mut Vec<Ref<i32>>, y: Ref<i32>) {
index 3d7064a4f71a3b45423590caebeabea3619316ae..7356fc11862f6e104d004cd642852161b18e5e1b 100644 (file)
@@ -4,7 +4,7 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` d
 16 |     let z = Ref { data: y.data };
    |             ^^^
    |
-note: first, the lifetime cannot outlive the lifetime 'c as defined on the function body at 15:0...
+note: first, the lifetime cannot outlive the lifetime 'c as defined on the function body at 15:1...
   --> $DIR/ex2c-push-inference-variable.rs:15:1
    |
 15 | / fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
@@ -17,7 +17,7 @@ note: ...so that reference does not outlive borrowed content
    |
 16 |     let z = Ref { data: y.data };
    |                         ^^^^^^
-note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 15:0...
+note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 15:1...
   --> $DIR/ex2c-push-inference-variable.rs:15:1
    |
 15 | / fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
index aced855bf669bdca7e839fe0bdebb45f939827cb..38b0acf9339e0e89595a6c0ee889abca1f2c221e 100644 (file)
@@ -4,7 +4,7 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` d
 17 |     let b = Ref { data: y.data };
    |             ^^^
    |
-note: first, the lifetime cannot outlive the lifetime 'c as defined on the function body at 15:0...
+note: first, the lifetime cannot outlive the lifetime 'c as defined on the function body at 15:1...
   --> $DIR/ex2d-push-inference-variable-2.rs:15:1
    |
 15 | / fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
@@ -18,7 +18,7 @@ note: ...so that reference does not outlive borrowed content
    |
 17 |     let b = Ref { data: y.data };
    |                         ^^^^^^
-note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 15:0...
+note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 15:1...
   --> $DIR/ex2d-push-inference-variable-2.rs:15:1
    |
 15 | / fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
index 07e2316b63d8c61a8a1ed90b9cf59cbcd9cbe345..035e516e8628e9b933157645e651ef281f272c01 100644 (file)
@@ -4,7 +4,7 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` d
 17 |     let b = Ref { data: y.data };
    |             ^^^
    |
-note: first, the lifetime cannot outlive the lifetime 'c as defined on the function body at 15:0...
+note: first, the lifetime cannot outlive the lifetime 'c as defined on the function body at 15:1...
   --> $DIR/ex2e-push-inference-variable-3.rs:15:1
    |
 15 | / fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
@@ -18,7 +18,7 @@ note: ...so that reference does not outlive borrowed content
    |
 17 |     let b = Ref { data: y.data };
    |                         ^^^^^^
-note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 15:0...
+note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 15:1...
   --> $DIR/ex2e-push-inference-variable-3.rs:15:1
    |
 15 | / fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {