]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Test for what happens when a type parameter `A` is closed over into |
2 | // an object. This should yield errors unless `A` (and the object) | |
3 | // both have suitable bounds. | |
4 | ||
04454e1e FG |
5 | // revisions: base nll |
6 | // ignore-compare-mode-nll | |
7 | //[nll] compile-flags: -Z borrowck=mir | |
c295e0f8 | 8 | |
f9f354fc XL |
9 | trait SomeTrait { |
10 | fn get(&self) -> isize; | |
11 | } | |
1a4d82fc | 12 | |
c295e0f8 | 13 | |
f9f354fc | 14 | fn make_object1<A: SomeTrait>(v: A) -> Box<dyn SomeTrait + 'static> { |
c295e0f8 | 15 | Box::new(v) as Box<dyn SomeTrait + 'static> |
f9f354fc | 16 | //~^ ERROR the parameter type `A` may not live long enough |
1a4d82fc JJ |
17 | } |
18 | ||
f9f354fc | 19 | fn make_object2<'a, A: SomeTrait + 'a>(v: A) -> Box<dyn SomeTrait + 'a> { |
c295e0f8 | 20 | Box::new(v) as Box<dyn SomeTrait + 'a> |
1a4d82fc JJ |
21 | } |
22 | ||
f9f354fc | 23 | fn make_object3<'a, 'b, A: SomeTrait + 'a>(v: A) -> Box<dyn SomeTrait + 'b> { |
c295e0f8 | 24 | Box::new(v) as Box<dyn SomeTrait + 'b> |
f9f354fc | 25 | //~^ ERROR the parameter type `A` may not live long enough |
1a4d82fc JJ |
26 | } |
27 | ||
f9f354fc | 28 | fn main() {} |