]> git.proxmox.com Git - rustc.git/blame - src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / ui / nll / closure-requirements / propagate-fail-to-approximate-longer-no-bounds.rs
CommitLineData
ff7c6d11
XL
1// Similarly to escape-argument-callee, a test case where the closure
2// requires a relationship between 2 unrelated higher-ranked regions,
3// with no helpful relations between the HRRs and free regions.
4//
5// In this case, the error is reported by the closure itself. This is
6// because it is unable to approximate the higher-ranked region `'x`,
7// as it knows of no relationships between `'x` and any
8// non-higher-ranked regions.
9
923072b8 10// compile-flags:-Zverbose
ff7c6d11
XL
11
12#![feature(rustc_attrs)]
13
14use std::cell::Cell;
15
16// Callee knows that:
17//
18// 'b: 'y
19//
20// but this doesn't really help us in proving that `'x: 'y`, so closure gets an error.
21fn establish_relationships<'a, 'b, F>(_cell_a: &Cell<&'a u32>, _cell_b: &Cell<&'b u32>, _closure: F)
22where
23 F: for<'x, 'y> FnMut(
24 &Cell<&'y &'b u32>, // shows that 'b: 'y
25 &Cell<&'x u32>,
26 &Cell<&'y u32>,
27 ),
28{
29}
30
31fn demand_y<'x, 'y>(_cell_x: &Cell<&'x u32>, _cell_y: &Cell<&'y u32>, _y: &'y u32) {}
32
33#[rustc_regions]
34fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
35 establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
36 // Only works if 'x: 'y:
37 demand_y(x, y, x.get())
b7449926 38 //~^ ERROR
ff7c6d11
XL
39 });
40}
41
42fn main() {}