1 // Test a "pass-through" object-lifetime-default that produces errors.
2 
3 #![allow(dead_code)]
4 
5 trait SomeTrait {
dummy(&self)6     fn dummy(&self) { }
7 }
8 
9 struct MyBox<T:?Sized> {
10     r: Box<T>
11 }
12 
deref<T>(ss: &T) -> T13 fn deref<T>(ss: &T) -> T {
14     // produces the type of a deref without worrying about whether a
15     // move out would actually be legal
16     loop { }
17 }
18 
load0(ss: &MyBox<dyn SomeTrait>) -> MyBox<dyn SomeTrait>19 fn load0(ss: &MyBox<dyn SomeTrait>) -> MyBox<dyn SomeTrait> {
20     deref(ss)
21 }
22 
load1<'a,'b>(a: &'a MyBox<dyn SomeTrait>, b: &'b MyBox<dyn SomeTrait>) -> &'b MyBox<dyn SomeTrait>23 fn load1<'a,'b>(a: &'a MyBox<dyn SomeTrait>,
24                 b: &'b MyBox<dyn SomeTrait>)
25                 -> &'b MyBox<dyn SomeTrait>
26 {
27     a //~ ERROR lifetime mismatch
28 }
29 
load2<'a>(ss: &MyBox<dyn SomeTrait + 'a>) -> MyBox<dyn SomeTrait + 'a>30 fn load2<'a>(ss: &MyBox<dyn SomeTrait + 'a>) -> MyBox<dyn SomeTrait + 'a> {
31     load0(ss) //~ ERROR mismatched types
32 }
33 
main()34 fn main() {
35 }
36