Skip to content

Commit 53b622a

Browse files
committed
Auto merge of #56479 - mark-i-m:unsat, r=nikomatsakis
Better lifetime error message I propose the following error message as more user-friendly r? @nikomatsakis
2 parents f001287 + db2d243 commit 53b622a

File tree

53 files changed

+90
-95
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+90
-95
lines changed

src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
505505
) {
506506
let mut diag = infcx.tcx.sess.struct_span_err(
507507
span,
508-
"unsatisfied lifetime constraints", // FIXME
508+
"lifetime may not live long enough"
509509
);
510510

511511
let counter = &mut 1;

src/test/ui/nll/closure-requirements/escape-argument-callee.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | let mut closure = expect_sig(|p, y| *p = y);
99
for<'r, 's, 't0> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BrNamed(crate0:DefIndex(0:0), 'r)) mut &ReLateBound(DebruijnIndex(0), BrNamed(crate0:DefIndex(0:0), 's)) i32, &ReLateBound(DebruijnIndex(0), BrNamed(crate0:DefIndex(0:0), 't0)) i32))
1010
]
1111

12-
error: unsatisfied lifetime constraints
12+
error: lifetime may not live long enough
1313
--> $DIR/escape-argument-callee.rs:26:45
1414
|
1515
LL | let mut closure = expect_sig(|p, y| *p = y);

src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LL | | },
1616
= note: late-bound region is '_#5r
1717
= note: late-bound region is '_#6r
1818

19-
error: unsatisfied lifetime constraints
19+
error: lifetime may not live long enough
2020
--> $DIR/propagate-approximated-fail-no-postdom.rs:46:13
2121
|
2222
LL | |_outlives1, _outlives2, _outlives3, x, y| {

src/test/ui/nll/closure-requirements/propagate-approximated-ref.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ fn demand_y<'x, 'y>(_cell_x: &Cell<&'x u32>, _cell_y: &Cell<&'y u32>, _y: &'y u3
4141
#[rustc_regions]
4242
fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
4343
establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
44-
4544
// Only works if 'x: 'y:
4645
demand_y(x, y, x.get())
47-
//~^ ERROR unsatisfied lifetime constraints
46+
//~^ ERROR lifetime may not live long enough
4847
});
4948
}
5049

src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ note: External requirements
33
|
44
LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
55
| _______________________________________________^
6-
LL | |
76
LL | | // Only works if 'x: 'y:
87
LL | | demand_y(x, y, x.get())
9-
LL | | //~^ ERROR unsatisfied lifetime constraints
8+
LL | | //~^ ERROR lifetime may not live long enough
109
LL | | });
1110
| |_____^
1211
|
@@ -24,17 +23,17 @@ note: No external requirements
2423
|
2524
LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
2625
LL | | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
27-
LL | |
2826
LL | | // Only works if 'x: 'y:
29-
... |
27+
LL | | demand_y(x, y, x.get())
28+
LL | | //~^ ERROR lifetime may not live long enough
3029
LL | | });
3130
LL | | }
3231
| |_^
3332
|
3433
= note: defining type: DefId(0/0:6 ~ propagate_approximated_ref[317d]::supply[0]) with substs []
3534

36-
error: unsatisfied lifetime constraints
37-
--> $DIR/propagate-approximated-ref.rs:46:9
35+
error: lifetime may not live long enough
36+
--> $DIR/propagate-approximated-ref.rs:45:9
3837
|
3938
LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
4039
| -- -- lifetime `'b` defined here

src/test/ui/nll/closure-requirements/propagate-approximated-val.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ fn demand_y<'x, 'y>(_outlives1: Cell<&&'x u32>, _outlives2: Cell<&'y &u32>, _y:
3434
#[rustc_regions]
3535
fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
3636
establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
37-
3837
// Only works if 'x: 'y:
3938
demand_y(outlives1, outlives2, x.get())
40-
//~^ ERROR unsatisfied lifetime constraints
39+
//~^ ERROR lifetime may not live long enough
4140
});
4241
}
4342

src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ note: External requirements
33
|
44
LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
55
| _____________________________________________^
6-
LL | |
76
LL | | // Only works if 'x: 'y:
87
LL | | demand_y(outlives1, outlives2, x.get())
9-
LL | | //~^ ERROR unsatisfied lifetime constraints
8+
LL | | //~^ ERROR lifetime may not live long enough
109
LL | | });
1110
| |_____^
1211
|
@@ -24,17 +23,17 @@ note: No external requirements
2423
|
2524
LL | / fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
2625
LL | | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
27-
LL | |
2826
LL | | // Only works if 'x: 'y:
29-
... |
27+
LL | | demand_y(outlives1, outlives2, x.get())
28+
LL | | //~^ ERROR lifetime may not live long enough
3029
LL | | });
3130
LL | | }
3231
| |_^
3332
|
3433
= note: defining type: DefId(0/0:6 ~ propagate_approximated_val[317d]::test[0]) with substs []
3534

36-
error: unsatisfied lifetime constraints
37-
--> $DIR/propagate-approximated-val.rs:39:9
35+
error: lifetime may not live long enough
36+
--> $DIR/propagate-approximated-val.rs:38:9
3837
|
3938
LL | fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
4039
| -- -- lifetime `'b` defined here

src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LL | | });
1616
= note: late-bound region is '_#2r
1717
= note: late-bound region is '_#3r
1818

19-
error: unsatisfied lifetime constraints
19+
error: lifetime may not live long enough
2020
--> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:37:9
2121
|
2222
LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {

src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LL | | });
1616
= note: late-bound region is '_#3r
1717
= note: late-bound region is '_#4r
1818

19-
error: unsatisfied lifetime constraints
19+
error: lifetime may not live long enough
2020
--> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:41:9
2121
|
2222
LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {

src/test/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: unsatisfied lifetime constraints
1+
error: lifetime may not live long enough
22
--> $DIR/region-lbr-named-does-not-outlive-static.rs:9:5
33
|
44
LL | fn foo<'a>(x: &'a u32) -> &'static u32 {

0 commit comments

Comments
 (0)