]> git.lizzy.rs Git - rust.git/blob - tests/ui/type-alias-impl-trait/constrain_inputs.rs
Rollup merge of #106323 - starkat99:stabilize-f16c_target_feature, r=petrochenkov
[rust.git] / tests / ui / type-alias-impl-trait / constrain_inputs.rs
1 #![feature(type_alias_impl_trait)]
2
3 mod lifetime_params {
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
8
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
13 }
14
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
20 }
21
22 // regression test for https://github.com/rust-lang/rust/issues/97104
23 mod type_params {
24     type Ty<T> = impl Sized;
25     fn define<T>(s: T) -> Ty<T> { s }
26
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
31 }
32
33 fn main() {}