]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.rs
Don't ICE on tuple struct ctor with incorrect arg count
[rust.git] / src / test / ui / nll / ty-outlives / ty-param-closure-approximate-lower-bound.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 // compile-flags:-Zborrowck=mir -Zverbose
12
13 #![allow(warnings)]
14 #![feature(dyn_trait)]
15 #![feature(rustc_attrs)]
16
17 use std::cell::Cell;
18
19 // Invoke in such a way that the callee knows:
20 //
21 // - 'a: 'x
22 //
23 // and it must prove that `T: 'x`. Callee passes along `T: 'a`.
24 fn twice<'a, F, T>(v: Cell<&'a ()>, value: T, mut f: F)
25 where
26     F: for<'x> FnMut(Option<Cell<&'a &'x ()>>, &T),
27 {
28     f(None, &value);
29     f(None, &value);
30 }
31
32 #[rustc_regions]
33 fn generic<T>(value: T) {
34     let cell = Cell::new(&());
35     twice(cell, value, |a, b| invoke(a, b));
36     //~^ WARNING not reporting region error
37     //
38     // This error from the old region solver looks bogus.
39 }
40
41 #[rustc_regions]
42 fn generic_fail<'a, T>(cell: Cell<&'a ()>, value: T) {
43     twice(cell, value, |a, b| invoke(a, b));
44     //~^ WARNING not reporting region error
45     //~| WARNING not reporting region error
46     //~| ERROR the parameter type `T` may not live long enough
47 }
48
49 fn invoke<'a, 'x, T>(x: Option<Cell<&'x &'a ()>>, y: &T)
50 where
51     T: 'x,
52 {
53 }
54
55 fn main() {}