1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
|
mod no_generics {
struct Ty;
type A = Ty;
type B = Ty<'static>;
//~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument
//~| HELP remove these generics
type C = Ty<'static, usize>;
//~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument
//~| ERROR struct takes 0 generic arguments but 1 generic argument
//~| HELP remove this lifetime argument
//~| HELP remove this generic argument
type D = Ty<'static, usize, { 0 }>;
//~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument
//~| ERROR struct takes 0 generic arguments but 2 generic arguments
//~| HELP remove this lifetime argument
//~| HELP remove these generic arguments
}
mod type_and_type {
struct Ty<A, B>;
type A = Ty;
//~^ ERROR missing generics for struct `type_and_type::Ty`
//~| HELP add missing
type B = Ty<usize>;
//~^ ERROR struct takes 2 generic arguments but 1 generic argument
//~| HELP add missing
type C = Ty<usize, String>;
type D = Ty<usize, String, char>;
//~^ ERROR struct takes 2 generic arguments but 3 generic arguments
//~| HELP remove this
type E = Ty<>;
//~^ ERROR struct takes 2 generic arguments but 0 generic arguments were supplied
//~| HELP add missing
}
mod lifetime_and_type {
struct Ty<'a, T>;
type A = Ty;
//~^ ERROR missing generics for struct
//~| ERROR missing lifetime specifier
//~| HELP add missing
//~| HELP consider introducing
type B = Ty<'static>;
//~^ ERROR struct takes 1 generic argument but 0 generic arguments
//~| HELP add missing
type C = Ty<usize>;
//~^ ERROR missing lifetime specifier
//~| HELP consider introducing
type D = Ty<'static, usize>;
type E = Ty<>;
//~^ ERROR struct takes 1 generic argument but 0 generic arguments
//~| ERROR missing lifetime specifier
//~| HELP consider introducing
//~| HELP add missing
type F = Ty<'static, usize, 'static, usize>;
//~^ ERROR struct takes 1 lifetime argument but 2 lifetime arguments
//~| ERROR struct takes 1 generic argument but 2 generic arguments
//~| HELP remove this lifetime argument
//~| HELP remove this generic argument
}
mod type_and_type_and_type {
struct Ty<A, B, C = &'static str>;
type A = Ty;
//~^ ERROR missing generics for struct `type_and_type_and_type::Ty`
//~| HELP add missing
type B = Ty<usize>;
//~^ ERROR struct takes at least 2
//~| HELP add missing
type C = Ty<usize, String>;
type D = Ty<usize, String, char>;
type E = Ty<usize, String, char, f64>;
//~^ ERROR struct takes at most 3
//~| HELP remove
type F = Ty<>;
//~^ ERROR struct takes at least 2 generic arguments but 0 generic arguments
//~| HELP add missing
}
// Traits have an implicit `Self` type - these tests ensure we don't accidentally return it
// somewhere in the message
mod r#trait {
trait NonGeneric {
//
}
trait GenericLifetime<'a> {
//
}
trait GenericType<A> {
//
}
type A = Box<dyn NonGeneric<usize>>;
//~^ ERROR trait takes 0 generic arguments but 1 generic argument
//~| HELP remove
type B = Box<dyn GenericLifetime>;
//~^ ERROR missing lifetime specifier
//~| HELP consider introducing
//~| HELP consider making the bound lifetime-generic
type C = Box<dyn GenericLifetime<'static, 'static>>;
//~^ ERROR trait takes 1 lifetime argument but 2 lifetime arguments were supplied
//~| HELP remove
type D = Box<dyn GenericType>;
//~^ ERROR missing generics for trait `GenericType`
//~| HELP add missing
type E = Box<dyn GenericType<String, usize>>;
//~^ ERROR trait takes 1 generic argument but 2 generic arguments
//~| HELP remove
type F = Box<dyn GenericLifetime<>>;
//~^ ERROR missing lifetime specifier
//~| HELP consider introducing
//~| HELP consider making the bound lifetime-generic
type G = Box<dyn GenericType<>>;
//~^ ERROR trait takes 1 generic argument but 0 generic arguments
//~| HELP add missing
}
mod associated_item {
mod non_generic {
trait NonGenericAT {
type AssocTy;
}
type A = Box<dyn NonGenericAT<usize, AssocTy=()>>;
//~^ ERROR trait takes 0 generic arguments but 1 generic argument
//~| HELP remove
}
mod lifetime {
trait GenericLifetimeAT<'a> {
type AssocTy;
}
type A = Box<dyn GenericLifetimeAT<AssocTy=()>>;
//~^ ERROR missing lifetime specifier
//~| HELP consider introducing
//~| HELP consider making the bound lifetime-generic
type B = Box<dyn GenericLifetimeAT<'static, 'static, AssocTy=()>>;
//~^ ERROR trait takes 1 lifetime argument but 2 lifetime arguments were supplied
//~| HELP remove
type C = Box<dyn GenericLifetimeAT<(), AssocTy=()>>;
//~^ ERROR missing lifetime specifier
//~| HELP consider introducing
//~| HELP consider making the bound lifetime-generic
//~| ERROR trait takes 0 generic arguments but 1 generic argument
//~| HELP remove
}
mod r#type {
trait GenericTypeAT<A> {
type AssocTy;
}
type A = Box<dyn GenericTypeAT<AssocTy=()>>;
//~^ ERROR trait takes 1 generic argument but 0 generic arguments
//~| HELP add missing
type B = Box<dyn GenericTypeAT<(), (), AssocTy=()>>;
//~^ ERROR trait takes 1 generic argument but 2 generic arguments
//~| HELP remove
type C = Box<dyn GenericTypeAT<'static, AssocTy=()>>;
//~^ ERROR trait takes 1 generic argument but 0 generic arguments
//~| HELP add missing
//~| ERROR trait takes 0 lifetime arguments but 1 lifetime argument was supplied
//~| HELP remove
}
mod lifetime_and_type {
trait GenericLifetimeTypeAT<'a, A> {
type AssocTy;
}
type A = Box<dyn GenericLifetimeTypeAT<AssocTy=()>>;
//~^ ERROR trait takes 1 generic argument but 0 generic arguments
//~| HELP add missing
//~| ERROR missing lifetime specifier
//~| HELP consider introducing
//~| HELP consider making the bound lifetime-generic
type B = Box<dyn GenericLifetimeTypeAT<'static, AssocTy=()>>;
//~^ ERROR trait takes 1 generic argument but 0 generic arguments were supplied
//~| HELP add missing
type C = Box<dyn GenericLifetimeTypeAT<'static, 'static, AssocTy=()>>;
//~^ ERROR trait takes 1 lifetime argument but 2 lifetime arguments were supplied
//~| HELP remove
//~| ERROR trait takes 1 generic argument but 0 generic arguments
//~| HELP add missing
type D = Box<dyn GenericLifetimeTypeAT<(), AssocTy=()>>;
//~^ ERROR missing lifetime specifier
//~| HELP consider introducing
//~| HELP consider making the bound lifetime-generic
type E = Box<dyn GenericLifetimeTypeAT<(), (), AssocTy=()>>;
//~^ ERROR missing lifetime specifier
//~| HELP consider introducing
//~| HELP consider making the bound lifetime-generic
//~| ERROR trait takes 1 generic argument but 2 generic arguments
//~| HELP remove
type F = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), AssocTy=()>>;
//~^ ERROR trait takes 1 lifetime argument but 2 lifetime arguments were supplied
//~| HELP remove
type G = Box<dyn GenericLifetimeTypeAT<'static, (), (), AssocTy=()>>;
//~^ ERROR trait takes 1 generic argument but 2 generic arguments
//~| HELP remove
type H = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), (), AssocTy=()>>;
//~^ ERROR trait takes 1 lifetime argument but 2 lifetime arguments were supplied
//~| HELP remove
//~| ERROR trait takes 1 generic argument but 2 generic arguments
//~| HELP remove
}
mod type_and_type {
trait GenericTypeTypeAT<A, B> {
type AssocTy;
}
type A = Box<dyn GenericTypeTypeAT<AssocTy=()>>;
//~^ ERROR trait takes 2 generic arguments but 0 generic arguments
//~| HELP add missing
type B = Box<dyn GenericTypeTypeAT<(), AssocTy=()>>;
//~^ ERROR trait takes 2 generic arguments but 1 generic argument
//~| HELP add missing
type C = Box<dyn GenericTypeTypeAT<(), (), (), AssocTy=()>>;
//~^ ERROR trait takes 2 generic arguments but 3 generic arguments
//~| HELP remove
}
mod lifetime_and_lifetime {
trait GenericLifetimeLifetimeAT<'a, 'b> {
type AssocTy;
}
type A = Box<dyn GenericLifetimeLifetimeAT<AssocTy=()>>;
//~^ ERROR missing lifetime specifier
//~| HELP consider introducing
//~| HELP consider making the bound lifetime-generic
type B = Box<dyn GenericLifetimeLifetimeAT<'static, AssocTy=()>>;
//~^ ERROR trait takes 2 lifetime arguments but 1 lifetime argument was supplied
//~| HELP add missing lifetime argument
}
mod lifetime_and_lifetime_and_type {
trait GenericLifetimeLifetimeTypeAT<'a, 'b, A> {
type AssocTy;
}
type A = Box<dyn GenericLifetimeLifetimeTypeAT<AssocTy=()>>;
//~^ ERROR missing lifetime specifier
//~| HELP consider introducing
//~| HELP consider making the bound lifetime-generic
//~| ERROR trait takes 1 generic argument but 0 generic arguments
//~| HELP add missing
type B = Box<dyn GenericLifetimeLifetimeTypeAT<'static, AssocTy=()>>;
//~^ ERROR trait takes 2 lifetime arguments but 1 lifetime argument was supplied
//~| HELP add missing lifetime argument
//~| ERROR trait takes 1 generic argument but 0 generic arguments
//~| HELP add missing
type C = Box<dyn GenericLifetimeLifetimeTypeAT<'static, (), AssocTy=()>>;
//~^ ERROR trait takes 2 lifetime arguments but 1 lifetime argument was supplied
//~| HELP add missing lifetime argument
}
}
mod stdlib {
mod hash_map {
use std::collections::HashMap;
type A = HashMap;
//~^ ERROR missing generics for struct `HashMap`
//~| HELP add missing
type B = HashMap<String>;
//~^ ERROR struct takes at least
//~| HELP add missing
type C = HashMap<'static>;
//~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument
//~| HELP remove these generics
//~| ERROR struct takes at least 2
//~| HELP add missing
type D = HashMap<usize, String, char, f64>;
//~^ ERROR struct takes at most 3
//~| HELP remove this
type E = HashMap<>;
//~^ ERROR struct takes at least 2 generic arguments but 0 generic arguments
//~| HELP add missing
}
mod result {
type A = Result;
//~^ ERROR missing generics for enum `Result`
//~| HELP add missing
type B = Result<String>;
//~^ ERROR enum takes 2 generic arguments but 1 generic argument
//~| HELP add missing
type C = Result<'static>;
//~^ ERROR enum takes 0 lifetime arguments but 1 lifetime argument
//~| HELP remove these generics
//~| ERROR enum takes 2 generic arguments but 0 generic arguments
//~| HELP add missing
type D = Result<usize, String, char>;
//~^ ERROR enum takes 2 generic arguments but 3 generic arguments
//~| HELP remove
type E = Result<>;
//~^ ERROR enum takes 2 generic arguments but 0 generic arguments
//~| HELP add missing
}
}
fn main() { }
|