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)]
538pub(crate) enum WhereClauseBeforeTypeAliasSugg {
539    #[suggestion(ast_passes_remove_suggestion, applicability = "machine-applicable", code = "")]
540    Remove {
541        #[primary_span]
542        span: Span,
543    },
544    #[multipart_suggestion(
545        ast_passes_move_suggestion,
546        applicability = "machine-applicable",
547        style = "verbose"
548    )]
549    Move {
550        #[suggestion_part(code = "")]
551        left: Span,
552        snippet: String,
553        #[suggestion_part(code = "{snippet}")]
554        right: Span,
555    },
556}
557
558#[derive(Diagnostic)]
559#[diag(ast_passes_generic_default_trailing)]
560pub(crate) struct GenericDefaultTrailing {
561    #[primary_span]
562    pub span: Span,
563}
564
565#[derive(Diagnostic)]
566#[diag(ast_passes_nested_lifetimes, code = E0316)]
567pub(crate) struct NestedLifetimes {
568    #[primary_span]
569    pub span: Span,
570}
571
572#[derive(Diagnostic)]
573#[diag(ast_passes_optional_trait_supertrait)]
574#[note]
575pub(crate) struct OptionalTraitSupertrait {
576    #[primary_span]
577    pub span: Span,
578    pub path_str: String,
579}
580
581#[derive(Diagnostic)]
582#[diag(ast_passes_optional_trait_object)]
583pub(crate) struct OptionalTraitObject {
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// FIXME(const_trait_impl): Consider making the note/reason the message of the diagnostic.
596// FIXME(const_trait_impl): Provide structured suggestions (e.g., add `const` / `#[const_trait]` here).
597#[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_object)]
646    TraitObject,
647    #[note(ast_passes_item)]
648    Item,
649}
650
651#[derive(Diagnostic)]
652#[diag(ast_passes_const_and_coroutine)]
653pub(crate) struct ConstAndCoroutine {
654    #[primary_span]
655    pub spans: Vec<Span>,
656    #[label(ast_passes_const)]
657    pub const_span: Span,
658    #[label(ast_passes_coroutine)]
659    pub coroutine_span: Span,
660    #[label]
661    pub span: Span,
662    pub coroutine_kind: &'static str,
663}
664
665#[derive(Diagnostic)]
666#[diag(ast_passes_const_and_c_variadic)]
667pub(crate) struct ConstAndCVariadic {
668    #[primary_span]
669    pub spans: Vec<Span>,
670    #[label(ast_passes_const)]
671    pub const_span: Span,
672    #[label(ast_passes_variadic)]
673    pub variadic_spans: Vec<Span>,
674}
675
676#[derive(Diagnostic)]
677#[diag(ast_passes_pattern_in_foreign, code = E0130)]
678// FIXME: deduplicate with rustc_lint (`BuiltinLintDiag::PatternsInFnsWithoutBody`)
679pub(crate) struct PatternInForeign {
680    #[primary_span]
681    #[label]
682    pub span: Span,
683}
684
685#[derive(Diagnostic)]
686#[diag(ast_passes_pattern_in_bodiless, code = E0642)]
687// FIXME: deduplicate with rustc_lint (`BuiltinLintDiag::PatternsInFnsWithoutBody`)
688pub(crate) struct PatternInBodiless {
689    #[primary_span]
690    #[label]
691    pub span: Span,
692}
693
694#[derive(Diagnostic)]
695#[diag(ast_passes_equality_in_where)]
696#[note]
697pub(crate) struct EqualityInWhere {
698    #[primary_span]
699    #[label]
700    pub span: Span,
701    #[subdiagnostic]
702    pub assoc: Option<AssociatedSuggestion>,
703    #[subdiagnostic]
704    pub assoc2: Option<AssociatedSuggestion2>,
705}
706
707#[derive(Subdiagnostic)]
708#[suggestion(
709    ast_passes_suggestion,
710    code = "{param}: {path}",
711    style = "verbose",
712    applicability = "maybe-incorrect"
713)]
714pub(crate) struct AssociatedSuggestion {
715    #[primary_span]
716    pub span: Span,
717    pub ident: Ident,
718    pub param: Ident,
719    pub path: String,
720}
721
722#[derive(Subdiagnostic)]
723#[multipart_suggestion(ast_passes_suggestion_path, applicability = "maybe-incorrect")]
724pub(crate) struct AssociatedSuggestion2 {
725    #[suggestion_part(code = "{args}")]
726    pub span: Span,
727    pub args: String,
728    #[suggestion_part(code = "")]
729    pub predicate: Span,
730    pub trait_segment: Ident,
731    pub potential_assoc: Ident,
732}
733
734#[derive(Diagnostic)]
735#[diag(ast_passes_feature_on_non_nightly, code = E0554)]
736pub(crate) struct FeatureOnNonNightly {
737    #[primary_span]
738    pub span: Span,
739    pub channel: &'static str,
740    #[subdiagnostic]
741    pub stable_features: Vec<StableFeature>,
742    #[suggestion(code = "", applicability = "machine-applicable")]
743    pub sugg: Option<Span>,
744}
745
746pub(crate) struct StableFeature {
747    pub name: Symbol,
748    pub since: Symbol,
749}
750
751impl Subdiagnostic for StableFeature {
752    fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
753        self,
754        diag: &mut Diag<'_, G>,
755        _: &F,
756    ) {
757        diag.arg("name", self.name);
758        diag.arg("since", self.since);
759        diag.help(fluent::ast_passes_stable_since);
760    }
761}
762
763#[derive(Diagnostic)]
764#[diag(ast_passes_incompatible_features)]
765#[help]
766pub(crate) struct IncompatibleFeatures {
767    #[primary_span]
768    pub spans: Vec<Span>,
769    pub f1: Symbol,
770    pub f2: Symbol,
771}
772
773#[derive(Diagnostic)]
774#[diag(ast_passes_negative_bound_not_supported)]
775pub(crate) struct NegativeBoundUnsupported {
776    #[primary_span]
777    pub span: Span,
778}
779
780#[derive(Diagnostic)]
781#[diag(ast_passes_constraint_on_negative_bound)]
782pub(crate) struct ConstraintOnNegativeBound {
783    #[primary_span]
784    pub span: Span,
785}
786
787#[derive(Diagnostic)]
788#[diag(ast_passes_negative_bound_with_parenthetical_notation)]
789pub(crate) struct NegativeBoundWithParentheticalNotation {
790    #[primary_span]
791    pub span: Span,
792}
793
794#[derive(Diagnostic)]
795#[diag(ast_passes_match_arm_with_no_body)]
796pub(crate) struct MatchArmWithNoBody {
797    #[primary_span]
798    pub span: Span,
799    // We include the braces around `todo!()` so that a comma is optional, and we don't have to have
800    // any logic looking at the arm being replaced if there was a comma already or not for the
801    // resulting code to be correct.
802    #[suggestion(
803        code = " => {{ todo!() }}",
804        applicability = "has-placeholders",
805        style = "verbose"
806    )]
807    pub suggestion: Span,
808}
809
810#[derive(Diagnostic)]
811#[diag(ast_passes_precise_capturing_not_allowed_here)]
812pub(crate) struct PreciseCapturingNotAllowedHere {
813    #[primary_span]
814    pub span: Span,
815    pub loc: &'static str,
816}
817
818#[derive(Diagnostic)]
819#[diag(ast_passes_precise_capturing_duplicated)]
820pub(crate) struct DuplicatePreciseCapturing {
821    #[primary_span]
822    pub bound1: Span,
823    #[label]
824    pub bound2: Span,
825}