]> git.proxmox.com Git - rustc.git/blob - src/test/ui/regions/regions-close-over-type-parameter-1.rs
New upstream version 1.62.1+dfsg1
[rustc.git] / src / test / ui / regions / regions-close-over-type-parameter-1.rs
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
5 // revisions: base nll
6 // ignore-compare-mode-nll
7 //[nll] compile-flags: -Z borrowck=mir
8
9 trait SomeTrait {
10 fn get(&self) -> isize;
11 }
12
13
14 fn make_object1<A: SomeTrait>(v: A) -> Box<dyn SomeTrait + 'static> {
15 Box::new(v) as Box<dyn SomeTrait + 'static>
16 //~^ ERROR the parameter type `A` may not live long enough
17 }
18
19 fn make_object2<'a, A: SomeTrait + 'a>(v: A) -> Box<dyn SomeTrait + 'a> {
20 Box::new(v) as Box<dyn SomeTrait + 'a>
21 }
22
23 fn make_object3<'a, 'b, A: SomeTrait + 'a>(v: A) -> Box<dyn SomeTrait + 'b> {
24 Box::new(v) as Box<dyn SomeTrait + 'b>
25 //~^ ERROR the parameter type `A` may not live long enough
26 }
27
28 fn main() {}