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

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

34 lines
601 B
Rust
Raw Normal View History

//@ run-pass
// Test that the lifetime from the enclosing `&` is "inherited"
// through the `Box` struct.
//@ pretty-expanded FIXME #23616
#![allow(dead_code)]
trait Test {
fn foo(&self) { }
}
struct SomeStruct<'a> {
2019-05-28 18:47:21 +00:00
t: &'a Box<dyn Test>,
u: &'a Box<dyn Test+'a>,
}
2019-05-28 18:47:21 +00:00
fn a<'a>(t: &'a Box<dyn Test>, mut ss: SomeStruct<'a>) {
ss.t = t;
}
2019-05-28 18:47:21 +00:00
fn b<'a>(t: &'a Box<dyn Test>, mut ss: SomeStruct<'a>) {
ss.u = t;
}
2020-12-28 17:15:16 +00:00
// see also ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs
2019-05-28 18:47:21 +00:00
fn d<'a>(t: &'a Box<dyn Test+'a>, mut ss: SomeStruct<'a>) {
ss.u = t;
}
fn main() {
}