1use rustc_abi::ExternAbi;
4use rustc_ast::ParamKindOrd;
5use rustc_errors::codes::*;
6use rustc_errors::{Applicability, Diag, EmissionGuarantee, Subdiagnostic};
7use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
8use rustc_span::{Ident, Span, Symbol};
9
10use crate::fluent_generated as fluent;
11
12#[derive(Diagnostic)]
13#[diag(ast_passes_visibility_not_permitted, code = E0449)]
14pub(crate) struct VisibilityNotPermitted {
15 #[primary_span]
16 pub span: Span,
17 #[subdiagnostic]
18 pub note: VisibilityNotPermittedNote,
19 #[suggestion(
20 ast_passes_remove_qualifier_sugg,
21 code = "",
22 applicability = "machine-applicable"
23 )]
24 pub remove_qualifier_sugg: Span,
25}
26
27#[derive(Subdiagnostic)]
28pub(crate) enum VisibilityNotPermittedNote {
29 #[note(ast_passes_enum_variant)]
30 EnumVariant,
31 #[note(ast_passes_trait_impl)]
32 TraitImpl,
33 #[note(ast_passes_individual_impl_items)]
34 IndividualImplItems,
35 #[note(ast_passes_individual_foreign_items)]
36 IndividualForeignItems,
37}
38
39#[derive(Diagnostic)]
40#[diag(ast_passes_trait_fn_const, code = E0379)]
41pub(crate) struct TraitFnConst {
42 #[primary_span]
43 #[label]
44 pub span: Span,
45 pub in_impl: bool,
46 #[label(ast_passes_const_context_label)]
47 pub const_context_label: Option<Span>,
48 #[suggestion(ast_passes_remove_const_sugg, code = "")]
49 pub remove_const_sugg: (Span, Applicability),
50 pub requires_multiple_changes: bool,
51 #[suggestion(
52 ast_passes_make_impl_const_sugg,
53 code = "const ",
54 applicability = "maybe-incorrect"
55 )]
56 pub make_impl_const_sugg: Option<Span>,
57 #[suggestion(
58 ast_passes_make_trait_const_sugg,
59 code = "#[const_trait]\n",
60 applicability = "maybe-incorrect"
61 )]
62 pub make_trait_const_sugg: Option<Span>,
63}
64
65#[derive(Diagnostic)]
66#[diag(ast_passes_async_fn_in_const_trait_or_trait_impl)]
67pub(crate) struct AsyncFnInConstTraitOrTraitImpl {
68 #[primary_span]
69 pub async_keyword: Span,
70 pub in_impl: bool,
71 #[label]
72 pub const_keyword: Span,
73}
74
75#[derive(Diagnostic)]
76#[diag(ast_passes_forbidden_bound)]
77pub(crate) struct ForbiddenBound {
78 #[primary_span]
79 pub spans: Vec<Span>,
80}
81
82#[derive(Diagnostic)]
83#[diag(ast_passes_forbidden_const_param)]
84pub(crate) struct ForbiddenConstParam {
85 #[primary_span]
86 pub const_param_spans: Vec<Span>,
87}
88
89#[derive(Diagnostic)]
90#[diag(ast_passes_fn_param_too_many)]
91pub(crate) struct FnParamTooMany {
92 #[primary_span]
93 pub span: Span,
94 pub max_num_args: usize,
95}
96
97#[derive(Diagnostic)]
98#[diag(ast_passes_fn_param_c_var_args_not_last)]
99pub(crate) struct FnParamCVarArgsNotLast {
100 #[primary_span]
101 pub span: Span,
102}
103
104#[derive(Diagnostic)]
105#[diag(ast_passes_fn_param_doc_comment)]
106pub(crate) struct FnParamDocComment {
107 #[primary_span]
108 #[label]
109 pub span: Span,
110}
111
112#[derive(Diagnostic)]
113#[diag(ast_passes_fn_param_forbidden_attr)]
114pub(crate) struct FnParamForbiddenAttr {
115 #[primary_span]
116 pub span: Span,
117}
118
119#[derive(Diagnostic)]
120#[diag(ast_passes_fn_param_forbidden_self)]
121#[note]
122pub(crate) struct FnParamForbiddenSelf {
123 #[primary_span]
124 #[label]
125 pub span: Span,
126}
127
128#[derive(Diagnostic)]
129#[diag(ast_passes_forbidden_default)]
130pub(crate) struct ForbiddenDefault {
131 #[primary_span]
132 pub span: Span,
133 #[label]
134 pub def_span: Span,
135}
136
137#[derive(Diagnostic)]
138#[diag(ast_passes_assoc_const_without_body)]
139pub(crate) struct AssocConstWithoutBody {
140 #[primary_span]
141 pub span: Span,
142 #[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
143 pub replace_span: Span,
144}
145
146#[derive(Diagnostic)]
147#[diag(ast_passes_assoc_fn_without_body)]
148pub(crate) struct AssocFnWithoutBody {
149 #[primary_span]
150 pub span: Span,
151 #[suggestion(code = " {{ <body> }}", applicability = "has-placeholders")]
152 pub replace_span: Span,
153}
154
155#[derive(Diagnostic)]
156#[diag(ast_passes_assoc_type_without_body)]
157pub(crate) struct AssocTypeWithoutBody {
158 #[primary_span]
159 pub span: Span,
160 #[suggestion(code = " = <type>;", applicability = "has-placeholders")]
161 pub replace_span: Span,
162}
163
164#[derive(Diagnostic)]
165#[diag(ast_passes_const_without_body)]
166pub(crate) struct ConstWithoutBody {
167 #[primary_span]
168 pub span: Span,
169 #[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
170 pub replace_span: Span,
171}
172
173#[derive(Diagnostic)]
174#[diag(ast_passes_static_without_body)]
175pub(crate) struct StaticWithoutBody {
176 #[primary_span]
177 pub span: Span,
178 #[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
179 pub replace_span: Span,
180}
181
182#[derive(Diagnostic)]
183#[diag(ast_passes_ty_alias_without_body)]
184pub(crate) struct TyAliasWithoutBody {
185 #[primary_span]
186 pub span: Span,
187 #[suggestion(code = " = <type>;", applicability = "has-placeholders")]
188 pub replace_span: Span,
189}
190
191#[derive(Diagnostic)]
192#[diag(ast_passes_fn_without_body)]
193pub(crate) struct FnWithoutBody {
194 #[primary_span]
195 pub span: Span,
196 #[suggestion(code = " {{ <body> }}", applicability = "has-placeholders")]
197 pub replace_span: Span,
198 #[subdiagnostic]
199 pub extern_block_suggestion: Option<ExternBlockSuggestion>,
200}
201
202#[derive(Subdiagnostic)]
203pub(crate) enum ExternBlockSuggestion {
204 #[multipart_suggestion(ast_passes_extern_block_suggestion, applicability = "maybe-incorrect")]
205 Implicit {
206 #[suggestion_part(code = "extern {{")]
207 start_span: Span,
208 #[suggestion_part(code = " }}")]
209 end_span: Span,
210 },
211 #[multipart_suggestion(ast_passes_extern_block_suggestion, applicability = "maybe-incorrect")]
212 Explicit {
213 #[suggestion_part(code = "extern \"{abi}\" {{")]
214 start_span: Span,
215 #[suggestion_part(code = " }}")]
216 end_span: Span,
217 abi: Symbol,
218 },
219}
220
221#[derive(Diagnostic)]
222#[diag(ast_passes_extern_invalid_safety)]
223pub(crate) struct InvalidSafetyOnExtern {
224 #[primary_span]
225 pub item_span: Span,
226 #[suggestion(code = "unsafe ", applicability = "machine-applicable", style = "verbose")]
227 pub block: Option<Span>,
228}
229
230#[derive(Diagnostic)]
231#[diag(ast_passes_item_invalid_safety)]
232pub(crate) struct InvalidSafetyOnItem {
233 #[primary_span]
234 pub span: Span,
235}
236
237#[derive(Diagnostic)]
238#[diag(ast_passes_fn_ptr_invalid_safety)]
239pub(crate) struct InvalidSafetyOnFnPtr {
240 #[primary_span]
241 pub span: Span,
242}
243
244#[derive(Diagnostic)]
245#[diag(ast_passes_unsafe_static)]
246pub(crate) struct UnsafeStatic {
247 #[primary_span]
248 pub span: Span,
249}
250
251#[derive(Diagnostic)]
252#[diag(ast_passes_bound_in_context)]
253pub(crate) struct BoundInContext<'a> {
254 #[primary_span]
255 pub span: Span,
256 pub ctx: &'a str,
257}
258
259#[derive(Diagnostic)]
260#[diag(ast_passes_extern_types_cannot)]
261#[note(ast_passes_extern_keyword_link)]
262pub(crate) struct ExternTypesCannotHave<'a> {
263 #[primary_span]
264 #[suggestion(code = "", applicability = "maybe-incorrect")]
265 pub span: Span,
266 pub descr: &'a str,
267 pub remove_descr: &'a str,
268 #[label]
269 pub block_span: Span,
270}
271
272#[derive(Diagnostic)]
273#[diag(ast_passes_body_in_extern)]
274#[note(ast_passes_extern_keyword_link)]
275pub(crate) struct BodyInExtern<'a> {
276 #[primary_span]
277 #[label(ast_passes_cannot_have)]
278 pub span: Span,
279 #[label(ast_passes_invalid)]
280 pub body: Span,
281 #[label(ast_passes_existing)]
282 pub block: Span,
283 pub kind: &'a str,
284}
285
286#[derive(Diagnostic)]
287#[diag(ast_passes_fn_body_extern)]
288#[help]
289#[note(ast_passes_extern_keyword_link)]
290pub(crate) struct FnBodyInExtern {
291 #[primary_span]
292 #[label(ast_passes_cannot_have)]
293 pub span: Span,
294 #[suggestion(code = ";", applicability = "maybe-incorrect")]
295 pub body: Span,
296 #[label]
297 pub block: Span,
298}
299
300#[derive(Diagnostic)]
301#[diag(ast_passes_extern_fn_qualifiers)]
302pub(crate) struct FnQualifierInExtern {
303 #[primary_span]
304 #[suggestion(code = "", applicability = "maybe-incorrect")]
305 pub span: Span,
306 #[label]
307 pub block: Span,
308 pub kw: &'static str,
309}
310
311#[derive(Diagnostic)]
312#[diag(ast_passes_extern_item_ascii)]
313#[note]
314pub(crate) struct ExternItemAscii {
315 #[primary_span]
316 pub span: Span,
317 #[label]
318 pub block: Span,
319}
320
321#[derive(Diagnostic)]
322#[diag(ast_passes_c_variadic_associated_function)]
323pub(crate) struct CVariadicAssociatedFunction {
324 #[primary_span]
325 pub span: Span,
326}
327
328#[derive(Diagnostic)]
329#[diag(ast_passes_c_variadic_no_extern)]
330#[help]
331pub(crate) struct CVariadicNoExtern {
332 #[primary_span]
333 pub span: Span,
334}
335
336#[derive(Diagnostic)]
337#[diag(ast_passes_c_variadic_must_be_unsafe)]
338pub(crate) struct CVariadicMustBeUnsafe {
339 #[primary_span]
340 pub span: Span,
341
342 #[suggestion(
343 ast_passes_suggestion,
344 applicability = "maybe-incorrect",
345 code = "unsafe ",
346 style = "verbose"
347 )]
348 pub unsafe_span: Span,
349}
350
351#[derive(Diagnostic)]
352#[diag(ast_passes_c_variadic_bad_extern)]
353#[help]
354pub(crate) struct CVariadicBadExtern {
355 #[primary_span]
356 pub span: Span,
357 pub abi: Symbol,
358 #[label]
359 pub extern_span: Span,
360}
361
362#[derive(Diagnostic)]
363#[diag(ast_passes_item_underscore)]
364pub(crate) struct ItemUnderscore<'a> {
365 #[primary_span]
366 #[label]
367 pub span: Span,
368 pub kind: &'a str,
369}
370
371#[derive(Diagnostic)]
372#[diag(ast_passes_nomangle_ascii, code = E0754)]
373pub(crate) struct NoMangleAscii {
374 #[primary_span]
375 pub span: Span,
376}
377
378#[derive(Diagnostic)]
379#[diag(ast_passes_module_nonascii, code = E0754)]
380#[help]
381pub(crate) struct ModuleNonAscii {
382 #[primary_span]
383 pub span: Span,
384 pub name: Symbol,
385}
386
387#[derive(Diagnostic)]
388#[diag(ast_passes_auto_generic, code = E0567)]
389pub(crate) struct AutoTraitGeneric {
390 #[primary_span]
391 #[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
392 pub span: Span,
393 #[label]
394 pub ident: Span,
395}
396
397#[derive(Diagnostic)]
398#[diag(ast_passes_auto_super_lifetime, code = E0568)]
399pub(crate) struct AutoTraitBounds {
400 #[primary_span]
401 pub span: Vec<Span>,
402 #[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
403 pub removal: Span,
404 #[label]
405 pub ident: Span,
406}
407
408#[derive(Diagnostic)]
409#[diag(ast_passes_auto_items, code = E0380)]
410pub(crate) struct AutoTraitItems {
411 #[primary_span]
412 pub spans: Vec<Span>,
413 #[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
414 pub total: Span,
415 #[label]
416 pub ident: Span,
417}
418
419#[derive(Diagnostic)]
420#[diag(ast_passes_generic_before_constraints)]
421pub(crate) struct ArgsBeforeConstraint {
422 #[primary_span]
423 pub arg_spans: Vec<Span>,
424 #[label(ast_passes_constraints)]
425 pub constraints: Span,
426 #[label(ast_passes_args)]
427 pub args: Span,
428 #[suggestion(code = "{suggestion}", applicability = "machine-applicable", style = "verbose")]
429 pub data: Span,
430 pub suggestion: String,
431 pub constraint_len: usize,
432 pub args_len: usize,
433 #[subdiagnostic]
434 pub constraint_spans: EmptyLabelManySpans,
435 #[subdiagnostic]
436 pub arg_spans2: EmptyLabelManySpans,
437}
438
439pub(crate) struct EmptyLabelManySpans(pub Vec<Span>);
440
441impl Subdiagnostic for EmptyLabelManySpans {
443 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
444 diag.span_labels(self.0, "");
445 }
446}
447
448#[derive(Diagnostic)]
449#[diag(ast_passes_pattern_in_fn_pointer, code = E0561)]
450pub(crate) struct PatternFnPointer {
451 #[primary_span]
452 pub span: Span,
453}
454
455#[derive(Diagnostic)]
456#[diag(ast_passes_trait_object_single_bound, code = E0226)]
457pub(crate) struct TraitObjectBound {
458 #[primary_span]
459 pub span: Span,
460}
461
462#[derive(Diagnostic)]
463#[diag(ast_passes_nested_impl_trait, code = E0666)]
464pub(crate) struct NestedImplTrait {
465 #[primary_span]
466 pub span: Span,
467 #[label(ast_passes_outer)]
468 pub outer: Span,
469 #[label(ast_passes_inner)]
470 pub inner: Span,
471}
472
473#[derive(Diagnostic)]
474#[diag(ast_passes_at_least_one_trait)]
475pub(crate) struct AtLeastOneTrait {
476 #[primary_span]
477 pub span: Span,
478}
479
480#[derive(Diagnostic)]
481#[diag(ast_passes_out_of_order_params)]
482pub(crate) struct OutOfOrderParams<'a> {
483 #[primary_span]
484 pub spans: Vec<Span>,
485 #[suggestion(code = "{ordered_params}", applicability = "machine-applicable")]
486 pub sugg_span: Span,
487 pub param_ord: &'a ParamKindOrd,
488 pub max_param: &'a ParamKindOrd,
489 pub ordered_params: &'a str,
490}
491
492#[derive(Diagnostic)]
493#[diag(ast_passes_obsolete_auto)]
494#[help]
495pub(crate) struct ObsoleteAuto {
496 #[primary_span]
497 pub span: Span,
498}
499
500#[derive(Diagnostic)]
501#[diag(ast_passes_unsafe_negative_impl, code = E0198)]
502pub(crate) struct UnsafeNegativeImpl {
503 #[primary_span]
504 pub span: Span,
505 #[label(ast_passes_negative)]
506 pub negative: Span,
507 #[label(ast_passes_unsafe)]
508 pub r#unsafe: Span,
509}
510
511#[derive(Diagnostic)]
512#[diag(ast_passes_unsafe_item)]
513pub(crate) struct UnsafeItem {
514 #[primary_span]
515 pub span: Span,
516 pub kind: &'static str,
517}
518
519#[derive(Diagnostic)]
520#[diag(ast_passes_missing_unsafe_on_extern)]
521pub(crate) struct MissingUnsafeOnExtern {
522 #[primary_span]
523 pub span: Span,
524}
525
526#[derive(Diagnostic)]
527#[diag(ast_passes_fieldless_union)]
528pub(crate) struct FieldlessUnion {
529 #[primary_span]
530 pub span: Span,
531}
532
533#[derive(Diagnostic)]
534#[diag(ast_passes_where_clause_after_type_alias)]
535#[note]
536pub(crate) struct WhereClauseAfterTypeAlias {
537 #[primary_span]
538 pub span: Span,
539 #[help]
540 pub help: bool,
541}
542
543#[derive(Diagnostic)]
544#[diag(ast_passes_where_clause_before_type_alias)]
545#[note]
546pub(crate) struct WhereClauseBeforeTypeAlias {
547 #[primary_span]
548 pub span: Span,
549 #[subdiagnostic]
550 pub sugg: WhereClauseBeforeTypeAliasSugg,
551}
552
553#[derive(Subdiagnostic)]
554pub(crate) enum WhereClauseBeforeTypeAliasSugg {
555 #[suggestion(ast_passes_remove_suggestion, applicability = "machine-applicable", code = "")]
556 Remove {
557 #[primary_span]
558 span: Span,
559 },
560 #[multipart_suggestion(
561 ast_passes_move_suggestion,
562 applicability = "machine-applicable",
563 style = "verbose"
564 )]
565 Move {
566 #[suggestion_part(code = "")]
567 left: Span,
568 snippet: String,
569 #[suggestion_part(code = "{snippet}")]
570 right: Span,
571 },
572}
573
574#[derive(Diagnostic)]
575#[diag(ast_passes_generic_default_trailing)]
576pub(crate) struct GenericDefaultTrailing {
577 #[primary_span]
578 pub span: Span,
579}
580
581#[derive(Diagnostic)]
582#[diag(ast_passes_nested_lifetimes, code = E0316)]
583pub(crate) struct NestedLifetimes {
584 #[primary_span]
585 pub span: Span,
586}
587
588#[derive(Diagnostic)]
589#[diag(ast_passes_const_bound_trait_object)]
590pub(crate) struct ConstBoundTraitObject {
591 #[primary_span]
592 pub span: Span,
593}
594
595#[derive(Diagnostic)]
598#[diag(ast_passes_tilde_const_disallowed)]
599pub(crate) struct TildeConstDisallowed {
600 #[primary_span]
601 pub span: Span,
602 #[subdiagnostic]
603 pub reason: TildeConstReason,
604}
605
606#[derive(Subdiagnostic, Copy, Clone)]
607pub(crate) enum TildeConstReason {
608 #[note(ast_passes_closure)]
609 Closure,
610 #[note(ast_passes_function)]
611 Function {
612 #[primary_span]
613 ident: Span,
614 },
615 #[note(ast_passes_trait)]
616 Trait {
617 #[primary_span]
618 span: Span,
619 },
620 #[note(ast_passes_trait_impl)]
621 TraitImpl {
622 #[primary_span]
623 span: Span,
624 },
625 #[note(ast_passes_impl)]
626 Impl {
627 #[primary_span]
628 span: Span,
629 },
630 #[note(ast_passes_trait_assoc_ty)]
631 TraitAssocTy {
632 #[primary_span]
633 span: Span,
634 },
635 #[note(ast_passes_trait_impl_assoc_ty)]
636 TraitImplAssocTy {
637 #[primary_span]
638 span: Span,
639 },
640 #[note(ast_passes_inherent_assoc_ty)]
641 InherentAssocTy {
642 #[primary_span]
643 span: Span,
644 },
645 #[note(ast_passes_struct)]
646 Struct {
647 #[primary_span]
648 span: Span,
649 },
650 #[note(ast_passes_enum)]
651 Enum {
652 #[primary_span]
653 span: Span,
654 },
655 #[note(ast_passes_union)]
656 Union {
657 #[primary_span]
658 span: Span,
659 },
660 #[note(ast_passes_anon_const)]
661 AnonConst {
662 #[primary_span]
663 span: Span,
664 },
665 #[note(ast_passes_object)]
666 TraitObject,
667 #[note(ast_passes_item)]
668 Item,
669}
670
671#[derive(Diagnostic)]
672#[diag(ast_passes_const_and_coroutine)]
673pub(crate) struct ConstAndCoroutine {
674 #[primary_span]
675 pub spans: Vec<Span>,
676 #[label(ast_passes_const)]
677 pub const_span: Span,
678 #[label(ast_passes_coroutine)]
679 pub coroutine_span: Span,
680 #[label]
681 pub span: Span,
682 pub coroutine_kind: &'static str,
683}
684
685#[derive(Diagnostic)]
686#[diag(ast_passes_const_and_c_variadic)]
687pub(crate) struct ConstAndCVariadic {
688 #[primary_span]
689 pub spans: Vec<Span>,
690 #[label(ast_passes_const)]
691 pub const_span: Span,
692 #[label(ast_passes_variadic)]
693 pub variadic_span: Span,
694}
695
696#[derive(Diagnostic)]
697#[diag(ast_passes_coroutine_and_c_variadic)]
698pub(crate) struct CoroutineAndCVariadic {
699 #[primary_span]
700 pub spans: Vec<Span>,
701 pub coroutine_kind: &'static str,
702 #[label(ast_passes_const)]
703 pub coroutine_span: Span,
704 #[label(ast_passes_variadic)]
705 pub variadic_span: Span,
706}
707
708#[derive(Diagnostic)]
709#[diag(ast_passes_pattern_in_foreign, code = E0130)]
710pub(crate) struct PatternInForeign {
712 #[primary_span]
713 #[label]
714 pub span: Span,
715}
716
717#[derive(Diagnostic)]
718#[diag(ast_passes_pattern_in_bodiless, code = E0642)]
719pub(crate) struct PatternInBodiless {
721 #[primary_span]
722 #[label]
723 pub span: Span,
724}
725
726#[derive(Diagnostic)]
727#[diag(ast_passes_equality_in_where)]
728#[note]
729pub(crate) struct EqualityInWhere {
730 #[primary_span]
731 #[label]
732 pub span: Span,
733 #[subdiagnostic]
734 pub assoc: Option<AssociatedSuggestion>,
735 #[subdiagnostic]
736 pub assoc2: Option<AssociatedSuggestion2>,
737}
738
739#[derive(Subdiagnostic)]
740#[suggestion(
741 ast_passes_suggestion,
742 code = "{param}: {path}",
743 style = "verbose",
744 applicability = "maybe-incorrect"
745)]
746pub(crate) struct AssociatedSuggestion {
747 #[primary_span]
748 pub span: Span,
749 pub ident: Ident,
750 pub param: Ident,
751 pub path: String,
752}
753
754#[derive(Subdiagnostic)]
755#[multipart_suggestion(ast_passes_suggestion_path, applicability = "maybe-incorrect")]
756pub(crate) struct AssociatedSuggestion2 {
757 #[suggestion_part(code = "{args}")]
758 pub span: Span,
759 pub args: String,
760 #[suggestion_part(code = "")]
761 pub predicate: Span,
762 pub trait_segment: Ident,
763 pub potential_assoc: Ident,
764}
765
766#[derive(Diagnostic)]
767#[diag(ast_passes_feature_on_non_nightly, code = E0554)]
768pub(crate) struct FeatureOnNonNightly {
769 #[primary_span]
770 pub span: Span,
771 pub channel: &'static str,
772 #[subdiagnostic]
773 pub stable_features: Vec<StableFeature>,
774 #[suggestion(code = "", applicability = "machine-applicable")]
775 pub sugg: Option<Span>,
776}
777
778pub(crate) struct StableFeature {
779 pub name: Symbol,
780 pub since: Symbol,
781}
782
783impl Subdiagnostic for StableFeature {
784 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
785 diag.arg("name", self.name);
786 diag.arg("since", self.since);
787 diag.help(fluent::ast_passes_stable_since);
788 }
789}
790
791#[derive(Diagnostic)]
792#[diag(ast_passes_incompatible_features)]
793#[help]
794pub(crate) struct IncompatibleFeatures {
795 #[primary_span]
796 pub spans: Vec<Span>,
797 pub f1: Symbol,
798 pub f2: Symbol,
799}
800
801#[derive(Diagnostic)]
802#[diag(ast_passes_negative_bound_not_supported)]
803pub(crate) struct NegativeBoundUnsupported {
804 #[primary_span]
805 pub span: Span,
806}
807
808#[derive(Diagnostic)]
809#[diag(ast_passes_constraint_on_negative_bound)]
810pub(crate) struct ConstraintOnNegativeBound {
811 #[primary_span]
812 pub span: Span,
813}
814
815#[derive(Diagnostic)]
816#[diag(ast_passes_negative_bound_with_parenthetical_notation)]
817pub(crate) struct NegativeBoundWithParentheticalNotation {
818 #[primary_span]
819 pub span: Span,
820}
821
822#[derive(Diagnostic)]
823#[diag(ast_passes_match_arm_with_no_body)]
824pub(crate) struct MatchArmWithNoBody {
825 #[primary_span]
826 pub span: Span,
827 #[suggestion(
831 code = " => {{ todo!() }}",
832 applicability = "has-placeholders",
833 style = "verbose"
834 )]
835 pub suggestion: Span,
836}
837
838#[derive(Diagnostic)]
839#[diag(ast_passes_precise_capturing_not_allowed_here)]
840pub(crate) struct PreciseCapturingNotAllowedHere {
841 #[primary_span]
842 pub span: Span,
843 pub loc: &'static str,
844}
845
846#[derive(Diagnostic)]
847#[diag(ast_passes_precise_capturing_duplicated)]
848pub(crate) struct DuplicatePreciseCapturing {
849 #[primary_span]
850 pub bound1: Span,
851 #[label]
852 pub bound2: Span,
853}
854
855#[derive(Diagnostic)]
856#[diag(ast_passes_extern_without_abi)]
857#[help]
858pub(crate) struct MissingAbi {
859 #[primary_span]
860 #[suggestion(code = "extern \"<abi>\"", applicability = "has-placeholders")]
861 pub span: Span,
862}
863
864#[derive(LintDiagnostic)]
865#[diag(ast_passes_extern_without_abi_sugg)]
866pub(crate) struct MissingAbiSugg {
867 #[suggestion(code = "extern {default_abi}", applicability = "machine-applicable")]
868 pub span: Span,
869 pub default_abi: ExternAbi,
870}
871
872#[derive(Diagnostic)]
873#[diag(ast_passes_abi_custom_safe_foreign_function)]
874pub(crate) struct AbiCustomSafeForeignFunction {
875 #[primary_span]
876 pub span: Span,
877
878 #[suggestion(
879 ast_passes_suggestion,
880 applicability = "maybe-incorrect",
881 code = "",
882 style = "verbose"
883 )]
884 pub safe_span: Span,
885}
886
887#[derive(Diagnostic)]
888#[diag(ast_passes_abi_custom_safe_function)]
889pub(crate) struct AbiCustomSafeFunction {
890 #[primary_span]
891 pub span: Span,
892 pub abi: ExternAbi,
893
894 #[suggestion(
895 ast_passes_suggestion,
896 applicability = "maybe-incorrect",
897 code = "unsafe ",
898 style = "verbose"
899 )]
900 pub unsafe_span: Span,
901}
902
903#[derive(Diagnostic)]
904#[diag(ast_passes_abi_cannot_be_coroutine)]
905pub(crate) struct AbiCannotBeCoroutine {
906 #[primary_span]
907 pub span: Span,
908 pub abi: ExternAbi,
909
910 #[suggestion(
911 ast_passes_suggestion,
912 applicability = "maybe-incorrect",
913 code = "",
914 style = "verbose"
915 )]
916 pub coroutine_kind_span: Span,
917 pub coroutine_kind_str: &'static str,
918}
919
920#[derive(Diagnostic)]
921#[diag(ast_passes_abi_must_not_have_parameters_or_return_type)]
922#[note]
923pub(crate) struct AbiMustNotHaveParametersOrReturnType {
924 #[primary_span]
925 pub spans: Vec<Span>,
926 pub abi: ExternAbi,
927
928 #[suggestion(
929 ast_passes_suggestion,
930 applicability = "maybe-incorrect",
931 code = "{padding}fn {symbol}()",
932 style = "verbose"
933 )]
934 pub suggestion_span: Span,
935 pub symbol: Symbol,
936 pub padding: &'static str,
937}
938
939#[derive(Diagnostic)]
940#[diag(ast_passes_abi_must_not_have_return_type)]
941#[note]
942pub(crate) struct AbiMustNotHaveReturnType {
943 #[primary_span]
944 #[help]
945 pub span: Span,
946 pub abi: ExternAbi,
947}
948
949#[derive(Diagnostic)]
950#[diag(ast_passes_abi_x86_interrupt)]
951#[note]
952pub(crate) struct AbiX86Interrupt {
953 #[primary_span]
954 pub spans: Vec<Span>,
955 pub param_count: usize,
956}