2015-02-18 15:20:01 +00:00
|
|
|
#![allow(warnings)]
|
|
|
|
|
2021-08-25 00:39:40 +00:00
|
|
|
|
2015-02-18 15:20:01 +00:00
|
|
|
trait A<T>
|
|
|
|
{
|
|
|
|
fn get(&self) -> T { panic!() }
|
|
|
|
}
|
|
|
|
|
2020-05-20 17:58:41 +00:00
|
|
|
struct B<'a, T: 'a>(&'a (A<T> + 'a));
|
2015-02-18 15:20:01 +00:00
|
|
|
|
2015-02-18 23:58:07 +00:00
|
|
|
trait X { fn foo(&self) {} }
|
2015-02-18 15:20:01 +00:00
|
|
|
|
|
|
|
impl<'a, T> X for B<'a, T> {}
|
|
|
|
|
2020-05-20 17:58:41 +00:00
|
|
|
fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
|
2015-08-07 17:23:11 +00:00
|
|
|
// oh dear!
|
2021-08-25 00:39:40 +00:00
|
|
|
Box::new(B(&*v)) as Box<dyn X>
|
2020-05-20 17:58:41 +00:00
|
|
|
//~^ ERROR the parameter type `T` may not live long enough
|
|
|
|
//~| ERROR the parameter type `T` may not live long enough
|
|
|
|
//~| ERROR the parameter type `T` may not live long enough
|
|
|
|
//~| ERROR the parameter type `T` may not live long enough
|
2022-04-01 17:13:25 +00:00
|
|
|
//~| ERROR cannot return value referencing local data `*v` [E0515]
|
2015-02-18 15:20:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|