]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/object-lifetime-default-from-rptr-box.rs
Auto merge of #61817 - eddyb:begone-gcx-attempt-2, r=oli-obk
[rust.git] / src / test / run-pass / object-lifetime-default-from-rptr-box.rs
1 // Test that the lifetime from the enclosing `&` is "inherited"
2 // through the `Box` struct.
3
4 // pretty-expanded FIXME #23616
5
6 #![allow(dead_code)]
7
8 trait Test {
9     fn foo(&self) { }
10 }
11
12 struct SomeStruct<'a> {
13     t: &'a Box<dyn Test>,
14     u: &'a Box<dyn Test+'a>,
15 }
16
17 fn a<'a>(t: &'a Box<dyn Test>, mut ss: SomeStruct<'a>) {
18     ss.t = t;
19 }
20
21 fn b<'a>(t: &'a Box<dyn Test>, mut ss: SomeStruct<'a>) {
22     ss.u = t;
23 }
24
25 // see also compile-fail/object-lifetime-default-from-rptr-box-error.rs
26
27 fn d<'a>(t: &'a Box<dyn Test+'a>, mut ss: SomeStruct<'a>) {
28     ss.u = t;
29 }
30
31 fn main() {
32 }