]> git.lizzy.rs Git - rust.git/blob - src/test/ui/object-lifetime/object-lifetime-default-mybox.rs
Merge commit '3e7c6dec244539970b593824334876f8b6ed0b18' into clippyup
[rust.git] / src / test / ui / object-lifetime / object-lifetime-default-mybox.rs
1 // Test a "pass-through" object-lifetime-default that produces errors.
2
3 #![allow(dead_code)]
4
5 trait SomeTrait {
6     fn dummy(&self) { }
7 }
8
9 struct MyBox<T:?Sized> {
10     r: Box<T>
11 }
12
13 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
19 fn load0(ss: &MyBox<dyn SomeTrait>) -> MyBox<dyn SomeTrait> {
20     deref(ss)
21 }
22
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
30 fn load2<'a>(ss: &MyBox<dyn SomeTrait + 'a>) -> MyBox<dyn SomeTrait + 'a> {
31     load0(ss) //~ ERROR mismatched types
32 }
33
34 fn main() {
35 }