]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-close-over-type-parameter-1.rs
Update tests
[rust.git] / src / test / ui / regions / regions-close-over-type-parameter-1.rs
1 #![feature(box_syntax)]
2
3 // Test for what happens when a type parameter `A` is closed over into
4 // an object. This should yield errors unless `A` (and the object)
5 // both have suitable bounds.
6
7 trait SomeTrait {
8     fn get(&self) -> isize;
9 }
10
11 fn make_object1<A: SomeTrait>(v: A) -> Box<dyn SomeTrait + 'static> {
12     box v as Box<dyn SomeTrait + 'static>
13     //~^ ERROR the parameter type `A` may not live long enough
14 }
15
16 fn make_object2<'a, A: SomeTrait + 'a>(v: A) -> Box<dyn SomeTrait + 'a> {
17     box v as Box<dyn SomeTrait + 'a>
18 }
19
20 fn make_object3<'a, 'b, A: SomeTrait + 'a>(v: A) -> Box<dyn SomeTrait + 'b> {
21     box v as Box<dyn SomeTrait + 'b>
22     //~^ ERROR the parameter type `A` may not live long enough
23 }
24
25 fn main() {}