2015-02-18 23:58:07 +00:00
|
|
|
trait X { fn foo(&self) {} }
|
2015-01-03 09:40:33 +00:00
|
|
|
|
2019-05-28 18:46:13 +00:00
|
|
|
fn p1<T>(v: T) -> Box<dyn X + 'static>
|
2015-01-03 09:40:33 +00:00
|
|
|
where T : X
|
|
|
|
{
|
2015-02-15 08:52:21 +00:00
|
|
|
Box::new(v) //~ ERROR parameter type `T` may not live long enough
|
2015-01-03 09:40:33 +00:00
|
|
|
}
|
|
|
|
|
2019-05-28 18:46:13 +00:00
|
|
|
fn p2<T>(v: Box<T>) -> Box<dyn X + 'static>
|
2015-01-03 09:40:33 +00:00
|
|
|
where Box<T> : X
|
|
|
|
{
|
2015-02-15 08:52:21 +00:00
|
|
|
Box::new(v) //~ ERROR parameter type `T` may not live long enough
|
2015-01-03 09:40:33 +00:00
|
|
|
}
|
|
|
|
|
2019-05-28 18:46:13 +00:00
|
|
|
fn p3<'a,T>(v: T) -> Box<dyn X + 'a>
|
2015-01-03 09:40:33 +00:00
|
|
|
where T : X
|
|
|
|
{
|
2015-02-15 08:52:21 +00:00
|
|
|
Box::new(v) //~ ERROR parameter type `T` may not live long enough
|
2015-01-03 09:40:33 +00:00
|
|
|
}
|
|
|
|
|
2019-05-28 18:46:13 +00:00
|
|
|
fn p4<'a,T>(v: Box<T>) -> Box<dyn X + 'a>
|
2015-01-03 09:40:33 +00:00
|
|
|
where Box<T> : X
|
|
|
|
{
|
2015-02-15 08:52:21 +00:00
|
|
|
Box::new(v) //~ ERROR parameter type `T` may not live long enough
|
2015-01-03 09:40:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|