11//! Errors emitted by ast_passes.
22
3+ use rustc_ast:: ParamKindOrd ;
4+ use rustc_errors:: { fluent, AddToDiagnostic , Applicability , Diagnostic , SubdiagnosticMessage } ;
35use rustc_macros:: { Diagnostic , Subdiagnostic } ;
46use rustc_span:: { Span , Symbol } ;
57
@@ -246,7 +248,7 @@ pub struct ImplAssocTyWithBound {
246248 pub span : Span ,
247249}
248250
249- #[ derive( SessionDiagnostic ) ]
251+ #[ derive( Diagnostic ) ]
250252#[ diag( ast_passes:: foreign_ty_with_generic_param) ]
251253#[ note( ast_passes:: more_extern_note) ]
252254pub struct ForeignTyWithGenericParam {
@@ -257,7 +259,7 @@ pub struct ForeignTyWithGenericParam {
257259 pub extern_span : Span ,
258260}
259261
260- #[ derive( SessionDiagnostic ) ]
262+ #[ derive( Diagnostic ) ]
261263#[ diag( ast_passes:: foreign_ty_with_where_clause) ]
262264#[ note( ast_passes:: more_extern_note) ]
263265pub struct ForeignTyWithWhereClause {
@@ -268,7 +270,7 @@ pub struct ForeignTyWithWhereClause {
268270 pub extern_span : Span ,
269271}
270272
271- #[ derive( SessionDiagnostic ) ]
273+ #[ derive( Diagnostic ) ]
272274#[ diag( ast_passes:: foreign_ty_with_body) ]
273275#[ note( ast_passes:: more_extern_note) ]
274276pub struct ForeignTyWithBody {
@@ -281,7 +283,7 @@ pub struct ForeignTyWithBody {
281283 pub extern_span : Span ,
282284}
283285
284- #[ derive( SessionDiagnostic ) ]
286+ #[ derive( Diagnostic ) ]
285287#[ diag( ast_passes:: foreign_static_with_body) ]
286288#[ note( ast_passes:: more_extern_note) ]
287289pub struct ForeignStaticWithBody {
@@ -294,7 +296,7 @@ pub struct ForeignStaticWithBody {
294296 pub extern_span : Span ,
295297}
296298
297- #[ derive( SessionDiagnostic ) ]
299+ #[ derive( Diagnostic ) ]
298300#[ diag( ast_passes:: foreign_fn_with_body) ]
299301#[ help]
300302#[ note( ast_passes:: more_extern_note) ]
@@ -308,7 +310,7 @@ pub struct ForeignFnWithBody {
308310 pub extern_span : Span ,
309311}
310312
311- #[ derive( SessionDiagnostic ) ]
313+ #[ derive( Diagnostic ) ]
312314#[ diag( ast_passes:: foreign_fn_with_qualifier) ]
313315pub struct ForeignFnWithQualifier {
314316 #[ primary_span]
@@ -319,7 +321,7 @@ pub struct ForeignFnWithQualifier {
319321 pub replace_span : Span ,
320322}
321323
322- #[ derive( SessionDiagnostic ) ]
324+ #[ derive( Diagnostic ) ]
323325#[ diag( ast_passes:: foreign_item_non_ascii) ]
324326#[ note]
325327pub struct ForeignItemNonAscii {
@@ -329,29 +331,29 @@ pub struct ForeignItemNonAscii {
329331 pub extern_span : Span ,
330332}
331333
332- #[ derive( SessionDiagnostic ) ]
334+ #[ derive( Diagnostic ) ]
333335#[ diag( ast_passes:: forbidden_c_var_args) ]
334336pub struct ForbiddenCVarArgs {
335337 #[ primary_span]
336338 pub span : Span ,
337339}
338340
339- #[ derive( SessionDiagnostic ) ]
341+ #[ derive( Diagnostic ) ]
340342#[ diag( ast_passes:: unnamed_assoc_const) ]
341343pub struct UnnamedAssocConst {
342344 #[ primary_span]
343345 #[ label]
344346 pub span : Span ,
345347}
346348
347- #[ derive( SessionDiagnostic ) ]
349+ #[ derive( Diagnostic ) ]
348350#[ diag( ast_passes:: nomangle_item_non_ascii, code = "E0754" ) ]
349351pub struct NomangleItemNonAscii {
350352 #[ primary_span]
351353 pub span : Span ,
352354}
353355
354- #[ derive( SessionDiagnostic ) ]
356+ #[ derive( Diagnostic ) ]
355357#[ diag( ast_passes:: mod_file_item_non_ascii, code = "E0754" ) ]
356358#[ help]
357359pub struct ModFileItemNonAscii {
@@ -360,7 +362,7 @@ pub struct ModFileItemNonAscii {
360362 pub name : Symbol ,
361363}
362364
363- #[ derive( SessionDiagnostic ) ]
365+ #[ derive( Diagnostic ) ]
364366#[ diag( ast_passes:: auto_trait_with_generic_param, code = "E0567" ) ]
365367pub struct AutoTraitWithGenericParam {
366368 #[ primary_span]
@@ -370,7 +372,7 @@ pub struct AutoTraitWithGenericParam {
370372 pub ident_span : Span ,
371373}
372374
373- #[ derive( SessionDiagnostic ) ]
375+ #[ derive( Diagnostic ) ]
374376#[ diag( ast_passes:: auto_trait_with_super_trait_or_where_clause, code = "E0568" ) ]
375377pub struct AutoTraitWithSuperTraitOrWhereClause {
376378 #[ primary_span]
@@ -380,7 +382,7 @@ pub struct AutoTraitWithSuperTraitOrWhereClause {
380382 pub ident_span : Span ,
381383}
382384
383- #[ derive( SessionDiagnostic ) ]
385+ #[ derive( Diagnostic ) ]
384386#[ diag( ast_passes:: auto_trait_with_assoc_item, code = "E0380" ) ]
385387pub struct AutoTraitWithAssocItem {
386388 #[ primary_span]
@@ -391,7 +393,7 @@ pub struct AutoTraitWithAssocItem {
391393 pub ident_span : Span ,
392394}
393395
394- #[ derive( SessionDiagnostic ) ]
396+ #[ derive( Diagnostic ) ]
395397#[ diag( ast_passes:: generic_arg_after_constraint) ]
396398pub struct GenericArgAfterConstraint {
397399 #[ primary_span]
@@ -409,28 +411,28 @@ pub struct GenericArgAfterConstraint {
409411 pub correct_order : String ,
410412}
411413
412- #[ derive( SessionDiagnostic ) ]
414+ #[ derive( Diagnostic ) ]
413415#[ diag( ast_passes:: fn_ptr_ty_with_pat, code = "E0561" ) ]
414416pub struct FnPtrTyWithPat {
415417 #[ primary_span]
416418 pub span : Span ,
417419}
418420
419- #[ derive( SessionDiagnostic ) ]
421+ #[ derive( Diagnostic ) ]
420422#[ diag( ast_passes:: multiple_explicit_lifetime_bound, code = "E0226" ) ]
421423pub struct MultipleExplicitLifetimeBound {
422424 #[ primary_span]
423425 pub span : Span ,
424426}
425427
426- #[ derive( SessionDiagnostic ) ]
428+ #[ derive( Diagnostic ) ]
427429#[ diag( ast_passes:: impl_trait_ty_in_path_param, code = "E0667" ) ]
428430pub struct ImplTraitTyInPathParam {
429431 #[ primary_span]
430432 pub span : Span ,
431433}
432434
433- #[ derive( SessionDiagnostic ) ]
435+ #[ derive( Diagnostic ) ]
434436#[ diag( ast_passes:: impl_trait_ty_nested, code = "E0666" ) ]
435437pub struct ImplTraitTyNested {
436438 #[ primary_span]
@@ -440,9 +442,21 @@ pub struct ImplTraitTyNested {
440442 pub outer_span : Span ,
441443}
442444
443- #[ derive( SessionDiagnostic ) ]
445+ #[ derive( Diagnostic ) ]
444446#[ diag( ast_passes:: impl_trait_ty_without_trait_bound) ]
445447pub struct ImplTraitTyWithoutTraitBound {
446448 #[ primary_span]
447449 pub span : Span ,
448450}
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