]> git.lizzy.rs Git - rust.git/blob - src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs
Auto merge of #95295 - CAD97:layout-isize, r=scottmcm
[rust.git] / src / test / ui / object-lifetime / object-lifetime-default-from-rptr-box-error.rs
1 // Test that the lifetime from the enclosing `&` is "inherited"
2 // through the `Box` struct.
3
4 #![allow(dead_code)]
5
6 trait Test {
7     fn foo(&self) { }
8 }
9
10 struct SomeStruct<'a> {
11     t: &'a Box<dyn Test>,
12 }
13
14 fn c<'a>(t: &'a Box<dyn Test+'a>, mut ss: SomeStruct<'a>) {
15     ss.t = t;
16     //~^ ERROR lifetime may not live long enough
17 }
18
19 fn main() {
20 }