1 #![feature(type_alias_impl_trait)]
4 type Ty<'a> = impl Sized;
5 fn defining(s: &str) -> Ty<'_> { s }
6 fn execute(ty: Ty<'_>) -> &str { todo!() }
7 //~^ ERROR return type references an anonymous lifetime, which is not constrained by the fn input types
9 type BadFnSig = fn(Ty<'_>) -> &str;
10 //~^ ERROR return type references an anonymous lifetime, which is not constrained by the fn input types
11 type BadTraitRef = dyn Fn(Ty<'_>) -> &str;
12 //~^ ERROR binding for associated type `Output` references an anonymous lifetime
15 mod lifetime_params_2 {
16 type Ty<'a> = impl FnOnce() -> &'a str;
17 fn defining(s: &str) -> Ty<'_> { move || s }
18 fn execute(ty: Ty<'_>) -> &str { ty() }
19 //~^ ERROR return type references an anonymous lifetime, which is not constrained by the fn input types
22 // regression test for https://github.com/rust-lang/rust/issues/97104
24 type Ty<T> = impl Sized;
25 fn define<T>(s: T) -> Ty<T> { s }
27 type BadFnSig = fn(Ty<&str>) -> &str;
28 //~^ ERROR return type references an anonymous lifetime, which is not constrained by the fn input types
29 type BadTraitRef = dyn Fn(Ty<&str>) -> &str;
30 //~^ ERROR binding for associated type `Output` references an anonymous lifetime