]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-close-object-into-object-5.rs
Rollup merge of #97317 - GuillaumeGomez:gui-settings-text-click, r=jsha
[rust.git] / src / test / ui / regions / regions-close-object-into-object-5.rs
1 // revisions: base nll
2 // ignore-compare-mode-nll
3 //[nll] compile-flags: -Z borrowck=mir
4
5 #![allow(warnings)]
6
7
8 trait A<T>
9 {
10     fn get(&self) -> T { panic!() }
11 }
12
13 struct B<'a, T: 'a>(&'a (A<T> + 'a));
14
15 trait X { fn foo(&self) {} }
16
17 impl<'a, T> X for B<'a, T> {}
18
19 fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
20     // oh dear!
21     Box::new(B(&*v)) as Box<dyn X>
22     //~^ ERROR the parameter type `T` may not live long enough
23     //~| ERROR the parameter type `T` may not live long enough
24     //~| ERROR the parameter type `T` may not live long enough
25     //~| ERROR the parameter type `T` may not live long enough
26     //[base]~| ERROR the parameter type `T` may not live long enough
27     //[base]~| ERROR the parameter type `T` may not live long enough
28     //[base]~| ERROR the parameter type `T` may not live long enough
29     //[nll]~| ERROR cannot return value referencing local data `*v` [E0515]
30 }
31
32 fn main() {}