rust/tests/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
347 B
Rust
Raw Normal View History

// Test that the lifetime from the enclosing `&` is "inherited"
// through the `Box` struct.
#![allow(dead_code)]
trait Test {
fn foo(&self) { }
}
struct SomeStruct<'a> {
2019-05-28 18:46:13 +00:00
t: &'a Box<dyn Test>,
}
2019-05-28 18:46:13 +00:00
fn c<'a>(t: &'a Box<dyn Test+'a>, mut ss: SomeStruct<'a>) {
ss.t = t;
2022-04-01 17:13:25 +00:00
//~^ ERROR lifetime may not live long enough
}
fn main() {
}