rustc_ast_passes/
errors.rs

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