Skip to content

Commit eb703f7

Browse files
committed
Fix off-by-one error in column number in explain_span.
1 parent 2b6ed3a commit eb703f7

8 files changed

+15
-15
lines changed

src/librustc/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
113113
heading: &str, span: Span)
114114
-> (String, Option<Span>) {
115115
let lo = tcx.sess.codemap().lookup_char_pos_adj(span.lo);
116-
(format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize()),
116+
(format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize() + 1),
117117
Some(span))
118118
}
119119

src/test/compile-fail/issue-27942.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
pub trait Resources<'a> {}
1212

1313
pub trait Buffer<'a, R: Resources<'a>> {
14-
//~^ NOTE the lifetime 'a as defined on the trait at 13:0...
14+
//~^ NOTE the lifetime 'a as defined on the trait at 13:1...
1515
//~| NOTE ...does not necessarily outlive the lifetime 'a as defined on the trait
1616

1717
fn select(&self) -> BufferViewHandle<R>;
@@ -22,7 +22,7 @@ pub trait Buffer<'a, R: Resources<'a>> {
2222
//~| ERROR mismatched types
2323
//~| lifetime mismatch
2424
//~| NOTE expected type `Resources<'_>`
25-
//~| NOTE the anonymous lifetime #1 defined on the method body at 17:4...
25+
//~| NOTE the anonymous lifetime #1 defined on the method body at 17:5...
2626
}
2727

2828
pub struct BufferViewHandle<'a, R: 'a+Resources<'a>>(&'a R);

src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content...
44
12 | if x > y { x } else { y }
55
| ^
66
|
7-
note: ...the reference is valid for the lifetime 'a as defined on the function body at 11:0...
7+
note: ...the reference is valid for the lifetime 'a as defined on the function body at 11:1...
88
--> $DIR/ex1-return-one-existing-name-if-else.rs:11:1
99
|
1010
11 | / fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {
1111
12 | | if x > y { x } else { y }
1212
13 | | }
1313
| |_^
14-
note: ...but the borrowed content is only valid for the anonymous lifetime #1 defined on the function body at 11:0
14+
note: ...but the borrowed content is only valid for the anonymous lifetime #1 defined on the function body at 11:1
1515
--> $DIR/ex1-return-one-existing-name-if-else.rs:11:1
1616
|
1717
11 | / fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {

src/test/ui/lifetime-errors/ex2a-push-one-existing-name.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ error[E0308]: mismatched types
66
|
77
= note: expected type `Ref<'a, _>`
88
found type `Ref<'_, _>`
9-
note: the anonymous lifetime #2 defined on the function body at 15:0...
9+
note: the anonymous lifetime #2 defined on the function body at 15:1...
1010
--> $DIR/ex2a-push-one-existing-name.rs:15:1
1111
|
1212
15 | / fn foo<'a>(x: &mut Vec<Ref<'a, i32>>, y: Ref<i32>) {
1313
16 | | x.push(y);
1414
17 | | }
1515
| |_^
16-
note: ...does not necessarily outlive the lifetime 'a as defined on the function body at 15:0
16+
note: ...does not necessarily outlive the lifetime 'a as defined on the function body at 15:1
1717
--> $DIR/ex2a-push-one-existing-name.rs:15:1
1818
|
1919
15 | / fn foo<'a>(x: &mut Vec<Ref<'a, i32>>, y: Ref<i32>) {

src/test/ui/lifetime-errors/ex2b-push-no-existing-names.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ error[E0308]: mismatched types
66
|
77
= note: expected type `Ref<'_, _>`
88
found type `Ref<'_, _>`
9-
note: the anonymous lifetime #3 defined on the function body at 15:0...
9+
note: the anonymous lifetime #3 defined on the function body at 15:1...
1010
--> $DIR/ex2b-push-no-existing-names.rs:15:1
1111
|
1212
15 | / fn foo(x: &mut Vec<Ref<i32>>, y: Ref<i32>) {
1313
16 | | x.push(y);
1414
17 | | }
1515
| |_^
16-
note: ...does not necessarily outlive the anonymous lifetime #2 defined on the function body at 15:0
16+
note: ...does not necessarily outlive the anonymous lifetime #2 defined on the function body at 15:1
1717
--> $DIR/ex2b-push-no-existing-names.rs:15:1
1818
|
1919
15 | / fn foo(x: &mut Vec<Ref<i32>>, y: Ref<i32>) {

src/test/ui/lifetime-errors/ex2c-push-inference-variable.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` d
44
16 | let z = Ref { data: y.data };
55
| ^^^
66
|
7-
note: first, the lifetime cannot outlive the lifetime 'c as defined on the function body at 15:0...
7+
note: first, the lifetime cannot outlive the lifetime 'c as defined on the function body at 15:1...
88
--> $DIR/ex2c-push-inference-variable.rs:15:1
99
|
1010
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
1717
|
1818
16 | let z = Ref { data: y.data };
1919
| ^^^^^^
20-
note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 15:0...
20+
note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 15:1...
2121
--> $DIR/ex2c-push-inference-variable.rs:15:1
2222
|
2323
15 | / fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {

src/test/ui/lifetime-errors/ex2d-push-inference-variable-2.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` d
44
17 | let b = Ref { data: y.data };
55
| ^^^
66
|
7-
note: first, the lifetime cannot outlive the lifetime 'c as defined on the function body at 15:0...
7+
note: first, the lifetime cannot outlive the lifetime 'c as defined on the function body at 15:1...
88
--> $DIR/ex2d-push-inference-variable-2.rs:15:1
99
|
1010
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
1818
|
1919
17 | let b = Ref { data: y.data };
2020
| ^^^^^^
21-
note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 15:0...
21+
note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 15:1...
2222
--> $DIR/ex2d-push-inference-variable-2.rs:15:1
2323
|
2424
15 | / fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {

src/test/ui/lifetime-errors/ex2e-push-inference-variable-3.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` d
44
17 | let b = Ref { data: y.data };
55
| ^^^
66
|
7-
note: first, the lifetime cannot outlive the lifetime 'c as defined on the function body at 15:0...
7+
note: first, the lifetime cannot outlive the lifetime 'c as defined on the function body at 15:1...
88
--> $DIR/ex2e-push-inference-variable-3.rs:15:1
99
|
1010
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
1818
|
1919
17 | let b = Ref { data: y.data };
2020
| ^^^^^^
21-
note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 15:0...
21+
note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 15:1...
2222
--> $DIR/ex2e-push-inference-variable-3.rs:15:1
2323
|
2424
15 | / fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {

0 commit comments

Comments
 (0)