]> git.lizzy.rs Git - rust.git/blob - tests/ui/object-lifetime/object-lifetime-default-from-rptr-box.rs
Rollup merge of #106664 - chenyukang:yukang/fix-106597-remove-lseek, r=cuviper
[rust.git] / tests / ui / object-lifetime / object-lifetime-default-from-rptr-box.rs
1 // run-pass
2 // Test that the lifetime from the enclosing `&` is "inherited"
3 // through the `Box` 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 Box<dyn Test>,
15     u: &'a Box<dyn Test+'a>,
16 }
17
18 fn a<'a>(t: &'a Box<dyn Test>, mut ss: SomeStruct<'a>) {
19     ss.t = t;
20 }
21
22 fn b<'a>(t: &'a Box<dyn Test>, mut ss: SomeStruct<'a>) {
23     ss.u = t;
24 }
25
26 // see also ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs
27
28 fn d<'a>(t: &'a Box<dyn Test+'a>, mut ss: SomeStruct<'a>) {
29     ss.u = t;
30 }
31
32 fn main() {
33 }