1
1
//! Errors emitted by ast_passes.
2
2
3
+ use rustc_ast:: ParamKindOrd ;
4
+ use rustc_errors:: { fluent, AddToDiagnostic , Applicability , Diagnostic , SubdiagnosticMessage } ;
3
5
use rustc_macros:: { Diagnostic , Subdiagnostic } ;
4
6
use rustc_span:: { Span , Symbol } ;
5
7
@@ -246,7 +248,7 @@ pub struct ImplAssocTyWithBound {
246
248
pub span : Span ,
247
249
}
248
250
249
- #[ derive( SessionDiagnostic ) ]
251
+ #[ derive( Diagnostic ) ]
250
252
#[ diag( ast_passes:: foreign_ty_with_generic_param) ]
251
253
#[ note( ast_passes:: more_extern_note) ]
252
254
pub struct ForeignTyWithGenericParam {
@@ -257,7 +259,7 @@ pub struct ForeignTyWithGenericParam {
257
259
pub extern_span : Span ,
258
260
}
259
261
260
- #[ derive( SessionDiagnostic ) ]
262
+ #[ derive( Diagnostic ) ]
261
263
#[ diag( ast_passes:: foreign_ty_with_where_clause) ]
262
264
#[ note( ast_passes:: more_extern_note) ]
263
265
pub struct ForeignTyWithWhereClause {
@@ -268,7 +270,7 @@ pub struct ForeignTyWithWhereClause {
268
270
pub extern_span : Span ,
269
271
}
270
272
271
- #[ derive( SessionDiagnostic ) ]
273
+ #[ derive( Diagnostic ) ]
272
274
#[ diag( ast_passes:: foreign_ty_with_body) ]
273
275
#[ note( ast_passes:: more_extern_note) ]
274
276
pub struct ForeignTyWithBody {
@@ -281,7 +283,7 @@ pub struct ForeignTyWithBody {
281
283
pub extern_span : Span ,
282
284
}
283
285
284
- #[ derive( SessionDiagnostic ) ]
286
+ #[ derive( Diagnostic ) ]
285
287
#[ diag( ast_passes:: foreign_static_with_body) ]
286
288
#[ note( ast_passes:: more_extern_note) ]
287
289
pub struct ForeignStaticWithBody {
@@ -294,7 +296,7 @@ pub struct ForeignStaticWithBody {
294
296
pub extern_span : Span ,
295
297
}
296
298
297
- #[ derive( SessionDiagnostic ) ]
299
+ #[ derive( Diagnostic ) ]
298
300
#[ diag( ast_passes:: foreign_fn_with_body) ]
299
301
#[ help]
300
302
#[ note( ast_passes:: more_extern_note) ]
@@ -308,7 +310,7 @@ pub struct ForeignFnWithBody {
308
310
pub extern_span : Span ,
309
311
}
310
312
311
- #[ derive( SessionDiagnostic ) ]
313
+ #[ derive( Diagnostic ) ]
312
314
#[ diag( ast_passes:: foreign_fn_with_qualifier) ]
313
315
pub struct ForeignFnWithQualifier {
314
316
#[ primary_span]
@@ -319,7 +321,7 @@ pub struct ForeignFnWithQualifier {
319
321
pub replace_span : Span ,
320
322
}
321
323
322
- #[ derive( SessionDiagnostic ) ]
324
+ #[ derive( Diagnostic ) ]
323
325
#[ diag( ast_passes:: foreign_item_non_ascii) ]
324
326
#[ note]
325
327
pub struct ForeignItemNonAscii {
@@ -329,29 +331,29 @@ pub struct ForeignItemNonAscii {
329
331
pub extern_span : Span ,
330
332
}
331
333
332
- #[ derive( SessionDiagnostic ) ]
334
+ #[ derive( Diagnostic ) ]
333
335
#[ diag( ast_passes:: forbidden_c_var_args) ]
334
336
pub struct ForbiddenCVarArgs {
335
337
#[ primary_span]
336
338
pub span : Span ,
337
339
}
338
340
339
- #[ derive( SessionDiagnostic ) ]
341
+ #[ derive( Diagnostic ) ]
340
342
#[ diag( ast_passes:: unnamed_assoc_const) ]
341
343
pub struct UnnamedAssocConst {
342
344
#[ primary_span]
343
345
#[ label]
344
346
pub span : Span ,
345
347
}
346
348
347
- #[ derive( SessionDiagnostic ) ]
349
+ #[ derive( Diagnostic ) ]
348
350
#[ diag( ast_passes:: nomangle_item_non_ascii, code = "E0754" ) ]
349
351
pub struct NomangleItemNonAscii {
350
352
#[ primary_span]
351
353
pub span : Span ,
352
354
}
353
355
354
- #[ derive( SessionDiagnostic ) ]
356
+ #[ derive( Diagnostic ) ]
355
357
#[ diag( ast_passes:: mod_file_item_non_ascii, code = "E0754" ) ]
356
358
#[ help]
357
359
pub struct ModFileItemNonAscii {
@@ -360,7 +362,7 @@ pub struct ModFileItemNonAscii {
360
362
pub name : Symbol ,
361
363
}
362
364
363
- #[ derive( SessionDiagnostic ) ]
365
+ #[ derive( Diagnostic ) ]
364
366
#[ diag( ast_passes:: auto_trait_with_generic_param, code = "E0567" ) ]
365
367
pub struct AutoTraitWithGenericParam {
366
368
#[ primary_span]
@@ -370,7 +372,7 @@ pub struct AutoTraitWithGenericParam {
370
372
pub ident_span : Span ,
371
373
}
372
374
373
- #[ derive( SessionDiagnostic ) ]
375
+ #[ derive( Diagnostic ) ]
374
376
#[ diag( ast_passes:: auto_trait_with_super_trait_or_where_clause, code = "E0568" ) ]
375
377
pub struct AutoTraitWithSuperTraitOrWhereClause {
376
378
#[ primary_span]
@@ -380,7 +382,7 @@ pub struct AutoTraitWithSuperTraitOrWhereClause {
380
382
pub ident_span : Span ,
381
383
}
382
384
383
- #[ derive( SessionDiagnostic ) ]
385
+ #[ derive( Diagnostic ) ]
384
386
#[ diag( ast_passes:: auto_trait_with_assoc_item, code = "E0380" ) ]
385
387
pub struct AutoTraitWithAssocItem {
386
388
#[ primary_span]
@@ -391,7 +393,7 @@ pub struct AutoTraitWithAssocItem {
391
393
pub ident_span : Span ,
392
394
}
393
395
394
- #[ derive( SessionDiagnostic ) ]
396
+ #[ derive( Diagnostic ) ]
395
397
#[ diag( ast_passes:: generic_arg_after_constraint) ]
396
398
pub struct GenericArgAfterConstraint {
397
399
#[ primary_span]
@@ -409,28 +411,28 @@ pub struct GenericArgAfterConstraint {
409
411
pub correct_order : String ,
410
412
}
411
413
412
- #[ derive( SessionDiagnostic ) ]
414
+ #[ derive( Diagnostic ) ]
413
415
#[ diag( ast_passes:: fn_ptr_ty_with_pat, code = "E0561" ) ]
414
416
pub struct FnPtrTyWithPat {
415
417
#[ primary_span]
416
418
pub span : Span ,
417
419
}
418
420
419
- #[ derive( SessionDiagnostic ) ]
421
+ #[ derive( Diagnostic ) ]
420
422
#[ diag( ast_passes:: multiple_explicit_lifetime_bound, code = "E0226" ) ]
421
423
pub struct MultipleExplicitLifetimeBound {
422
424
#[ primary_span]
423
425
pub span : Span ,
424
426
}
425
427
426
- #[ derive( SessionDiagnostic ) ]
428
+ #[ derive( Diagnostic ) ]
427
429
#[ diag( ast_passes:: impl_trait_ty_in_path_param, code = "E0667" ) ]
428
430
pub struct ImplTraitTyInPathParam {
429
431
#[ primary_span]
430
432
pub span : Span ,
431
433
}
432
434
433
- #[ derive( SessionDiagnostic ) ]
435
+ #[ derive( Diagnostic ) ]
434
436
#[ diag( ast_passes:: impl_trait_ty_nested, code = "E0666" ) ]
435
437
pub struct ImplTraitTyNested {
436
438
#[ primary_span]
@@ -440,9 +442,21 @@ pub struct ImplTraitTyNested {
440
442
pub outer_span : Span ,
441
443
}
442
444
443
- #[ derive( SessionDiagnostic ) ]
445
+ #[ derive( Diagnostic ) ]
444
446
#[ diag( ast_passes:: impl_trait_ty_without_trait_bound) ]
445
447
pub struct ImplTraitTyWithoutTraitBound {
446
448
#[ primary_span]
447
449
pub span : Span ,
448
450
}
451
+
452
+ #[ derive( Diagnostic ) ]
453
+ #[ diag( ast_passes:: generic_param_wrong_order) ]
454
+ pub struct GenericParamWrongOrder {
455
+ #[ primary_span]
456
+ pub spans : Vec < Span > ,
457
+ pub param_kind : ParamKindOrd ,
458
+ pub max_param_kind : ParamKindOrd ,
459
+ #[ suggestion( code = "{correct_order}" , applicability = "machine-applicable" ) ]
460
+ pub replace_span : Span ,
461
+ pub correct_order : String ,
462
+ }
0 commit comments