Skip to content

Commit f5936bc

Browse files
committed
DO NOT MERGE temporarily disable where-allowed UI test
1 parent 0743b89 commit f5936bc

File tree

2 files changed

+16
-674
lines changed

2 files changed

+16
-674
lines changed

tests/ui/impl-trait/where-allowed.rs

Lines changed: 12 additions & 242 deletions
Original file line numberDiff line numberDiff line change
@@ -1,256 +1,26 @@
1-
//! A simple test for testing many permutations of allowedness of
2-
//! impl Trait
3-
#![feature(impl_trait_in_fn_trait_return)]
4-
#![feature(custom_inner_attributes)]
5-
#![rustfmt::skip]
6-
use std::fmt::Debug;
7-
8-
// Allowed
9-
fn in_parameters(_: impl Debug) { panic!() }
10-
11-
// Allowed
12-
fn in_return() -> impl Debug { panic!() }
13-
14-
// Allowed
15-
fn in_adt_in_parameters(_: Vec<impl Debug>) { panic!() }
16-
17-
// Disallowed
18-
fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() }
19-
//~^ ERROR `impl Trait` is not allowed in `fn` pointer
20-
21-
// Disallowed
22-
fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() }
23-
//~^ ERROR `impl Trait` is not allowed in `fn` pointer
24-
25-
// Disallowed
26-
fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() }
27-
//~^ ERROR `impl Trait` is not allowed in `fn` pointer
28-
29-
// Disallowed
30-
fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() }
31-
//~^ ERROR `impl Trait` is not allowed in `fn` pointer
32-
33-
// Disallowed
34-
fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() }
35-
//~^ ERROR `impl Trait` is not allowed in the parameters of `Fn` trait bounds
36-
37-
// Disallowed
38-
fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() }
39-
//~^ ERROR `impl Trait` is not allowed in the return type of `Fn` trait bounds
40-
41-
// Disallowed
42-
fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() }
43-
//~^ ERROR `impl Trait` is not allowed in the parameters of `Fn` trait bounds
44-
45-
// Allowed (but it's still ambiguous; nothing constrains the RPIT in this body).
46-
fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() }
47-
//~^ ERROR: type annotations needed
48-
49-
// Disallowed
50-
fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() }
51-
//~^ ERROR `impl Trait` is not allowed in the parameters of `Fn` trait bounds
52-
//~^^ ERROR nested `impl Trait` is not allowed
53-
54-
// Disallowed
55-
fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() }
56-
//~^ ERROR `impl Trait` is not allowed in the return type of `Fn` trait bounds
57-
58-
// Disallowed
59-
fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() }
60-
//~^ ERROR `impl Trait` is not allowed in the parameters of `Fn` trait bounds
61-
//~| ERROR nested `impl Trait` is not allowed
62-
63-
// Allowed
64-
fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() }
65-
//~^ ERROR: type annotations needed
66-
67-
// Disallowed
68-
fn in_Fn_parameter_in_generics<F: Fn(impl Debug)> (_: F) { panic!() }
69-
//~^ ERROR `impl Trait` is not allowed in the parameters of `Fn` trait bounds
70-
71-
// Disallowed
72-
fn in_Fn_return_in_generics<F: Fn() -> impl Debug> (_: F) { panic!() }
73-
//~^ ERROR `impl Trait` is not allowed in the return type of `Fn` trait bounds
74-
75-
76-
// Allowed
77-
fn in_impl_Trait_in_parameters(_: impl Iterator<Item = impl Iterator>) { panic!() }
78-
79-
// Allowed
80-
fn in_impl_Trait_in_return() -> impl IntoIterator<Item = impl IntoIterator> {
81-
vec![vec![0; 10], vec![12; 7], vec![8; 3]]
82-
}
83-
84-
// Disallowed
85-
struct InBraceStructField { x: impl Debug }
86-
//~^ ERROR `impl Trait` is not allowed in field types
87-
88-
// Disallowed
89-
struct InAdtInBraceStructField { x: Vec<impl Debug> }
90-
//~^ ERROR `impl Trait` is not allowed in field types
91-
92-
// Disallowed
93-
struct InTupleStructField(impl Debug);
94-
//~^ ERROR `impl Trait` is not allowed in field types
95-
96-
// Disallowed
97-
enum InEnum {
98-
InBraceVariant { x: impl Debug },
99-
//~^ ERROR `impl Trait` is not allowed in field types
100-
InTupleVariant(impl Debug),
101-
//~^ ERROR `impl Trait` is not allowed in field types
102-
}
1+
// FIXME this is only temporary to access the CI state.
1032

104-
// Allowed
105-
trait InTraitDefnParameters {
106-
fn in_parameters(_: impl Debug);
107-
}
108-
109-
// Allowed
110-
trait InTraitDefnReturn {
111-
fn in_return() -> impl Debug;
112-
}
113-
114-
// Allowed and disallowed in trait impls
115-
trait DummyTrait {
116-
type Out;
117-
fn in_trait_impl_parameter(_: impl Debug);
118-
fn in_trait_impl_return() -> Self::Out;
119-
}
120-
impl DummyTrait for () {
121-
type Out = impl Debug;
122-
//~^ ERROR `impl Trait` in associated types is unstable
123-
//~| ERROR unconstrained opaque type
124-
125-
fn in_trait_impl_parameter(_: impl Debug) { }
126-
// Allowed
127-
128-
fn in_trait_impl_return() -> impl Debug { () }
129-
//~^ ERROR `in_trait_impl_return` has an incompatible type for trait
130-
// Allowed
131-
}
3+
use std::fmt::Debug;
1324

