2016-07-31 15:01:02 -05:00
|
|
|
use std::fmt;
|
|
|
|
|
|
|
|
pub trait MethodType {
|
|
|
|
type GetProp: ?Sized;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct MTFn;
|
|
|
|
|
|
|
|
impl<'a> MethodType for MTFn { //~ ERROR E0207
|
2019-05-28 13:46:13 -05:00
|
|
|
type GetProp = dyn fmt::Debug + 'a;
|
2016-07-31 15:01:02 -05:00
|
|
|
}
|
|
|
|
|
2019-05-28 13:46:13 -05:00
|
|
|
fn bad(a: Box<<MTFn as MethodType>::GetProp>) -> Box<dyn fmt::Debug+'static> {
|
2016-07-31 15:01:02 -05:00
|
|
|
a
|
|
|
|
}
|
|
|
|
|
2019-05-28 13:46:13 -05:00
|
|
|
fn dangling(a: &str) -> Box<dyn fmt::Debug> {
|
2016-07-31 15:01:02 -05:00
|
|
|
bad(Box::new(a))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut s = "hello".to_string();
|
|
|
|
let x = dangling(&s);
|
|
|
|
s = String::new();
|
|
|
|
println!("{:?}", x);
|
|
|
|
}
|