1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Similarly to escape-argument-callee, a test case where the closure
12 // requires a relationship between 2 unrelated higher-ranked regions,
13 // with no helpful relations between the HRRs and free regions.
15 // In this case, the error is reported by the closure itself. This is
16 // because it is unable to approximate the higher-ranked region `'x`,
17 // as it knows of no relationships between `'x` and any
18 // non-higher-ranked regions.
20 // compile-flags:-Zborrowck=mir -Zverbose
22 #![feature(rustc_attrs)]
30 // but this doesn't really help us in proving that `'x: 'y`, so closure gets an error.
31 fn establish_relationships<'a, 'b, F>(_cell_a: &Cell<&'a u32>, _cell_b: &Cell<&'b u32>, _closure: F)
34 &Cell<&'y &'b u32>, // shows that 'b: 'y
41 fn demand_y<'x, 'y>(_cell_x: &Cell<&'x u32>, _cell_y: &Cell<&'y u32>, _y: &'y u32) {}
44 fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
45 establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
46 // Only works if 'x: 'y:
47 demand_y(x, y, x.get())
48 //~^ WARN not reporting region error due to nll