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, 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<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
398        diag.span_labels(self.0, "");
399    }
400}
401
402#[derive(Diagnostic)]
403#[diag(ast_passes_pattern_in_fn_pointer, code = E0561)]
404pub(crate) struct PatternFnPointer {
405    #[primary_span]
406    pub span: Span,
407}
408
409#[derive(Diagnostic)]
410#[diag(ast_passes_trait_object_single_bound, code = E0226)]
411pub(crate) struct TraitObjectBound {
412    #[primary_span]
413    pub span: Span,
414}
415
416#[derive(Diagnostic)]
417#[diag(ast_passes_nested_impl_trait, code = E0666)]
418pub(crate) struct NestedImplTrait {
419    #[primary_span]
420    pub span: Span,
421    #[label(ast_passes_outer)]
422    pub outer: Span,
423    #[label(ast_passes_inner)]
424    pub inner: Span,
425}
426
427#[derive(Diagnostic)]
428#[diag(ast_passes_at_least_one_trait)]
429pub(crate) struct AtLeastOneTrait {
430    #[primary_span]
431    pub span: Span,
432}
433
434#[derive(Diagnostic)]
435#[diag(ast_passes_out_of_order_params)]
436pub(crate) struct OutOfOrderParams<'a> {
437    #[primary_span]
438    pub spans: Vec<Span>,
439    #[suggestion(code = "{ordered_params}", applicability = "machine-applicable")]
440    pub sugg_span: Span,
441    pub param_ord: &'a ParamKindOrd,
442    pub max_param: &'a ParamKindOrd,
443    pub ordered_params: &'a str,
444}
445
446#[derive(Diagnostic)]
447#[diag(ast_passes_obsolete_auto)]
448#[help]
449pub(crate) struct ObsoleteAuto {
450    #[primary_span]
451    pub span: Span,
452}
453
454#[derive(Diagnostic)]
455#[diag(ast_passes_unsafe_negative_impl, code = E0198)]
456pub(crate) struct UnsafeNegativeImpl {
457    #[primary_span]
458    pub span: Span,
459    #[label(ast_passes_negative)]
460    pub negative: Span,
461    #[label(ast_passes_unsafe)]
462    pub r#unsafe: Span,
463}
464
465#[derive(Diagnostic)]
466#[diag(ast_passes_inherent_cannot_be)]
467pub(crate) struct InherentImplCannot<'a> {
468    #[primary_span]
469    pub span: Span,
470    #[label(ast_passes_because)]
471    pub annotation_span: Span,
472    pub annotation: &'a str,
473    #[label(ast_passes_type)]
474    pub self_ty: Span,
475    #[note(ast_passes_only_trait)]
476    pub only_trait: bool,
477}
478
479#[derive(Diagnostic)]
480#[diag(ast_passes_inherent_cannot_be, code = E0197)]
481pub(crate) struct InherentImplCannotUnsafe<'a> {
482    #[primary_span]
483    pub span: Span,
484    #[label(ast_passes_because)]
485    pub annotation_span: Span,
486    pub annotation: &'a str,
487    #[label(ast_passes_type)]
488    pub self_ty: Span,
489}
490
491#[derive(Diagnostic)]
492#[diag(ast_passes_unsafe_item)]
493pub(crate) struct UnsafeItem {
494    #[primary_span]
495    pub span: Span,
496    pub kind: &'static str,
497}
498
499#[derive(Diagnostic)]
500#[diag(ast_passes_missing_unsafe_on_extern)]
501pub(crate) struct MissingUnsafeOnExtern {
502    #[primary_span]
503    pub span: Span,
504}
505
506#[derive(Diagnostic)]
507#[diag(ast_passes_fieldless_union)]
508pub(crate) struct FieldlessUnion {
509    #[primary_span]
510    pub span: Span,
511}
512
513#[derive(Diagnostic)]
514#[diag(ast_passes_where_clause_after_type_alias)]
515#[note]
516pub(crate) struct WhereClauseAfterTypeAlias {
517    #[primary_span]
518    pub span: Span,
519    #[help]
520    pub help: bool,
521}
522
523#[derive(Diagnostic)]
524#[diag(ast_passes_where_clause_before_type_alias)]
525#[note]
526pub(crate) struct WhereClauseBeforeTypeAlias {
527    #[primary_span]
528    pub span: Span,
529    #[subdiagnostic]
530    pub sugg: WhereClauseBeforeTypeAliasSugg,
531}
532
533#[derive(Subdiagnostic)]
534pub(crate) enum WhereClauseBeforeTypeAliasSugg {
535    #[suggestion(ast_passes_remove_suggestion, applicability = "machine-applicable", code = "")]
536    Remove {
537        #[primary_span]
538        span: Span,
539    },
540    #[multipart_suggestion(
541        ast_passes_move_suggestion,
542        applicability = "machine-applicable",
543        style = "verbose"
544    )]
545    Move {
546        #[suggestion_part(code = "")]
547        left: Span,
548        snippet: String,
549        #[suggestion_part(code = "{snippet}")]
550        right: Span,
551    },
552}
553
554#[derive(Diagnostic)]
555#[diag(ast_passes_generic_default_trailing)]
556pub(crate) struct GenericDefaultTrailing {
557    #[primary_span]
558    pub span: Span,
559}
560
561#[derive(Diagnostic)]
562#[diag(ast_passes_nested_lifetimes, code = E0316)]
563pub(crate) struct NestedLifetimes {
564    #[primary_span]
565    pub span: Span,
566}
567
568#[derive(Diagnostic)]
569#[diag(ast_passes_optional_trait_supertrait)]
570#[note]
571pub(crate) struct OptionalTraitSupertrait {
572    #[primary_span]
573    pub span: Span,
574    pub path_str: String,
575}
576
577#[derive(Diagnostic)]
578#[diag(ast_passes_optional_trait_object)]
579pub(crate) struct OptionalTraitObject {
580    #[primary_span]
581    pub span: Span,
582}
583
584#[derive(Diagnostic)]
585#[diag(ast_passes_const_bound_trait_object)]
586pub(crate) struct ConstBoundTraitObject {
587    #[primary_span]
588    pub span: Span,
589}
590
591// FIXME(const_trait_impl): Consider making the note/reason the message of the diagnostic.
592// FIXME(const_trait_impl): Provide structured suggestions (e.g., add `const` / `#[const_trait]` here).
593#[derive(Diagnostic)]
594#[diag(ast_passes_tilde_const_disallowed)]
595pub(crate) struct TildeConstDisallowed {
596    #[primary_span]
597    pub span: Span,
598    #[subdiagnostic]
599    pub reason: TildeConstReason,
600}
601
602#[derive(Subdiagnostic, Copy, Clone)]
603pub(crate) enum TildeConstReason {
604    #[note(ast_passes_closure)]
605    Closure,
606    #[note(ast_passes_function)]
607    Function {
608        #[primary_span]
609        ident: Span,
610    },
611    #[note(ast_passes_trait)]
612    Trait {
613        #[primary_span]
614        span: Span,
615    },
616    #[note(ast_passes_trait_impl)]
617    TraitImpl {
618        #[primary_span]
619        span: Span,
620    },
621    #[note(ast_passes_impl)]
622    Impl {
623        #[primary_span]
624        span: Span,
625    },
626    #[note(ast_passes_trait_assoc_ty)]
627    TraitAssocTy {
628        #[primary_span]
629        span: Span,
630    },
631    #[note(ast_passes_trait_impl_assoc_ty)]
632    TraitImplAssocTy {
633        #[primary_span]
634        span: Span,
635    },
636    #[note(ast_passes_inherent_assoc_ty)]
637    InherentAssocTy {
638        #[primary_span]
639        span: Span,
640    },
641    #[note(ast_passes_object)]
642    TraitObject,
643    #[note(ast_passes_item)]
644    Item,
645}
646
647#[derive(Diagnostic)]
648#[diag(ast_passes_const_and_coroutine)]
649pub(crate) struct ConstAndCoroutine {
650    #[primary_span]
651    pub spans: Vec<Span>,
652    #[label(ast_passes_const)]
653    pub const_span: Span,
654    #[label(ast_passes_coroutine)]
655    pub coroutine_span: Span,
656    #[label]
657    pub span: Span,
658    pub coroutine_kind: &'static str,
659}
660
661#[derive(Diagnostic)]
662#[diag(ast_passes_const_and_c_variadic)]
663pub(crate) struct ConstAndCVariadic {
664    #[primary_span]
665    pub spans: Vec<Span>,
666    #[label(ast_passes_const)]
667    pub const_span: Span,
668    #[label(ast_passes_variadic)]
669    pub variadic_spans: Vec<Span>,
670}
671
672#[derive(Diagnostic)]
673#[diag(ast_passes_pattern_in_foreign, code = E0130)]
674// FIXME: deduplicate with rustc_lint (`BuiltinLintDiag::PatternsInFnsWithoutBody`)
675pub(crate) struct PatternInForeign {
676    #[primary_span]
677    #[label]
678    pub span: Span,
679}
680
681#[derive(Diagnostic)]
682#[diag(ast_passes_pattern_in_bodiless, code = E0642)]
683// FIXME: deduplicate with rustc_lint (`BuiltinLintDiag::PatternsInFnsWithoutBody`)
684pub(crate) struct PatternInBodiless {
685    #[primary_span]
686    #[label]
687    pub span: Span,
688}
689
690#[derive(Diagnostic)]
691#[diag(ast_passes_equality_in_where)]
692#[note]
693pub(crate) struct EqualityInWhere {
694    #[primary_span]
695    #[label]
696    pub span: Span,
697    #[subdiagnostic]
698    pub assoc: Option<AssociatedSuggestion>,
699    #[subdiagnostic]
700    pub assoc2: Option<AssociatedSuggestion2>,
701}
702
703#[derive(Subdiagnostic)]
704#[suggestion(
705    ast_passes_suggestion,
706    code = "{param}: {path}",
707    style = "verbose",
708    applicability = "maybe-incorrect"
709)]
710pub(crate) struct AssociatedSuggestion {
711    #[primary_span]
712    pub span: Span,
713    pub ident: Ident,
714    pub param: Ident,
715    pub path: String,
716}
717
718#[derive(Subdiagnostic)]
719#[multipart_suggestion(ast_passes_suggestion_path, applicability = "maybe-incorrect")]
720pub(crate) struct AssociatedSuggestion2 {
721    #[suggestion_part(code = "{args}")]
722    pub span: Span,
723    pub args: String,
724    #[suggestion_part(code = "")]
725    pub predicate: Span,
726    pub trait_segment: Ident,
727    pub potential_assoc: Ident,
728}
729
730#[derive(Diagnostic)]
731#[diag(ast_passes_feature_on_non_nightly, code = E0554)]
732pub(crate) struct FeatureOnNonNightly {
733    #[primary_span]
734    pub span: Span,
735    pub channel: &'static str,
736    #[subdiagnostic]
737    pub stable_features: Vec<StableFeature>,
738    #[suggestion(code = "", applicability = "machine-applicable")]
739    pub sugg: Option<Span>,
740}
741
742pub(crate) struct StableFeature {
743    pub name: Symbol,
744    pub since: Symbol,
745}
746
747impl Subdiagnostic for StableFeature {
748    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
749        diag.arg("name", self.name);
750        diag.arg("since", self.since);
751        diag.help(fluent::ast_passes_stable_since);
752    }
753}
754
755#[derive(Diagnostic)]
756#[diag(ast_passes_incompatible_features)]
757#[help]
758pub(crate) struct IncompatibleFeatures {
759    #[primary_span]
760    pub spans: Vec<Span>,
761    pub f1: Symbol,
762    pub f2: Symbol,
763}
764
765#[derive(Diagnostic)]
766#[diag(ast_passes_negative_bound_not_supported)]
767pub(crate) struct NegativeBoundUnsupported {
768    #[primary_span]
769    pub span: Span,
770}
771
772#[derive(Diagnostic)]
773#[diag(ast_passes_constraint_on_negative_bound)]
774pub(crate) struct ConstraintOnNegativeBound {
775    #[primary_span]
776    pub span: Span,
777}
778
779#[derive(Diagnostic)]
780#[diag(ast_passes_negative_bound_with_parenthetical_notation)]
781pub(crate) struct NegativeBoundWithParentheticalNotation {
782    #[primary_span]
783    pub span: Span,
784}
785
786#[derive(Diagnostic)]
787#[diag(ast_passes_match_arm_with_no_body)]
788pub(crate) struct MatchArmWithNoBody {
789    #[primary_span]
790    pub span: Span,
791    // We include the braces around `todo!()` so that a comma is optional, and we don't have to have
792    // any logic looking at the arm being replaced if there was a comma already or not for the
793    // resulting code to be correct.
794    #[suggestion(
795        code = " => {{ todo!() }}",
796        applicability = "has-placeholders",
797        style = "verbose"
798    )]
799    pub suggestion: Span,
800}
801
802#[derive(Diagnostic)]
803#[diag(ast_passes_precise_capturing_not_allowed_here)]
804pub(crate) struct PreciseCapturingNotAllowedHere {
805    #[primary_span]
806    pub span: Span,
807    pub loc: &'static str,
808}
809
810#[derive(Diagnostic)]
811#[diag(ast_passes_precise_capturing_duplicated)]
812pub(crate) struct DuplicatePreciseCapturing {
813    #[primary_span]
814    pub bound1: Span,
815    #[label]
816    pub bound2: Span,
817}
818
819#[derive(Diagnostic)]
820#[diag(ast_passes_extern_without_abi)]
821#[help]
822pub(crate) struct MissingAbi {
823    #[primary_span]
824    #[suggestion(code = "extern \"<abi>\"", applicability = "has-placeholders")]
825    pub span: Span,
826}