1 // Taken from https://github.com/rust-lang/rust/issues/44454#issuecomment-1175925928
3 trait Trait<ARG: 'static>: 'static {
4 type Assoc: AsRef<str>;
7 fn hr<T: ?Sized, ARG>(x: T::Assoc) -> Box<dyn AsRef<str> + 'static>
14 fn extend_lt<'a>(x: &'a str) -> Box<dyn AsRef<str> + 'static> {
15 type DynTrait = dyn for<'a> Trait<&'a str, Assoc = &'a str>;
16 hr::<DynTrait, _>(x) //~ ERROR: borrowed data escapes outside of function
20 let extended = extend_lt(&String::from("hello"));
21 println!("{}", extended.as_ref().as_ref());