rust/tests/ui/issues/issue-35139.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
458 B
Rust
Raw Normal View History

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;
}
2019-05-28 18:46:13 +00:00
fn bad(a: Box<<MTFn as MethodType>::GetProp>) -> Box<dyn fmt::Debug+'static> {
a
}
2019-05-28 18:46:13 +00:00
fn dangling(a: &str) -> Box<dyn fmt::Debug> {
bad(Box::new(a))
}
fn main() {
let mut s = "hello".to_string();
let x = dangling(&s);
s = String::new();
println!("{:?}", x);
}