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 15:20:01 +00:00
#![allow(warnings)]
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> {
// oh dear!
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() {}