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 // compile-flags:-Zborrowck=mir -Zverbose
14 #![feature(dyn_trait)]
15 #![feature(rustc_attrs)]
19 fn with_signature<'a, T, F>(x: Box<T>, op: F) -> Box<dyn Debug + 'a>
20 where F: FnOnce(Box<T>) -> Box<dyn Debug + 'a>
26 fn no_region<'a, T>(x: Box<T>) -> Box<dyn Debug + 'a>
30 // Here, the closure winds up being required to prove that `T:
31 // 'a`. In principle, it could know that, except that it is
32 // type-checked in a fully generic way, and hence it winds up with
33 // a propagated requirement that `T: '_#2`, where `'_#2` appears
34 // in the return type. The caller makes the mapping from `'_#2` to
35 // `'a` (and subsequently reports an error).
37 with_signature(x, |y| y)
38 //~^ WARNING not reporting region error due to nll
39 //~| ERROR the parameter type `T` may not live long enough
42 fn correct_region<'a, T>(x: Box<T>) -> Box<Debug + 'a>
49 fn wrong_region<'a, 'b, T>(x: Box<T>) -> Box<Debug + 'a>
54 //~^ WARNING not reporting region error due to nll
55 //~| ERROR the parameter type `T` may not live long enough
58 fn outlives_region<'a, 'b, T>(x: Box<T>) -> Box<Debug + 'a>