diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /src/test/ui/nll/closure-requirements/propagate-approximated-ref.rs | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/nll/closure-requirements/propagate-approximated-ref.rs')
-rw-r--r-- | src/test/ui/nll/closure-requirements/propagate-approximated-ref.rs | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-ref.rs b/src/test/ui/nll/closure-requirements/propagate-approximated-ref.rs deleted file mode 100644 index 7291c6e97..000000000 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-ref.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Rather convoluted setup where we infer a relationship between two -// free regions in the closure signature (`'a` and `'b`) on the basis -// of a relationship between two bound regions (`'x` and `'y`). -// -// The idea is that, thanks to invoking `demand_y`, `'x: 'y` must -// hold, where `'x` and `'y` are bound regions. The closure can't -// prove that directly, and because `'x` and `'y` are bound it cannot -// ask the caller to prove it either. But it has bounds on `'x` and -// `'y` in terms of `'a` and `'b`, and it can propagate a relationship -// between `'a` and `'b` to the caller. -// -// Note: the use of `Cell` here is to introduce invariance. One less -// variable. - -// compile-flags:-Zverbose - -#![feature(rustc_attrs)] - -use std::cell::Cell; - -// Callee knows that: -// -// 'x: 'a -// 'b: 'y -// -// so if we are going to ensure that `'x: 'y`, then `'a: 'b` must -// hold. -fn establish_relationships<'a, 'b, F>(_cell_a: &Cell<&'a u32>, _cell_b: &Cell<&'b u32>, _closure: F) -where - F: for<'x, 'y> FnMut( - &Cell<&'a &'x u32>, // shows that 'x: 'a - &Cell<&'y &'b u32>, // shows that 'b: 'y - &Cell<&'x u32>, - &Cell<&'y u32>, - ), -{ -} - -fn demand_y<'x, 'y>(_cell_x: &Cell<&'x u32>, _cell_y: &Cell<&'y u32>, _y: &'y u32) {} - -#[rustc_regions] -fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { - establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { - // Only works if 'x: 'y: - demand_y(x, y, x.get()) - //~^ ERROR lifetime may not live long enough - }); -} - -fn main() {} |