2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2015-02-12 00:45:19 +00:00
|
|
|
// Test that the lifetime from the enclosing `&` is "inherited"
|
|
|
|
// through the `MyBox` struct.
|
|
|
|
|
2015-03-22 20:13:15 +00:00
|
|
|
// pretty-expanded FIXME #23616
|
|
|
|
|
2015-02-12 00:45:19 +00:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
|
|
|
trait Test {
|
|
|
|
fn foo(&self) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SomeStruct<'a> {
|
2019-05-28 18:47:21 +00:00
|
|
|
t: &'a MyBox<dyn Test>,
|
|
|
|
u: &'a MyBox<dyn Test+'a>,
|
2015-02-12 00:45:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct MyBox<T:?Sized> {
|
|
|
|
b: Box<T>
|
|
|
|
}
|
|
|
|
|
2019-05-28 18:47:21 +00:00
|
|
|
fn a<'a>(t: &'a MyBox<dyn Test>, mut ss: SomeStruct<'a>) {
|
2015-02-12 00:45:19 +00:00
|
|
|
ss.t = t;
|
|
|
|
}
|
|
|
|
|
2019-05-28 18:47:21 +00:00
|
|
|
fn b<'a>(t: &'a MyBox<dyn Test>, mut ss: SomeStruct<'a>) {
|
2015-02-12 00:45:19 +00:00
|
|
|
ss.u = t;
|
|
|
|
}
|
|
|
|
|
2020-12-28 17:15:16 +00:00
|
|
|
// see also ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs
|
2015-02-12 00:45:19 +00:00
|
|
|
|
2019-05-28 18:47:21 +00:00
|
|
|
fn d<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>) {
|
2015-02-12 00:45:19 +00:00
|
|
|
ss.u = t;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|