]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-close-over-type-parameter-multiple.rs
Auto merge of #106143 - matthiaskrgr:rollup-3kpy1dc, r=matthiaskrgr
[rust.git] / src / test / ui / regions / regions-close-over-type-parameter-multiple.rs
1 // Various tests where we over type parameters with multiple lifetime
2 // bounds.
3
4 trait SomeTrait { fn get(&self) -> isize; }
5
6
7 fn make_object_good1<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'a> {
8     // A outlives 'a AND 'b...
9     Box::new(v) as Box<dyn SomeTrait + 'a> // ...hence this type is safe.
10 }
11
12 fn make_object_good2<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'b> {
13     // A outlives 'a AND 'b...
14     Box::new(v) as Box<dyn SomeTrait + 'b> // ...hence this type is safe.
15 }
16
17 fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'c> {
18     // A outlives 'a AND 'b...but not 'c.
19     Box::new(v) as Box<dyn SomeTrait + 'a>
20     //~^ ERROR lifetime may not live long enough
21 }
22
23 fn main() {
24 }