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