Skip to content

Commit 03cf0d7

Browse files
committed
TAIT: adjust tests
1 parent 8b663ec commit 03cf0d7

File tree

5 files changed

+202
-29
lines changed

5 files changed

+202
-29
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,45 @@
1-
type Foo = impl std::fmt::Debug; //~ ERROR `impl Trait` in type aliases is unstable
1+
use std::fmt::Debug;
2+
3+
type Foo = impl Debug; //~ ERROR `impl Trait` in type aliases is unstable
24

35
trait Bar {
4-
type Baa: std::fmt::Debug;
6+
type Baa: Debug;
57
fn define() -> Self::Baa;
68
}
79

810
impl Bar for () {
9-
type Baa = impl std::fmt::Debug; //~ ERROR `impl Trait` in type aliases is unstable
11+
type Baa = impl Debug; //~ ERROR `impl Trait` in type aliases is unstable
1012
fn define() -> Self::Baa { 0 }
1113
}
1214

1315
fn define() -> Foo { 0 }
1416

17+
trait TraitWithDefault {
18+
type Assoc = impl Debug;
19+
//~^ ERROR associated type defaults are unstable
20+
//~| ERROR `impl Trait` not allowed outside of function
21+
//~| ERROR `impl Trait` in type aliases is unstable
22+
}
23+
24+
type NestedFree = (Vec<impl Debug>, impl Debug, impl Iterator<Item = impl Debug>);
25+
//~^ ERROR `impl Trait` in type aliases is unstable
26+
//~| ERROR `impl Trait` in type aliases is unstable
27+
//~| ERROR `impl Trait` in type aliases is unstable
28+
//~| ERROR `impl Trait` in type aliases is unstable
29+
//~| ERROR `impl Trait` not allowed outside of function
30+
//~| ERROR `impl Trait` not allowed outside of function
31+
//~| ERROR `impl Trait` not allowed outside of function
32+
33+
impl Bar for u8 {
34+
type Baa = (Vec<impl Debug>, impl Debug, impl Iterator<Item = impl Debug>);
35+
//~^ ERROR `impl Trait` in type aliases is unstable
36+
//~| ERROR `impl Trait` in type aliases is unstable
37+
//~| ERROR `impl Trait` in type aliases is unstable
38+
//~| ERROR `impl Trait` in type aliases is unstable
39+
//~| ERROR `impl Trait` not allowed outside of function
40+
//~| ERROR `impl Trait` not allowed outside of function
41+
//~| ERROR `impl Trait` not allowed outside of function
42+
fn define() -> Self::Baa { (vec![true], 0u8, 0i32..1) }
43+
}
44+
1545
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,154 @@
11
error[E0658]: `impl Trait` in type aliases is unstable
2-
--> $DIR/feature-gate-type_alias_impl_trait.rs:1:1
2+
--> $DIR/feature-gate-type_alias_impl_trait.rs:3:12
33
|
4-
LL | type Foo = impl std::fmt::Debug;
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
LL | type Foo = impl Debug;
5+
| ^^^^^^^^^^
66
|
77
= note: for more information, see https://github.com/rust-lang/rust/issues/63063
88
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
99

1010
error[E0658]: `impl Trait` in type aliases is unstable
11-
--> $DIR/feature-gate-type_alias_impl_trait.rs:9:5
11+
--> $DIR/feature-gate-type_alias_impl_trait.rs:11:16
1212
|
13-
LL | type Baa = impl std::fmt::Debug;
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13+
LL | type Baa = impl Debug;
14+
| ^^^^^^^^^^
1515
|
1616
= note: for more information, see https://github.com/rust-lang/rust/issues/63063
1717
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
1818

