rust/tests/ui/nll/closure-requirements/propagate-approximated-shor...

50 lines
2.1 KiB
Plaintext

note: external requirements
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:32:47
|
LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
| ^^^^^^^^^^^^^^^^^
|
= note: defining type: supply::{closure#0} with closure args [
i16,
for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&'^0 std::cell::Cell<&'?1 &'^1 u32>, &'^2 std::cell::Cell<&'^1 u32>, &'^3 std::cell::Cell<&'^4 u32>)),
(),
]
= note: late-bound region is '?2
= note: late-bound region is '?3
= note: number of external vids: 4
= note: where '?1: '?0
note: no external requirements
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:31:1
|
LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: supply
error[E0521]: borrowed data escapes outside of function
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:32:5
|
LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
| -- ------ `cell_a` is a reference that is only valid in the function body
| |
| lifetime `'a` defined here
LL | / establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
LL | |
LL | |
LL | | // Only works if 'x: 'y:
LL | | demand_y(x, y, x.get())
LL | | });
| | ^
| | |
| |______`cell_a` escapes the function body here
| argument requires that `'a` must outlive `'static`
|
= note: requirement occurs because of the type `Cell<&'?9 u32>`, which makes the generic argument `&'?9 u32` invariant
= note: the struct `Cell<T>` is invariant over the parameter `T`
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0521`.