]> git.lizzy.rs Git - rust.git/blob - tests/ui/object-lifetime/object-lifetime-default-from-rptr-struct.rs
Rollup merge of #106664 - chenyukang:yukang/fix-106597-remove-lseek, r=cuviper
[rust.git] / tests / ui / object-lifetime / object-lifetime-default-from-rptr-struct.rs
1 // run-pass
2 // Test that the lifetime from the enclosing `&` is "inherited"
3 // through the `MyBox` struct.
4
5 // pretty-expanded FIXME #23616
6
7 #![allow(dead_code)]
8
9 trait Test {
10     fn foo(&self) { }
11 }
12
13 struct SomeStruct<'a> {
14     t: &'a MyBox<dyn Test>,
15     u: &'a MyBox<dyn Test+'a>,
16 }
17
18 struct MyBox<T:?Sized> {
19     b: Box<T>
20 }
21
22 fn a<'a>(t: &'a MyBox<dyn Test>, mut ss: SomeStruct<'a>) {
23     ss.t = t;
24 }
25
26 fn b<'a>(t: &'a MyBox<dyn Test>, mut ss: SomeStruct<'a>) {
27     ss.u = t;
28 }
29
30 // see also ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs
31
32 fn d<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>) {
33     ss.u = t;
34 }
35
36 fn main() {
37 }