2018-12-16 22:21:47 -05:00
|
|
|
struct Direct<'a> {
|
2015-01-08 21:54:35 +11:00
|
|
|
f: &'a isize
|
2012-08-23 16:22:23 -07:00
|
|
|
}
|
|
|
|
|
2018-12-16 22:21:47 -05:00
|
|
|
struct Indirect1 {
|
2013-02-27 19:41:02 -05:00
|
|
|
// Here the lifetime parameter of direct is bound by the fn()
|
2019-05-28 14:46:13 -04:00
|
|
|
g: Box<dyn FnOnce(Direct) + 'static>
|
2012-08-23 16:22:23 -07:00
|
|
|
}
|
|
|
|
|
2018-12-16 22:21:47 -05:00
|
|
|
struct Indirect2<'a> {
|
2013-12-09 23:16:18 -08:00
|
|
|
// But here it is set to 'a
|
2019-05-28 14:46:13 -04:00
|
|
|
g: Box<dyn FnOnce(Direct<'a>) + 'static>
|
2012-08-23 16:22:23 -07:00
|
|
|
}
|
|
|
|
|
2022-04-19 12:56:18 +02:00
|
|
|
fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p }
|
2022-04-01 13:13:25 -04:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
2013-05-23 21:37:37 -04:00
|
|
|
|
2018-12-16 22:21:47 -05:00
|
|
|
fn take_indirect1(p: Indirect1) -> Indirect1 { p }
|
2013-05-23 21:37:37 -04:00
|
|
|
|
2022-04-19 12:56:18 +02:00
|
|
|
fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p }
|
2022-04-01 13:13:25 -04:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
|
|
|
//~| ERROR lifetime may not live long enough
|
2013-05-23 21:37:37 -04:00
|
|
|
|
2012-08-23 16:22:23 -07:00
|
|
|
fn main() {}
|