Skip to content

Commit 967e963

Browse files
bless test about post dominating lower bounds
1 parent 3071a81 commit 967e963

File tree

2 files changed

+60
-22
lines changed

2 files changed

+60
-22
lines changed

tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Test where we fail to approximate due to demanding a postdom
2-
// relationship between our upper bounds.
1+
// Test that we can propagate multiple region errors by propagating all
2+
// non-local lower bounds of `fr_longer`.
33

44
//@ compile-flags:-Zverbose-internals
55

@@ -13,9 +13,8 @@ use std::cell::Cell;
1313
// 'x: 'b
1414
// 'c: 'y
1515
//
16-
// we have to prove that `'x: 'y`. We currently can only approximate
17-
// via a postdominator -- hence we fail to choose between `'a` and
18-
// `'b` here and report the error in the closure.
16+
// we have to prove that `'x: 'y`. We find non-local lower bounds of 'x to be 'a and 'b and
17+
// non-local upper bound of 'y to be 'c. So we propagate `'b: 'c` and `'a: 'c`.
1918
fn establish_relationships<'a, 'b, 'c, F>(
2019
_cell_a: Cell<&'a u32>,
2120
_cell_b: Cell<&'b u32>,
@@ -36,14 +35,16 @@ fn demand_y<'x, 'y>(_cell_x: Cell<&'x u32>, _cell_y: Cell<&'y u32>, _y: &'y u32)
3635

3736
#[rustc_regions]
3837
fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell<&'c u32>) {
38+
//~vv ERROR lifetime may not live long enough
39+
//~v ERROR lifetime may not live long enough
3940
establish_relationships(
4041
cell_a,
4142
cell_b,
4243
cell_c,
4344
|_outlives1, _outlives2, _outlives3, x, y| {
4445
// Only works if 'x: 'y:
4546
let p = x.get();
46-
demand_y(x, y, p) //~ ERROR
47+
demand_y(x, y, p)
4748
},
4849
);
4950
}
Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
note: no external requirements
2-
--> $DIR/propagate-approximated-fail-no-postdom.rs:43:9
1+
note: external requirements
2+
--> $DIR/propagate-approximated-fail-no-postdom.rs:44:9
33
|
44
LL | |_outlives1, _outlives2, _outlives3, x, y| {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -14,29 +14,66 @@ LL | |_outlives1, _outlives2, _outlives3, x, y| {
1414
= note: late-bound region is '?4
1515
= note: late-bound region is '?5
1616
= note: late-bound region is '?6
17+
= note: number of external vids: 7
18+
= note: where '?2: '?3
19+
= note: where '?1: '?3
20+
21+
note: no external requirements
22+
--> $DIR/propagate-approximated-fail-no-postdom.rs:37:1
23+
|
24+
LL | fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell<&'c u32>) {
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26+
|
27+
= note: defining type: supply
1728

1829
error: lifetime may not live long enough
19-
--> $DIR/propagate-approximated-fail-no-postdom.rs:46:13
30+
--> $DIR/propagate-approximated-fail-no-postdom.rs:40:5
2031
|
21-
LL | |_outlives1, _outlives2, _outlives3, x, y| {
22-
| ---------- ---------- has type `Cell<&'2 &'?3 u32>`
23-
| |
24-
| has type `Cell<&'?1 &'1 u32>`
32+
LL | fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell<&'c u32>) {
33+
| -- -- lifetime `'c` defined here
34+
| |
35+
| lifetime `'a` defined here
2536
...
26-
LL | demand_y(x, y, p)
27-
| ^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
37+
LL | / establish_relationships(
38+
LL | | cell_a,
39+
LL | | cell_b,
40+
LL | | cell_c,
41+
... |
42+
LL | | },
43+
LL | | );
44+
| |_____^ argument requires that `'a` must outlive `'c`
2845
|
29-
= note: requirement occurs because of the type `Cell<&'?34 u32>`, which makes the generic argument `&'?34 u32` invariant
46+
= help: consider adding the following bound: `'a: 'c`
47+
= note: requirement occurs because of the type `Cell<&'?10 u32>`, which makes the generic argument `&'?10 u32` invariant
3048
= note: the struct `Cell<T>` is invariant over the parameter `T`
3149
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
3250

33-
note: no external requirements
34-
--> $DIR/propagate-approximated-fail-no-postdom.rs:38:1
51+
error: lifetime may not live long enough
52+
--> $DIR/propagate-approximated-fail-no-postdom.rs:40:5
3553
|
36-
LL | fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell<&'c u32>) {
37-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
54+
LL | fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell<&'c u32>) {
55+
| -- -- lifetime `'c` defined here
56+
| |
57+
| lifetime `'b` defined here
58+
...
59+
LL | / establish_relationships(
60+
LL | | cell_a,
61+
LL | | cell_b,
62+
LL | | cell_c,
63+
... |
64+
LL | | },
65+
LL | | );
66+
| |_____^ argument requires that `'b` must outlive `'c`
3867
|
39-
= note: defining type: supply
68+
= help: consider adding the following bound: `'b: 'c`
69+
= note: requirement occurs because of the type `Cell<&'?10 u32>`, which makes the generic argument `&'?10 u32` invariant
70+
= note: the struct `Cell<T>` is invariant over the parameter `T`
71+
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
72+
73+
help: the following changes may resolve your lifetime errors
74+
|
75+
= help: add bound `'a: 'c`
76+
= help: add bound `'b: 'c`
4077

41-
error: aborting due to 1 previous error
78+
error: aborting due to 2 previous errors
4279

0 commit comments

Comments
 (0)