1 //! A simple test for testing many permutations of allowedness of
6 fn in_parameters(_: impl Debug) { panic!() }
9 fn in_return() -> impl Debug { panic!() }
12 fn in_adt_in_parameters(_: Vec<impl Debug>) { panic!() }
15 fn in_adt_in_return() -> Vec<impl Debug> { panic!() }
18 fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() }
19 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
22 fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() }
23 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
26 fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() }
27 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
30 fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() }
31 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
34 fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() }
35 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
38 fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() }
39 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
42 fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() }
43 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
46 fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() }
47 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
50 fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() }
51 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
52 //~^^ ERROR nested `impl Trait` is not allowed
55 fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() }
56 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
59 fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() }
60 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
61 //~^^ ERROR nested `impl Trait` is not allowed
64 fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() }
65 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
68 fn in_Fn_parameter_in_generics<F: Fn(impl Debug)> (_: F) { panic!() }
69 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
72 fn in_Fn_return_in_generics<F: Fn() -> impl Debug> (_: F) { panic!() }
73 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
77 fn in_impl_Trait_in_parameters(_: impl Iterator<Item = impl Iterator>) { panic!() }
80 fn in_impl_Trait_in_return() -> impl IntoIterator<Item = impl IntoIterator> {
81 vec![vec![0; 10], vec![12; 7], vec![8; 3]]
85 struct InBraceStructField { x: impl Debug }
86 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
89 struct InAdtInBraceStructField { x: Vec<impl Debug> }
90 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
93 struct InTupleStructField(impl Debug);
94 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
98 InBraceVariant { x: impl Debug },
99 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
100 InTupleVariant(impl Debug),
101 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
105 trait InTraitDefnParameters {
106 fn in_parameters(_: impl Debug);
110 trait InTraitDefnReturn {
111 fn in_return() -> impl Debug;
112 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
115 // Allowed and disallowed in trait impls
118 fn in_trait_impl_parameter(_: impl Debug);
119 fn in_trait_impl_return() -> Self::Out;
121 impl DummyTrait for () {
122 type Out = impl Debug;
123 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
125 fn in_trait_impl_parameter(_: impl Debug) { }
128 fn in_trait_impl_return() -> impl Debug { () }
129 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
135 fn in_inherent_impl_parameters(_: impl Debug) { }
136 fn in_inherent_impl_return() -> impl Debug { () }
141 fn in_foreign_parameters(_: impl Debug);
142 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
144 fn in_foreign_return() -> impl Debug;
145 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
149 extern "C" fn in_extern_fn_parameters(_: impl Debug) {
153 extern "C" fn in_extern_fn_return() -> impl Debug {
157 type InTypeAlias<R> = impl Debug;
158 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
160 type InReturnInTypeAlias<R> = fn() -> impl Debug;
161 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
163 // Disallowed in impl headers
164 impl PartialEq<impl Debug> for () {
165 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
168 // Disallowed in impl headers
169 impl PartialEq<()> for impl Debug {
170 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
173 // Disallowed in inherent impls
175 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
178 // Disallowed in inherent impls
179 struct InInherentImplAdt<T> { t: T }
180 impl InInherentImplAdt<impl Debug> {
181 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
184 // Disallowed in where clauses
185 fn in_fn_where_clause()
186 where impl Debug: Debug
187 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
191 // Disallowed in where clauses
192 fn in_adt_in_fn_where_clause()
193 where Vec<impl Debug>: Debug
194 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
199 fn in_trait_parameter_in_fn_where_clause<T>()
200 where T: PartialEq<impl Debug>
201 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
206 fn in_Fn_parameter_in_fn_where_clause<T>()
207 where T: Fn(impl Debug)
208 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
213 fn in_Fn_return_in_fn_where_clause<T>()
214 where T: Fn() -> impl Debug
215 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
220 let _in_local_variable: impl Fn() = || {};
221 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
222 let _in_return_in_local_variable = || -> impl Fn() { || {} };
223 //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types