Skip to content

Commit b562565

Browse files
committed
Same change to point at borrow for mir errors
1 parent 02079e4 commit b562565

25 files changed

+71
-68
lines changed

Diff for: src/librustc_mir/borrow_check/error_reporting.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
394394
&mut self, name: &String, _scope_tree: &Rc<ScopeTree>, _borrow: &BorrowData<'tcx>,
395395
drop_span: Span, borrow_span: Span, _proper_span: Span, end_span: Option<Span>
396396
) {
397-
let mut err = self.tcx.path_does_not_live_long_enough(drop_span,
397+
let mut err = self.tcx.path_does_not_live_long_enough(borrow_span,
398398
&format!("`{}`", name),
399399
Origin::Mir);
400-
err.span_label(borrow_span, "borrow occurs here");
400+
err.span_label(borrow_span, "borrowed value does not live long enough");
401401
err.span_label(drop_span, format!("`{}` dropped here while still borrowed", name));
402402
if let Some(end) = end_span {
403403
err.span_label(end, "borrowed value needs to live until here");
@@ -407,12 +407,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
407407

408408
fn report_scoped_temporary_value_does_not_live_long_enough(
409409
&mut self, _scope_tree: &Rc<ScopeTree>, _borrow: &BorrowData<'tcx>,
410-
drop_span: Span, borrow_span: Span, proper_span: Span, end_span: Option<Span>
410+
drop_span: Span, _borrow_span: Span, proper_span: Span, end_span: Option<Span>
411411
) {
412-
let mut err = self.tcx.path_does_not_live_long_enough(borrow_span,
412+
let mut err = self.tcx.path_does_not_live_long_enough(proper_span,
413413
"borrowed value",
414414
Origin::Mir);
415-
err.span_label(proper_span, "temporary value created here");
415+
err.span_label(proper_span, "temporary value does not live long enough");
416416
err.span_label(drop_span, "temporary value dropped here while still borrowed");
417417
err.note("consider using a `let` binding to increase its lifetime");
418418
if let Some(end) = end_span {
@@ -428,7 +428,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
428428
let mut err = self.tcx.path_does_not_live_long_enough(borrow_span,
429429
&format!("`{}`", name),
430430
Origin::Mir);
431-
err.span_label(borrow_span, "does not live long enough");
431+
err.span_label(borrow_span, "borrowed value does not live long enough");
432432
err.span_label(drop_span, "borrowed value only lives until here");
433433
self.tcx.note_and_explain_region(scope_tree, &mut err,
434434
"borrowed value must be valid for ",
@@ -443,7 +443,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
443443
let mut err = self.tcx.path_does_not_live_long_enough(proper_span,
444444
"borrowed value",
445445
Origin::Mir);
446-
err.span_label(proper_span, "does not live long enough");
446+
err.span_label(proper_span, "temporary value does not live long enough");
447447
err.span_label(drop_span, "temporary value only lives until here");
448448
self.tcx.note_and_explain_region(scope_tree, &mut err,
449449
"borrowed value must be valid for ",

Diff for: src/test/compile-fail-fulldeps/dropck_tarena_cycle_checked.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,4 @@ fn f<'a>(arena: &'a TypedArena<C<'a>>) {
124124
fn main() {
125125
let arena = TypedArena::new();
126126
f(&arena);
127-
} //~ ERROR `arena` does not live long enough
127+
} //~^ ERROR `arena` does not live long enough

Diff for: src/test/compile-fail-fulldeps/dropck_tarena_unsound_drop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ fn f<'a>(_arena: &'a TypedArena<C<'a>>) {}
4949
fn main() {
5050
let arena: TypedArena<C> = TypedArena::new();
5151
f(&arena);
52-
} //~ ERROR `arena` does not live long enough
52+
} //~^ ERROR `arena` does not live long enough
5353

Diff for: src/test/compile-fail/E0597.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ fn main() {
1616
let mut x = Foo { x: None };
1717
let y = 0;
1818
x.x = Some(&y);
19-
} //~ `y` does not live long enough [E0597]
19+
//~^ `y` does not live long enough [E0597]
20+
}

Diff for: src/test/compile-fail/catch-bad-lifetime.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ pub fn main() {
1818
let _result: Result<(), &str> = do catch {
1919
let my_string = String::from("");
2020
let my_str: & str = & my_string;
21+
//~^ ERROR `my_string` does not live long enough
2122
Err(my_str) ?;
2223
Err("") ?;
2324
Ok(())
24-
}; //~ ERROR `my_string` does not live long enough
25+
};
2526
}
2627

2728
{

Diff for: src/test/compile-fail/issue-36082.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ fn main() {
2121
let val: &_ = x.borrow().0;
2222
//[ast]~^ ERROR borrowed value does not live long enough [E0597]
2323
//[ast]~| NOTE temporary value dropped here while still borrowed
24-
//[ast]~| NOTE temporary value created here
24+
//[ast]~| NOTE temporary value does not live long enough
2525
//[ast]~| NOTE consider using a `let` binding to increase its lifetime
2626
//[mir]~^^^^^ ERROR borrowed value does not live long enough [E0597]
2727
//[mir]~| NOTE temporary value dropped here while still borrowed
28-
//[mir]~| NOTE temporary value created here
28+
//[mir]~| NOTE temporary value does not live long enough
2929
//[mir]~| NOTE consider using a `let` binding to increase its lifetime
3030
println!("{}", val);
3131
}

Diff for: src/test/compile-fail/region-borrow-params-issue-29793-big.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ fn main() {
8181
WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`)
8282
//[ast]~^ ERROR `x` does not live long enough
8383
//[ast]~| ERROR `y` does not live long enough
84+
//[mir]~^^^ ERROR `x` does not live long enough
85+
//[mir]~| ERROR `y` does not live long enough
8486
});
85-
//[mir]~^ ERROR `x` does not live long enough
86-
//[mir]~| ERROR `y` does not live long enough
8787

8888
w.handle(); // This works
8989
// w.handle_ref(); // This doesn't

Diff for: src/test/ui/issue-46471-1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn main() {
1515
let mut z = 0;
1616
&mut z
1717
};
18-
//~^ ERROR `z` does not live long enough (Ast) [E0597]
18+
//~^^ ERROR `z` does not live long enough (Ast) [E0597]
1919
//~| ERROR `z` does not live long enough (Mir) [E0597]
2020
println!("{}", y);
2121
}

Diff for: src/test/ui/issue-46471-1.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ error[E0597]: `z` does not live long enough (Ast)
1010
| - borrowed value needs to live until here
1111

1212
error[E0597]: `z` does not live long enough (Mir)
13-
--> $DIR/issue-46471-1.rs:17:6
13+
--> $DIR/issue-46471-1.rs:16:9
1414
|
1515
16 | &mut z
16-
| ------ borrow occurs here
16+
| ^^^^^^ borrowed value does not live long enough
1717
17 | };
18-
| ^ `z` dropped here while still borrowed
18+
| - `z` dropped here while still borrowed
1919
...
2020
21 | }
2121
| - borrowed value needs to live until here

Diff for: src/test/ui/issue-46471.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ error[E0597]: `x` does not live long enough (Mir)
1313
--> $DIR/issue-46471.rs:15:5
1414
|
1515
15 | &x
16-
| ^^ does not live long enough
16+
| ^^ borrowed value does not live long enough
1717
...
1818
18 | }
1919
| - borrowed value only lives until here

Diff for: src/test/ui/issue-46472.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ error[E0597]: borrowed value does not live long enough (Mir)
2121
--> $DIR/issue-46472.rs:14:10
2222
|
2323
14 | &mut 4
24-
| ^ does not live long enough
24+
| ^ temporary value does not live long enough
2525
...
2626
17 | }
2727
| - temporary value only lives until here

Diff for: src/test/ui/nll/capture-ref-in-struct.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0597]: `y` does not live long enough
22
--> $DIR/capture-ref-in-struct.rs:32:16
33
|
44
32 | y: &y,
5-
| ^^ does not live long enough
5+
| ^^ borrowed value does not live long enough
66
...
77
37 | }
88
| - borrowed value only lives until here

Diff for: src/test/ui/nll/closure-requirements/escape-argument.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ error[E0597]: `y` does not live long enough
2828
--> $DIR/escape-argument.rs:37:25
2929
|
3030
37 | closure(&mut p, &y);
31-
| ^^ does not live long enough
31+
| ^^ borrowed value does not live long enough
3232
38 | //~^ ERROR `y` does not live long enough [E0597]
3333
39 | }
3434
| - borrowed value only lives until here

Diff for: src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ error[E0597]: `y` does not live long enough
5454
31 | | let mut closure1 = || p = &y;
5555
32 | | closure1();
5656
33 | | };
57-
| |_________^ does not live long enough
57+
| |_________^ borrowed value does not live long enough
5858
...
5959
36 | }
6060
| - borrowed value only lives until here

Diff for: src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ error[E0597]: `y` does not live long enough
3131
--> $DIR/escape-upvar-ref.rs:33:27
3232
|
3333
33 | let mut closure = || p = &y;
34-
| ^^^^^^^^^ does not live long enough
34+
| ^^^^^^^^^ borrowed value does not live long enough
3535
...
3636
36 | }
3737
| - borrowed value only lives until here

Diff for: src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ error[E0597]: `a` does not live long enough
7575
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:41:26
7676
|
7777
41 | let cell = Cell::new(&a);
78-
| ^^ does not live long enough
78+
| ^^ borrowed value does not live long enough
7979
...
8080
49 | }
8181
| - borrowed value only lives until here

Diff for: src/test/ui/region-borrow-params-issue-29793-small.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0597]: `x` does not live long enough
22
--> $DIR/region-borrow-params-issue-29793-small.rs:19:34
33
|
44
19 | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
5-
| --------- ^ does not live long enough
5+
| --------- ^ borrowed value does not live long enough
66
| |
77
| capture occurs here
88
...
@@ -15,7 +15,7 @@ error[E0597]: `y` does not live long enough
1515
--> $DIR/region-borrow-params-issue-29793-small.rs:19:45
1616
|
1717
19 | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
18-
| --------- ^ does not live long enough
18+
| --------- ^ borrowed value does not live long enough
1919
| |
2020
| capture occurs here
2121
...
@@ -28,7 +28,7 @@ error[E0597]: `x` does not live long enough
2828
--> $DIR/region-borrow-params-issue-29793-small.rs:34:34
2929
|
3030
34 | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
31-
| --------- ^ does not live long enough
31+
| --------- ^ borrowed value does not live long enough
3232
| |
3333
| capture occurs here
3434
...
@@ -41,7 +41,7 @@ error[E0597]: `y` does not live long enough
4141
--> $DIR/region-borrow-params-issue-29793-small.rs:34:45
4242
|
4343
34 | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
44-
| --------- ^ does not live long enough
44+
| --------- ^ borrowed value does not live long enough
4545
| |
4646
| capture occurs here
4747
...

Diff for: src/test/ui/span/borrowck-let-suggestion-suffixes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ fn f() {
4242
//~| NOTE consider using a `let` binding to increase its lifetime
4343

4444
} // (statement 7)
45+
//~^ NOTE temporary value needs to live until here
4546

4647
let mut v5 = Vec::new(); // statement 8
4748

Diff for: src/test/ui/span/borrowck-let-suggestion-suffixes.stderr

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
11
error[E0597]: `young[..]` does not live long enough
2-
--> $DIR/borrowck-let-suggestion-suffixes.rs:43:1
2+
--> $DIR/borrowck-let-suggestion-suffixes.rs:21:14
33
|
44
21 | v2.push(&young[0]); // statement 4
5-
| -------- borrow occurs here
5+
| ^^^^^^^^ borrowed value does not live long enough
66
...
7-
43 | }
8-
| ^ `young[..]` dropped here while still borrowed
7+
56 | }
8+
| - `young[..]` dropped here while still borrowed
99
|
1010
= note: values in a scope are dropped in the opposite order they are created
1111

1212
error[E0597]: borrowed value does not live long enough
13-
--> $DIR/borrowck-let-suggestion-suffixes.rs:25:22
13+
--> $DIR/borrowck-let-suggestion-suffixes.rs:28:14
1414
|
15-
25 | v3.push(&id('x')); // statement 6
16-
| ------- ^ temporary value dropped here while still borrowed
15+
28 | v3.push(&id('x')); // statement 6
16+
| ^^^^^^^ - temporary value dropped here while still borrowed
1717
| |
18-
| temporary value created here
18+
| temporary value does not live long enough
1919
...
20-
43 | }
20+
56 | }
2121
| - temporary value needs to live until here
2222
|
2323
= note: consider using a `let` binding to increase its lifetime
2424

2525
error[E0597]: borrowed value does not live long enough
26-
--> $DIR/borrowck-let-suggestion-suffixes.rs:32:26
26+
--> $DIR/borrowck-let-suggestion-suffixes.rs:38:18
2727
|
28-
32 | v4.push(&id('y'));
29-
| ------- ^ temporary value dropped here while still borrowed
28+
38 | v4.push(&id('y'));
29+
| ^^^^^^^ - temporary value dropped here while still borrowed
3030
| |
31-
| temporary value created here
31+
| temporary value does not live long enough
3232
...
33-
35 | } // (statement 7)
33+
44 | } // (statement 7)
3434
| - temporary value needs to live until here
3535
|
3636
= note: consider using a `let` binding to increase its lifetime
3737

3838
error[E0597]: borrowed value does not live long enough
39-
--> $DIR/borrowck-let-suggestion-suffixes.rs:39:22
39+
--> $DIR/borrowck-let-suggestion-suffixes.rs:49:14
4040
|
41-
39 | v5.push(&id('z'));
42-
| ------- ^ temporary value dropped here while still borrowed
41+
49 | v5.push(&id('z'));
42+
| ^^^^^^^ - temporary value dropped here while still borrowed
4343
| |
44-
| temporary value created here
44+
| temporary value does not live long enough
4545
...
46-
43 | }
46+
56 | }
4747
| - temporary value needs to live until here
4848
|
4949
= note: consider using a `let` binding to increase its lifetime

Diff for: src/test/ui/span/dropck-object-cycle.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ impl<'t> MakerTrait for Box<Trait<'t>+'static> {
3535
pub fn main() {
3636
let m : Box<Trait+'static> = make_val();
3737
assert_eq!(object_invoke1(&*m), (4,5));
38+
//~^ ERROR `*m` does not live long enough
3839

3940
// the problem here is that the full type of `m` is
4041
//
@@ -54,5 +55,4 @@ pub fn main() {
5455
// the type of `m` *strictly outlives* `'m`. Hence we get an
5556
// error.
5657
}
57-
//~^ ERROR `*m` does not live long enough
5858

Diff for: src/test/ui/span/dropck-object-cycle.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0597]: `*m` does not live long enough
2-
--> $DIR/dropck-object-cycle.rs:56:1
2+
--> $DIR/dropck-object-cycle.rs:37:32
33
|
44
37 | assert_eq!(object_invoke1(&*m), (4,5));
5-
| -- borrow occurs here
5+
| ^^ borrowed value does not live long enough
66
...
7-
56 | }
8-
| ^ `*m` dropped here while still borrowed
7+
57 | }
8+
| - `*m` dropped here while still borrowed
99
|
1010
= note: values in a scope are dropped in the opposite order they are created
1111

Diff for: src/test/ui/span/issue-36537.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ fn main() {
1212
let p;
1313
let a = 42;
1414
p = &a;
15+
//~^ ERROR `a` does not live long enough
1516
}
16-
//~^ ERROR `a` does not live long enough

Diff for: src/test/ui/span/issue-36537.stderr

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
error[E0597]: `a` does not live long enough
2-
--> $DIR/issue-36537.rs:15:1
2+
--> $DIR/issue-36537.rs:14:10
33
|
44
14 | p = &a;
5-
| - borrow occurs here
6-
15 | }
7-
| ^ `a` dropped here while still borrowed
5+
| ^ borrowed value does not live long enough
6+
15 | //~^ ERROR `a` does not live long enough
7+
16 | }
8+
| - `a` dropped here while still borrowed
89
|
910
= note: values in a scope are dropped in the opposite order they are created
1011

Diff for: src/test/ui/span/regions-escape-loop-via-vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ fn broken() {
1515
while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed
1616
let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed
1717
_y.push(&mut z);
18+
//~^ ERROR `z` does not live long enough
1819
x += 1; //~ ERROR cannot assign
1920
}
20-
//~^ ERROR `z` does not live long enough
2121
}
2222

2323
fn main() { }

0 commit comments

Comments
 (0)