2015-02-12 08:37:52 -06:00
|
|
|
// Test a "pass-through" object-lifetime-default that produces errors.
|
|
|
|
|
|
|
|
#![allow(dead_code)]
|
|
|
|
|
|
|
|
trait SomeTrait {
|
|
|
|
fn dummy(&self) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
struct MyBox<T:?Sized> {
|
|
|
|
r: Box<T>
|
|
|
|
}
|
|
|
|
|
|
|
|
fn deref<T>(ss: &T) -> T {
|
|
|
|
// produces the type of a deref without worrying about whether a
|
|
|
|
// move out would actually be legal
|
|
|
|
loop { }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn load0(ss: &MyBox<SomeTrait>) -> MyBox<SomeTrait> {
|
2015-07-14 18:36:15 -05:00
|
|
|
deref(ss)
|
2015-02-12 08:37:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn load1<'a,'b>(a: &'a MyBox<SomeTrait>,
|
|
|
|
b: &'b MyBox<SomeTrait>)
|
|
|
|
-> &'b MyBox<SomeTrait>
|
|
|
|
{
|
2017-09-12 16:21:53 -05:00
|
|
|
a //~ ERROR lifetime mismatch
|
2015-02-12 08:37:52 -06:00
|
|
|
}
|
|
|
|
|
2015-06-17 13:11:58 -05:00
|
|
|
fn load2<'a>(ss: &MyBox<SomeTrait+'a>) -> MyBox<SomeTrait+'a> {
|
2015-07-14 18:36:15 -05:00
|
|
|
load0(ss) //~ ERROR mismatched types
|
2015-06-17 13:11:58 -05:00
|
|
|
}
|
|
|
|
|
2015-02-12 08:37:52 -06:00
|
|
|
fn main() {
|
|
|
|
}
|