rust/tests/ui/regions/regions-close-object-into-object-5.rs

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

26 lines
625 B
Rust
Raw Normal View History

2015-02-18 10:20:01 -05:00
#![allow(warnings)]
2015-02-18 10:20:01 -05:00
trait A<T>
{
fn get(&self) -> T { panic!() }
}
2020-05-20 18:58:41 +01:00
struct B<'a, T: 'a>(&'a (A<T> + 'a));
2015-02-18 10:20:01 -05:00
2015-02-18 15:58:07 -08:00
trait X { fn foo(&self) {} }
2015-02-18 10:20:01 -05:00
impl<'a, T> X for B<'a, T> {}
2020-05-20 18:58:41 +01:00
fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
// oh dear!
Box::new(B(&*v)) as Box<dyn X>
2020-05-20 18:58:41 +01: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 13:13:25 -04:00
//~| ERROR cannot return value referencing local data `*v` [E0515]
2015-02-18 10:20:01 -05:00
}
fn main() {}