1335
// Allowed
134-
struct DummyType;
135-
impl DummyType {
136-
fn in_inherent_impl_parameters(_: impl Debug) { }
137-
fn in_inherent_impl_return() -> impl Debug { () }
138-
}
139-
140-
// Disallowed
141-
extern "C" {
142-
fn in_foreign_parameters(_: impl Debug);
143-
//~^ ERROR `impl Trait` is not allowed in `extern fn`
144-
145-
fn in_foreign_return() -> impl Debug;
146-
//~^ ERROR `impl Trait` is not allowed in `extern fn`
6+
fn in_parameters(_: impl Debug) {
7+
panic!()
1478
}
1489

14910
// Allowed
150-
extern "C" fn in_extern_fn_parameters(_: impl Debug) {
11+
fn in_return() -> impl Debug {
12+
panic!()
15113
}
15214

15315
// Allowed
154-
extern "C" fn in_extern_fn_return() -> impl Debug {
155-
22
156-
}
157-
158-
type InTypeAlias<R> = impl Debug;
159-
//~^ ERROR `impl Trait` in type aliases is unstable
160-
//~| ERROR unconstrained opaque type
161-
162-
type InReturnInTypeAlias<R> = fn() -> impl Debug;
163-
//~^ ERROR `impl Trait` is not allowed in `fn` pointer
164-
//~| ERROR `impl Trait` in type aliases is unstable
165-
166-
// Disallowed in impl headers
167-
impl PartialEq<impl Debug> for () {
168-
//~^ ERROR `impl Trait` is not allowed in traits
169-
}
170-
171-
// Disallowed in impl headers
172-
impl PartialEq<()> for impl Debug {
173-
//~^ ERROR `impl Trait` is not allowed in impl headers
174-
}
175-
176-
// Disallowed in inherent impls
177-
impl impl Debug {
178-
//~^ ERROR `impl Trait` is not allowed in impl headers
179-
}
180-
181-
// Disallowed in inherent impls
182-
struct InInherentImplAdt<T> { t: T }
183-
impl InInherentImplAdt<impl Debug> {
184-
//~^ ERROR `impl Trait` is not allowed in impl headers
185-
}
186-
187-
// Disallowed in where clauses
188-
fn in_fn_where_clause()
189-
where impl Debug: Debug
190-
//~^ ERROR `impl Trait` is not allowed in bounds
191-
{
192-
}
193-
194-
// Disallowed in where clauses
195-
fn in_adt_in_fn_where_clause()
196-
where Vec<impl Debug>: Debug
197-
//~^ ERROR `impl Trait` is not allowed in bounds
198-
{
199-
}
200-
201-
// Disallowed
202-
fn in_trait_parameter_in_fn_where_clause<T>()
203-
where T: PartialEq<impl Debug>
204-
//~^ ERROR `impl Trait` is not allowed in bounds
205-
{
206-
}
207-
208-
// Disallowed
209-
fn in_Fn_parameter_in_fn_where_clause<T>()
210-
where T: Fn(impl Debug)
211-
//~^ ERROR `impl Trait` is not allowed in the parameters of `Fn` trait bounds
212-
{
16+
fn in_adt_in_parameters(_: Vec<impl Debug>) {
17+
panic!()
21318
}
21419

21520
// Disallowed
216-
fn in_Fn_return_in_fn_where_clause<T>()
217-
where T: Fn() -> impl Debug
218-
//~^ ERROR `impl Trait` is not allowed in the return type of `Fn` trait bounds
219-
{
21+
//~v ERROR `impl Trait` is not allowed in `fn` pointer parameters
22+
fn in_fn_parameter_in_parameters(_: fn(impl Debug)) {
23+
panic!()
22024
}
22125

222-
// Disallowed
223-
struct InStructGenericParamDefault<T = impl Debug>(T);
224-
//~^ ERROR `impl Trait` is not allowed in generic parameter defaults
225-
226-
// Disallowed
227-
enum InEnumGenericParamDefault<T = impl Debug> { Variant(T) }
228-
//~^ ERROR `impl Trait` is not allowed in generic parameter defaults
229-
230-
// Disallowed
231-
trait InTraitGenericParamDefault<T = impl Debug> {}
232-
//~^ ERROR `impl Trait` is not allowed in generic parameter defaults
233-
234-
// Disallowed
235-
type InTypeAliasGenericParamDefault<T = impl Debug> = T;
236-
//~^ ERROR `impl Trait` is not allowed in generic parameter defaults
237-
238-
// Disallowed
239-
impl <T = impl Debug> T {}
240-
//~^ ERROR defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
241-
//~| WARNING this was previously accepted by the compiler but is being phased out
242-
//~| ERROR `impl Trait` is not allowed in generic parameter defaults
243-
//~| ERROR no nominal type found
244-
245-
// Disallowed
246-
fn in_method_generic_param_default<T = impl Debug>(_: T) {}
247-
//~^ ERROR defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
248-
//~| WARNING this was previously accepted by the compiler but is being phased out
249-
//~| ERROR `impl Trait` is not allowed in generic parameter defaults
250-
251-
fn main() {
252-
let _in_local_variable: impl Fn() = || {};
253-
//~^ ERROR `impl Trait` is not allowed in the type of variable bindings
254-
let _in_return_in_local_variable = || -> impl Fn() { || {} };
255-
//~^ ERROR `impl Trait` is not allowed in closure return types
256-
}
26+
fn main() {}

0 commit comments

Comments
 (0)