granite-rust/src/test/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.

33 lines
927 B
Rust
Raw Normal View History

// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
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
//[base]~| ERROR the parameter type `T` may not live long enough
//[base]~| ERROR the parameter type `T` may not live long enough
//[base]~| ERROR the parameter type `T` may not live long enough
//[nll]~| ERROR cannot return value referencing local data `*v` [E0515]
2015-02-18 10:20:01 -05:00
}
fn main() {}