]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-35139.rs
Rollup merge of #75180 - KodrAus:feat/error-by-ref, r=m-ou-se
[rust.git] / src / test / ui / issues / issue-35139.rs
1 use std::fmt;
2
3 pub trait MethodType {
4     type GetProp: ?Sized;
5 }
6
7 pub struct MTFn;
8
9 impl<'a> MethodType for MTFn { //~ ERROR E0207
10     type GetProp = dyn fmt::Debug + 'a;
11 }
12
13 fn bad(a: Box<<MTFn as MethodType>::GetProp>) -> Box<dyn fmt::Debug+'static> {
14     a
15 }
16
17 fn dangling(a: &str) -> Box<dyn fmt::Debug> {
18     bad(Box::new(a))
19 }
20
21 fn main() {
22     let mut s = "hello".to_string();
23     let x = dangling(&s);
24     s = String::new();
25     println!("{:?}", x);
26 }