1 #![feature(type_alias_impl_trait)]
3 trait Static: 'static {}
6 type Gal<T> = impl Static;
7 fn _defining<T>() -> Gal<T> {}
9 trait Callable<Arg> { type Output; }
11 /// We can infer `<C as Callable<Arg>>::Output: 'static`,
12 /// because we know `C: 'static` and `Arg: 'static`,
13 fn box_str<C, Arg>(s: C::Output) -> Box<dyn AsRef<str> + 'static>
16 C: ?Sized + Callable<Arg> + 'static,
17 C::Output: AsRef<str>,
22 fn extend_lifetime(s: &str) -> Box<dyn AsRef<str> + 'static> {
23 type MalformedTy = dyn for<'a> Callable<Gal<&'a ()>, Output = &'a str>;
24 //~^ ERROR binding for associated type `Output` references lifetime `'a`
25 box_str::<MalformedTy, _>(s)
29 let extended = extend_lifetime(&String::from("hello"));
30 println!("{}", extended.as_ref().as_ref());