19-
error: aborting due to 2 previous errors
19+
error[E0658]: `impl Trait` in type aliases is unstable
20+
--> $DIR/feature-gate-type_alias_impl_trait.rs:18:18
21+
|
22+
LL | type Assoc = impl Debug;
23+
| ^^^^^^^^^^
24+
|
25+
= note: for more information, see https://github.com/rust-lang/rust/issues/63063
26+
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
27+
28+
error[E0658]: associated type defaults are unstable
29+
--> $DIR/feature-gate-type_alias_impl_trait.rs:18:5
30+
|
31+
LL | type Assoc = impl Debug;
32+
| ^^^^^^^^^^^^^^^^^^^^^^^^
33+
|
34+
= note: for more information, see https://github.com/rust-lang/rust/issues/29661
35+
= help: add `#![feature(associated_type_defaults)]` to the crate attributes to enable
36+
37+
error[E0658]: `impl Trait` in type aliases is unstable
38+
--> $DIR/feature-gate-type_alias_impl_trait.rs:24:24
39+
|
40+
LL | type NestedFree = (Vec<impl Debug>, impl Debug, impl Iterator<Item = impl Debug>);
41+
| ^^^^^^^^^^
42+
|
43+
= note: for more information, see https://github.com/rust-lang/rust/issues/63063
44+
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
45+
46+
error[E0658]: `impl Trait` in type aliases is unstable
47+
--> $DIR/feature-gate-type_alias_impl_trait.rs:24:37
48+
|
49+
LL | type NestedFree = (Vec<impl Debug>, impl Debug, impl Iterator<Item = impl Debug>);
50+
| ^^^^^^^^^^
51+
|
52+
= note: for more information, see https://github.com/rust-lang/rust/issues/63063
53+
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
54+
55+
error[E0658]: `impl Trait` in type aliases is unstable
56+
--> $DIR/feature-gate-type_alias_impl_trait.rs:24:49
57+
|
58+
LL | type NestedFree = (Vec<impl Debug>, impl Debug, impl Iterator<Item = impl Debug>);
59+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
60+
|
61+
= note: for more information, see https://github.com/rust-lang/rust/issues/63063
62+
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
63+
64+
error[E0658]: `impl Trait` in type aliases is unstable
65+
--> $DIR/feature-gate-type_alias_impl_trait.rs:24:70
66+
|
67+
LL | type NestedFree = (Vec<impl Debug>, impl Debug, impl Iterator<Item = impl Debug>);
68+
| ^^^^^^^^^^
69+
|
70+
= note: for more information, see https://github.com/rust-lang/rust/issues/63063
71+
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
72+
73+
error[E0658]: `impl Trait` in type aliases is unstable
74+
--> $DIR/feature-gate-type_alias_impl_trait.rs:34:21
75+
|
76+
LL | type Baa = (Vec<impl Debug>, impl Debug, impl Iterator<Item = impl Debug>);
77+
| ^^^^^^^^^^
78+
|
79+
= note: for more information, see https://github.com/rust-lang/rust/issues/63063
80+
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
81+
82+
error[E0658]: `impl Trait` in type aliases is unstable
83+
--> $DIR/feature-gate-type_alias_impl_trait.rs:34:34
84+
|
85+
LL | type Baa = (Vec<impl Debug>, impl Debug, impl Iterator<Item = impl Debug>);
86+
| ^^^^^^^^^^
87+
|
88+
= note: for more information, see https://github.com/rust-lang/rust/issues/63063
89+
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
90+
91+
error[E0658]: `impl Trait` in type aliases is unstable
92+
--> $DIR/feature-gate-type_alias_impl_trait.rs:34:46
93+
|
94+
LL | type Baa = (Vec<impl Debug>, impl Debug, impl Iterator<Item = impl Debug>);
95+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
96+
|
97+
= note: for more information, see https://github.com/rust-lang/rust/issues/63063
98+
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
99+
100+
error[E0658]: `impl Trait` in type aliases is unstable
101+
--> $DIR/feature-gate-type_alias_impl_trait.rs:34:67
102+
|
103+
LL | type Baa = (Vec<impl Debug>, impl Debug, impl Iterator<Item = impl Debug>);
104+
| ^^^^^^^^^^
105+
|
106+
= note: for more information, see https://github.com/rust-lang/rust/issues/63063
107+
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
108+
109+
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
110+
--> $DIR/feature-gate-type_alias_impl_trait.rs:18:18
111+
|
112+
LL | type Assoc = impl Debug;
113+
| ^^^^^^^^^^
114+
115+
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
116+
--> $DIR/feature-gate-type_alias_impl_trait.rs:24:24
117+
|
118+
LL | type NestedFree = (Vec<impl Debug>, impl Debug, impl Iterator<Item = impl Debug>);
119+
| ^^^^^^^^^^
120+
121+
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
122+
--> $DIR/feature-gate-type_alias_impl_trait.rs:24:37
123+
|
124+
LL | type NestedFree = (Vec<impl Debug>, impl Debug, impl Iterator<Item = impl Debug>);
125+
| ^^^^^^^^^^
126+
127+
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
128+
--> $DIR/feature-gate-type_alias_impl_trait.rs:24:49
129+
|
130+
LL | type NestedFree = (Vec<impl Debug>, impl Debug, impl Iterator<Item = impl Debug>);
131+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
132+
133+
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
134+
--> $DIR/feature-gate-type_alias_impl_trait.rs:34:21
135+
|
136+
LL | type Baa = (Vec<impl Debug>, impl Debug, impl Iterator<Item = impl Debug>);
137+
| ^^^^^^^^^^
138+
139+
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
140+
--> $DIR/feature-gate-type_alias_impl_trait.rs:34:34
141+
|
142+
LL | type Baa = (Vec<impl Debug>, impl Debug, impl Iterator<Item = impl Debug>);
143+
| ^^^^^^^^^^
144+
145+
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
146+
--> $DIR/feature-gate-type_alias_impl_trait.rs:34:46
147+
|
148+
LL | type Baa = (Vec<impl Debug>, impl Debug, impl Iterator<Item = impl Debug>);
149+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
150+
151+
error: aborting due to 19 previous errors
20152

