]> git.proxmox.com Git - rustc.git/blame - src/test/ui/regions/regions-close-over-type-parameter-multiple.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / ui / regions / regions-close-over-type-parameter-multiple.rs
CommitLineData
1a4d82fc
JJ
1// Various tests where we over type parameters with multiple lifetime
2// bounds.
3
4trait SomeTrait { fn get(&self) -> isize; }
5
c295e0f8 6
dc9dc135 7fn make_object_good1<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'a> {
1a4d82fc 8 // A outlives 'a AND 'b...
c295e0f8 9 Box::new(v) as Box<dyn SomeTrait + 'a> // ...hence this type is safe.
1a4d82fc
JJ
10}
11
dc9dc135 12fn make_object_good2<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'b> {
1a4d82fc 13 // A outlives 'a AND 'b...
c295e0f8 14 Box::new(v) as Box<dyn SomeTrait + 'b> // ...hence this type is safe.
1a4d82fc
JJ
15}
16
dc9dc135 17fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'c> {
1a4d82fc 18 // A outlives 'a AND 'b...but not 'c.
04454e1e 19 Box::new(v) as Box<dyn SomeTrait + 'a>
923072b8 20 //~^ ERROR lifetime may not live long enough
1a4d82fc
JJ
21}
22
23fn main() {
24}