]> git.lizzy.rs Git - rust.git/blob - tests/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs
Rollup merge of #104965 - zacklukem:p-option-as_ref-docs, r=scottmcm
[rust.git] / tests / ui / object-lifetime / object-lifetime-default-from-rptr-struct-error.rs
1 // Test that the lifetime from the enclosing `&` is "inherited"
2 // through the `MyBox` struct.
3
4 #![allow(dead_code)]
5
6 trait Test {
7     fn foo(&self) { }
8 }
9
10 struct SomeStruct<'a> {
11     t: &'a MyBox<dyn Test>,
12     u: &'a MyBox<dyn Test + 'a>,
13 }
14
15 struct MyBox<T:?Sized> {
16     b: Box<T>
17 }
18
19 fn c<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>) {
20     ss.t = t;
21     //~^ ERROR lifetime may not live long enough
22 }
23
24 fn main() {
25 }