]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-close-over-type-parameter-1.rs
Rollup merge of #57107 - mjbshaw:thread_local_test, r=nikomatsakis
[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 { fn get(&self) -> isize; }
8
9 fn make_object1<A:SomeTrait>(v: A) -> Box<SomeTrait+'static> {
10     box v as Box<SomeTrait+'static>
11         //~^ ERROR the parameter type `A` may not live long enough
12         //~| ERROR the parameter type `A` may not live long enough
13 }
14
15 fn make_object2<'a,A:SomeTrait+'a>(v: A) -> Box<SomeTrait+'a> {
16     box v as Box<SomeTrait+'a>
17 }
18
19 fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box<SomeTrait+'b> {
20     box v as Box<SomeTrait+'b>
21         //~^ ERROR the parameter type `A` may not live long enough
22         //~| ERROR the parameter type `A` may not live long enough
23 }
24
25 fn main() { }