blob: 610f757453ba64e54a2ea40747794af254d04e19 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
// Test for what happens when a type parameter `A` is closed over into
// an object. This should yield errors unless `A` (and the object)
// both have suitable bounds.
trait SomeTrait {
fn get(&self) -> isize;
}
fn make_object1<A: SomeTrait>(v: A) -> Box<dyn SomeTrait + 'static> {
Box::new(v) as Box<dyn SomeTrait + 'static>
//~^ ERROR the parameter type `A` may not live long enough
}
fn make_object2<'a, A: SomeTrait + 'a>(v: A) -> Box<dyn SomeTrait + 'a> {
Box::new(v) as Box<dyn SomeTrait + 'a>
}
fn make_object3<'a, 'b, A: SomeTrait + 'a>(v: A) -> Box<dyn SomeTrait + 'b> {
Box::new(v) as Box<dyn SomeTrait + 'b>
//~^ ERROR the parameter type `A` may not live long enough
}
fn main() {}
|