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