]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.rs
Omit 'missing IndexMut impl' suggestion when IndexMut is implemented.
[rust.git] / src / test / ui / nll / closure-requirements / propagate-fail-to-approximate-longer-no-bounds.rs
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.
4 //
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.
10
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.
14 //
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.
19
20 // compile-flags:-Zborrowck=mir -Zverbose
21
22 #![feature(rustc_attrs)]
23
24 use std::cell::Cell;
25
26 // Callee knows that:
27 //
28 // 'b: 'y
29 //
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)
32 where
33     F: for<'x, 'y> FnMut(
34         &Cell<&'y &'b u32>, // shows that 'b: 'y
35         &Cell<&'x u32>,
36         &Cell<&'y u32>,
37     ),
38 {
39 }
40
41 fn demand_y<'x, 'y>(_cell_x: &Cell<&'x u32>, _cell_y: &Cell<&'y u32>, _y: &'y u32) {}
42
43 #[rustc_regions]
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
49         //~| ERROR
50     });
51 }
52
53 fn main() {}