21-
For more information about this error, try `rustc --explain E0658`.
153+
Some errors have detailed explanations: E0562, E0658.
154+
For more information about an error, try `rustc --explain E0562`.

src/test/ui/impl-trait/where-allowed.rs

+1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ type InTypeAlias<R> = impl Debug;
163163

164164
type InReturnInTypeAlias<R> = fn() -> impl Debug;
165165
//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
166+
//~| ERROR `impl Trait` in type aliases is unstable
166167

167168
// Disallowed in impl headers
168169
impl PartialEq<impl Debug> for () {

src/test/ui/impl-trait/where-allowed.stderr

+25-16
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,28 @@ LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic
1717
| outer `impl Trait`
1818

1919
error[E0658]: `impl Trait` in type aliases is unstable
20-
--> $DIR/where-allowed.rs:124:5
20+
--> $DIR/where-allowed.rs:124:16
2121
|
2222
LL | type Out = impl Debug;
23-
| ^^^^^^^^^^^^^^^^^^^^^^
23+
| ^^^^^^^^^^
2424
|
2525
= note: for more information, see https://github.com/rust-lang/rust/issues/63063
2626
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
2727

2828
error[E0658]: `impl Trait` in type aliases is unstable
29-
--> $DIR/where-allowed.rs:160:1
29+
--> $DIR/where-allowed.rs:160:23
3030
|
3131
LL | type InTypeAlias<R> = impl Debug;
32-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32+
| ^^^^^^^^^^
33+
|
34+
= note: for more information, see https://github.com/rust-lang/rust/issues/63063
35+
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
36+
37+
error[E0658]: `impl Trait` in type aliases is unstable
38+
--> $DIR/where-allowed.rs:164:39
39+
|
40+
LL | type InReturnInTypeAlias<R> = fn() -> impl Debug;
41+
| ^^^^^^^^^^
3342
|
3443
= note: for more information, see https://github.com/rust-lang/rust/issues/63063
3544
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
@@ -179,69 +188,69 @@ LL | type InReturnInTypeAlias<R> = fn() -> impl Debug;
179188
| ^^^^^^^^^^
180189

181190
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
182-
--> $DIR/where-allowed.rs:168:16
191+
--> $DIR/where-allowed.rs:169:16
183192
|
184193
LL | impl PartialEq<impl Debug> for () {
185194
| ^^^^^^^^^^
186195

187196
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
188-
--> $DIR/where-allowed.rs:173:24
197+
--> $DIR/where-allowed.rs:174:24
189198
|
190199
LL | impl PartialEq<()> for impl Debug {
191200
| ^^^^^^^^^^
192201

193202
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
194-
--> $DIR/where-allowed.rs:178:6
203+
--> $DIR/where-allowed.rs:179:6
195204
|
196205
LL | impl impl Debug {
197206
| ^^^^^^^^^^
198207

199208
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
200-
--> $DIR/where-allowed.rs:184:24
209+
--> $DIR/where-allowed.rs:185:24
201210
|
202211
LL | impl InInherentImplAdt<impl Debug> {
203212
| ^^^^^^^^^^
204213

205214
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
206-
--> $DIR/where-allowed.rs:190:11
215+
--> $DIR/where-allowed.rs:191:11
207216
|
208217
LL | where impl Debug: Debug
209218
| ^^^^^^^^^^
210219

211220
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
212-
--> $DIR/where-allowed.rs:197:15
221+
--> $DIR/where-allowed.rs:198:15
213222
|
214223
LL | where Vec<impl Debug>: Debug
215224
| ^^^^^^^^^^
216225

217226
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
218-
--> $DIR/where-allowed.rs:204:24
227+
--> $DIR/where-allowed.rs:205:24
219228
|
220229
LL | where T: PartialEq<impl Debug>
221230
| ^^^^^^^^^^
222231

223232
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
224-
--> $DIR/where-allowed.rs:211:17
233+
--> $DIR/where-allowed.rs:212:17
225234
|
226235
LL | where T: Fn(impl Debug)
227236
| ^^^^^^^^^^
228237

229238
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
230-
--> $DIR/where-allowed.rs:218:22
239+
--> $DIR/where-allowed.rs:219:22
231240
|
232241
LL | where T: Fn() -> impl Debug
233242
| ^^^^^^^^^^
234243

235244
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
236-
--> $DIR/where-allowed.rs:224:29
245+
--> $DIR/where-allowed.rs:225:29
237246
|
238247
LL | let _in_local_variable: impl Fn() = || {};
239248
| ^^^^^^^^^
240249
|
241250
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
242251

243252
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
244-
--> $DIR/where-allowed.rs:226:46
253+
--> $DIR/where-allowed.rs:227:46
245254
|
246255
LL | let _in_return_in_local_variable = || -> impl Fn() { || {} };
247256
| ^^^^^^^^^
@@ -270,7 +279,7 @@ error: could not find defining uses
270279
LL | type Out = impl Debug;
271280
| ^^^^^^^^^^^^^^^^^^^^^^
272281

273-
error: aborting due to 43 previous errors
282+
error: aborting due to 44 previous errors
274283

275284
Some errors have detailed explanations: E0282, E0562, E0658, E0666.
276285
For more information about an error, try `rustc --explain E0282`.

src/test/ui/type-alias-impl-trait/issue-60371.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0658]: `impl Trait` in type aliases is unstable
2-
--> $DIR/issue-60371.rs:8:5
2+
--> $DIR/issue-60371.rs:8:17
33
|
44
LL | type Item = impl Bug;
5-
| ^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^
66
|
77
= note: for more information, see https://github.com/rust-lang/rust/issues/63063
88
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable

0 commit comments

Comments
 (0)