ed36698031
The strategy is this: - we compute SCCs once all outlives constraints are known - we allocate a set of values **per region** for storing liveness - we allocate a set of values **per SCC** for storing the final values - when we add a liveness constraint to the region R, we also add it to the final value of the SCC to which R belongs - then we can apply the constraints by just walking the DAG for the SCCs and union'ing the children (which have their liveness constraints within) There are a few intermediate refactorings that I really ought to have broken out into their own commits: - reverse the constraint graph so that `R1: R2` means `R1 -> R2` and not `R2 -> R1`. This fits better with the SCC computation and new style of inference (`->` now means "take value from" and not "push value into") - this does affect some of the UI tests, since they traverse the graph, but mostly the artificial ones and they don't necessarily seem worse - put some things (constraint set, etc) into `Rc`. This lets us root them to permit mutation and iteration. It also guarantees they don't change, which is critical to the correctness of the algorithm. - Generalize various helpers that previously operated only on points to work on any sort of region element.
92 lines
3.5 KiB
Plaintext
92 lines
3.5 KiB
Plaintext
warning: not reporting region error due to nll
|
|
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:31:5
|
|
|
|
|
LL | foo(cell, |cell_a, cell_x| {
|
|
| ^^^
|
|
|
|
error: unsatisfied lifetime constraints
|
|
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:33:20
|
|
|
|
|
LL | foo(cell, |cell_a, cell_x| {
|
|
| ------ ------ lifetime `'1` appears in this argument
|
|
| |
|
|
| lifetime `'2` appears in this argument
|
|
LL | //~^ WARNING not reporting region error due to nll
|
|
LL | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure
|
|
| ^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
|
|
|
|
note: No external requirements
|
|
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:31:15
|
|
|
|
|
LL | foo(cell, |cell_a, cell_x| {
|
|
| _______________^
|
|
LL | | //~^ WARNING not reporting region error due to nll
|
|
LL | | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure
|
|
LL | | //~^ ERROR
|
|
LL | | })
|
|
| |_____^
|
|
|
|
|
= note: defining type: DefId(0/1:12 ~ propagate_approximated_shorter_to_static_comparing_against_free[317d]::case1[0]::{{closure}}[0]) with closure substs [
|
|
i32,
|
|
for<'r> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BrNamed(crate0:DefIndex(0:0), 'r)) u32>))
|
|
]
|
|
|
|
note: No external requirements
|
|
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:28:1
|
|
|
|
|
LL | / fn case1() {
|
|
LL | | let a = 0;
|
|
LL | | let cell = Cell::new(&a);
|
|
LL | | foo(cell, |cell_a, cell_x| {
|
|
... |
|
|
LL | | })
|
|
LL | | }
|
|
| |_^
|
|
|
|
|
= note: defining type: DefId(0/0:5 ~ propagate_approximated_shorter_to_static_comparing_against_free[317d]::case1[0]) with substs []
|
|
|
|
note: External requirements
|
|
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:46:15
|
|
|
|
|
LL | foo(cell, |cell_a, cell_x| {
|
|
| _______________^
|
|
LL | | cell_x.set(cell_a.get()); // forces 'a: 'x, implies 'a = 'static -> borrow error
|
|
LL | | })
|
|
| |_____^
|
|
|
|
|
= note: defining type: DefId(0/1:13 ~ propagate_approximated_shorter_to_static_comparing_against_free[317d]::case2[0]::{{closure}}[0]) with closure substs [
|
|
i32,
|
|
for<'r> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BrNamed(crate0:DefIndex(0:0), 'r)) u32>))
|
|
]
|
|
= note: number of external vids: 2
|
|
= note: where '_#1r: '_#0r
|
|
|
|
note: No external requirements
|
|
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:39:1
|
|
|
|
|
LL | / fn case2() {
|
|
LL | | let a = 0;
|
|
LL | | let cell = Cell::new(&a);
|
|
LL | | //~^ ERROR `a` does not live long enough
|
|
... |
|
|
LL | | })
|
|
LL | | }
|
|
| |_^
|
|
|
|
|
= note: defining type: DefId(0/0:6 ~ propagate_approximated_shorter_to_static_comparing_against_free[317d]::case2[0]) with substs []
|
|
|
|
error[E0597]: `a` does not live long enough
|
|
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:41:26
|
|
|
|
|
LL | let cell = Cell::new(&a);
|
|
| ^^ borrowed value does not live long enough
|
|
...
|
|
LL | }
|
|
| - borrowed value only lives until here
|
|
|
|
|
= note: borrowed value must be valid for the static lifetime...
|
|
|
|
error: aborting due to 2 previous errors
|
|
|
|
For more information about this error, try `rustc --explain E0597`.
|