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