]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_passes/src/errors.rs
68103608ec9d9f16606ff8b71bffcd769e209c53
[rust.git] / compiler / rustc_passes / src / errors.rs
1 use std::{
2     io::Error,
3     path::{Path, PathBuf},
4 };
5
6 use rustc_ast::Label;
7 use rustc_errors::{
8     error_code, Applicability, DiagnosticSymbolList, ErrorGuaranteed, IntoDiagnostic, MultiSpan,
9 };
10 use rustc_hir::{self as hir, ExprKind, Target};
11 use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
12 use rustc_middle::ty::{MainDefinition, Ty};
13 use rustc_span::{Span, Symbol, DUMMY_SP};
14
15 use crate::check_attr::ProcMacroKind;
16 use crate::lang_items::Duplicate;
17
18 #[derive(LintDiagnostic)]
19 #[diag(passes_outer_crate_level_attr)]
20 pub struct OuterCrateLevelAttr;
21
22 #[derive(LintDiagnostic)]
23 #[diag(passes_inner_crate_level_attr)]
24 pub struct InnerCrateLevelAttr;
25
26 #[derive(LintDiagnostic)]
27 #[diag(passes_ignored_attr_with_macro)]
28 pub struct IgnoredAttrWithMacro<'a> {
29     pub sym: &'a str,
30 }
31
32 #[derive(LintDiagnostic)]
33 #[diag(passes_ignored_attr)]
34 pub struct IgnoredAttr<'a> {
35     pub sym: &'a str,
36 }
37
38 #[derive(LintDiagnostic)]
39 #[diag(passes_inline_ignored_function_prototype)]
40 pub struct IgnoredInlineAttrFnProto;
41
42 #[derive(LintDiagnostic)]
43 #[diag(passes_inline_ignored_constants)]
44 #[warning]
45 #[note]
46 pub struct IgnoredInlineAttrConstants;
47
48 #[derive(Diagnostic)]
49 #[diag(passes_inline_not_fn_or_closure, code = "E0518")]
50 pub struct InlineNotFnOrClosure {
51     #[primary_span]
52     pub attr_span: Span,
53     #[label]
54     pub defn_span: Span,
55 }
56
57 #[derive(LintDiagnostic)]
58 #[diag(passes_no_coverage_ignored_function_prototype)]
59 pub struct IgnoredNoCoverageFnProto;
60
61 #[derive(LintDiagnostic)]
62 #[diag(passes_no_coverage_propagate)]
63 pub struct IgnoredNoCoveragePropagate;
64
65 #[derive(LintDiagnostic)]
66 #[diag(passes_no_coverage_fn_defn)]
67 pub struct IgnoredNoCoverageFnDefn;
68
69 #[derive(Diagnostic)]
70 #[diag(passes_no_coverage_not_coverable, code = "E0788")]
71 pub struct IgnoredNoCoverageNotCoverable {
72     #[primary_span]
73     pub attr_span: Span,
74     #[label]
75     pub defn_span: Span,
76 }
77
78 #[derive(Diagnostic)]
79 #[diag(passes_should_be_applied_to_fn)]
80 pub struct AttrShouldBeAppliedToFn {
81     #[primary_span]
82     pub attr_span: Span,
83     #[label]
84     pub defn_span: Span,
85     pub on_crate: bool,
86 }
87
88 #[derive(Diagnostic)]
89 #[diag(passes_naked_tracked_caller, code = "E0736")]
90 pub struct NakedTrackedCaller {
91     #[primary_span]
92     pub attr_span: Span,
93 }
94
95 #[derive(Diagnostic)]
96 #[diag(passes_should_be_applied_to_fn, code = "E0739")]
97 pub struct TrackedCallerWrongLocation {
98     #[primary_span]
99     pub attr_span: Span,
100     #[label]
101     pub defn_span: Span,
102     pub on_crate: bool,
103 }
104
105 #[derive(Diagnostic)]
106 #[diag(passes_should_be_applied_to_struct_enum, code = "E0701")]
107 pub struct NonExhaustiveWrongLocation {
108     #[primary_span]
109     pub attr_span: Span,
110     #[label]
111     pub defn_span: Span,
112 }
113
114 #[derive(Diagnostic)]
115 #[diag(passes_should_be_applied_to_trait)]
116 pub struct AttrShouldBeAppliedToTrait {
117     #[primary_span]
118     pub attr_span: Span,
119     #[label]
120     pub defn_span: Span,
121 }
122
123 #[derive(LintDiagnostic)]
124 #[diag(passes_target_feature_on_statement)]
125 pub struct TargetFeatureOnStatement;
126
127 #[derive(Diagnostic)]
128 #[diag(passes_should_be_applied_to_static)]
129 pub struct AttrShouldBeAppliedToStatic {
130     #[primary_span]
131     pub attr_span: Span,
132     #[label]
133     pub defn_span: Span,
134 }
135
136 #[derive(Diagnostic)]
137 #[diag(passes_doc_expect_str)]
138 pub struct DocExpectStr<'a> {
139     #[primary_span]
140     pub attr_span: Span,
141     pub attr_name: &'a str,
142 }
143
144 #[derive(Diagnostic)]
145 #[diag(passes_doc_alias_empty)]
146 pub struct DocAliasEmpty<'a> {
147     #[primary_span]
148     pub span: Span,
149     pub attr_str: &'a str,
150 }
151
152 #[derive(Diagnostic)]
153 #[diag(passes_doc_alias_bad_char)]
154 pub struct DocAliasBadChar<'a> {
155     #[primary_span]
156     pub span: Span,
157     pub attr_str: &'a str,
158     pub char_: char,
159 }
160
161 #[derive(Diagnostic)]
162 #[diag(passes_doc_alias_start_end)]
163 pub struct DocAliasStartEnd<'a> {
164     #[primary_span]
165     pub span: Span,
166     pub attr_str: &'a str,
167 }
168
169 #[derive(Diagnostic)]
170 #[diag(passes_doc_alias_bad_location)]
171 pub struct DocAliasBadLocation<'a> {
172     #[primary_span]
173     pub span: Span,
174     pub attr_str: &'a str,
175     pub location: &'a str,
176 }
177
178 #[derive(Diagnostic)]
179 #[diag(passes_doc_alias_not_an_alias)]
180 pub struct DocAliasNotAnAlias<'a> {
181     #[primary_span]
182     pub span: Span,
183     pub attr_str: &'a str,
184 }
185
186 #[derive(LintDiagnostic)]
187 #[diag(passes_doc_alias_duplicated)]
188 pub struct DocAliasDuplicated {
189     #[label]
190     pub first_defn: Span,
191 }
192
193 #[derive(Diagnostic)]
194 #[diag(passes_doc_alias_not_string_literal)]
195 pub struct DocAliasNotStringLiteral {
196     #[primary_span]
197     pub span: Span,
198 }
199
200 #[derive(Diagnostic)]
201 #[diag(passes_doc_alias_malformed)]
202 pub struct DocAliasMalformed {
203     #[primary_span]
204     pub span: Span,
205 }
206
207 #[derive(Diagnostic)]
208 #[diag(passes_doc_keyword_empty_mod)]
209 pub struct DocKeywordEmptyMod {
210     #[primary_span]
211     pub span: Span,
212 }
213
214 #[derive(Diagnostic)]
215 #[diag(passes_doc_keyword_not_mod)]
216 pub struct DocKeywordNotMod {
217     #[primary_span]
218     pub span: Span,
219 }
220
221 #[derive(Diagnostic)]
222 #[diag(passes_doc_keyword_invalid_ident)]
223 pub struct DocKeywordInvalidIdent {
224     #[primary_span]
225     pub span: Span,
226     pub doc_keyword: Symbol,
227 }
228
229 #[derive(Diagnostic)]
230 #[diag(passes_doc_fake_variadic_not_valid)]
231 pub struct DocFakeVariadicNotValid {
232     #[primary_span]
233     pub span: Span,
234 }
235
236 #[derive(Diagnostic)]
237 #[diag(passes_doc_keyword_only_impl)]
238 pub struct DocKeywordOnlyImpl {
239     #[primary_span]
240     pub span: Span,
241 }
242
243 #[derive(Diagnostic)]
244 #[diag(passes_doc_inline_conflict)]
245 #[help]
246 pub struct DocKeywordConflict {
247     #[primary_span]
248     pub spans: MultiSpan,
249 }
250
251 #[derive(LintDiagnostic)]
252 #[diag(passes_doc_inline_only_use)]
253 #[note]
254 pub struct DocInlineOnlyUse {
255     #[label]
256     pub attr_span: Span,
257     #[label(not_a_use_item_label)]
258     pub item_span: Option<Span>,
259 }
260
261 #[derive(Diagnostic)]
262 #[diag(passes_doc_attr_not_crate_level)]
263 pub struct DocAttrNotCrateLevel<'a> {
264     #[primary_span]
265     pub span: Span,
266     pub attr_name: &'a str,
267 }
268
269 #[derive(LintDiagnostic)]
270 #[diag(passes_doc_test_unknown)]
271 pub struct DocTestUnknown {
272     pub path: String,
273 }
274
275 #[derive(LintDiagnostic)]
276 #[diag(passes_doc_test_takes_list)]
277 pub struct DocTestTakesList;
278
279 #[derive(LintDiagnostic)]
280 #[diag(passes_doc_cfg_hide_takes_list)]
281 pub struct DocCfgHideTakesList;
282
283 #[derive(LintDiagnostic)]
284 #[diag(passes_doc_primitive)]
285 pub struct DocPrimitive;
286
287 #[derive(LintDiagnostic)]
288 #[diag(passes_doc_test_unknown_any)]
289 pub struct DocTestUnknownAny {
290     pub path: String,
291 }
292
293 #[derive(LintDiagnostic)]
294 #[diag(passes_doc_test_unknown_spotlight)]
295 #[note]
296 #[note(no_op_note)]
297 pub struct DocTestUnknownSpotlight {
298     pub path: String,
299     #[suggestion(style = "short", applicability = "machine-applicable", code = "notable_trait")]
300     pub span: Span,
301 }
302
303 #[derive(LintDiagnostic)]
304 #[diag(passes_doc_test_unknown_include)]
305 pub struct DocTestUnknownInclude {
306     pub path: String,
307     pub value: String,
308     pub inner: &'static str,
309     #[suggestion(code = "#{inner}[doc = include_str!(\"{value}\")]")]
310     pub sugg: (Span, Applicability),
311 }
312
313 #[derive(LintDiagnostic)]
314 #[diag(passes_doc_invalid)]
315 pub struct DocInvalid;
316
317 #[derive(Diagnostic)]
318 #[diag(passes_pass_by_value)]
319 pub struct PassByValue {
320     #[primary_span]
321     pub attr_span: Span,
322     #[label]
323     pub span: Span,
324 }
325
326 #[derive(Diagnostic)]
327 #[diag(passes_allow_incoherent_impl)]
328 pub struct AllowIncoherentImpl {
329     #[primary_span]
330     pub attr_span: Span,
331     #[label]
332     pub span: Span,
333 }
334
335 #[derive(Diagnostic)]
336 #[diag(passes_has_incoherent_inherent_impl)]
337 pub struct HasIncoherentInherentImpl {
338     #[primary_span]
339     pub attr_span: Span,
340     #[label]
341     pub span: Span,
342 }
343
344 #[derive(LintDiagnostic)]
345 #[diag(passes_must_use_async)]
346 pub struct MustUseAsync {
347     #[label]
348     pub span: Span,
349 }
350
351 #[derive(LintDiagnostic)]
352 #[diag(passes_must_use_no_effect)]
353 pub struct MustUseNoEffect {
354     pub article: &'static str,
355     pub target: rustc_hir::Target,
356 }
357
358 #[derive(Diagnostic)]
359 #[diag(passes_must_not_suspend)]
360 pub struct MustNotSuspend {
361     #[primary_span]
362     pub attr_span: Span,
363     #[label]
364     pub span: Span,
365 }
366
367 #[derive(LintDiagnostic)]
368 #[diag(passes_cold)]
369 #[warning]
370 pub struct Cold {
371     #[label]
372     pub span: Span,
373     pub on_crate: bool,
374 }
375
376 #[derive(LintDiagnostic)]
377 #[diag(passes_link)]
378 #[warning]
379 pub struct Link {
380     #[label]
381     pub span: Option<Span>,
382 }
383
384 #[derive(LintDiagnostic)]
385 #[diag(passes_link_name)]
386 #[warning]
387 pub struct LinkName<'a> {
388     #[help]
389     pub attr_span: Option<Span>,
390     #[label]
391     pub span: Span,
392     pub value: &'a str,
393 }
394
395 #[derive(Diagnostic)]
396 #[diag(passes_no_link)]
397 pub struct NoLink {
398     #[primary_span]
399     pub attr_span: Span,
400     #[label]
401     pub span: Span,
402 }
403
404 #[derive(Diagnostic)]
405 #[diag(passes_export_name)]
406 pub struct ExportName {
407     #[primary_span]
408     pub attr_span: Span,
409     #[label]
410     pub span: Span,
411 }
412
413 #[derive(Diagnostic)]
414 #[diag(passes_rustc_layout_scalar_valid_range_not_struct)]
415 pub struct RustcLayoutScalarValidRangeNotStruct {
416     #[primary_span]
417     pub attr_span: Span,
418     #[label]
419     pub span: Span,
420 }
421
422 #[derive(Diagnostic)]
423 #[diag(passes_rustc_layout_scalar_valid_range_arg)]
424 pub struct RustcLayoutScalarValidRangeArg {
425     #[primary_span]
426     pub attr_span: Span,
427 }
428
429 #[derive(Diagnostic)]
430 #[diag(passes_rustc_legacy_const_generics_only)]
431 pub struct RustcLegacyConstGenericsOnly {
432     #[primary_span]
433     pub attr_span: Span,
434     #[label]
435     pub param_span: Span,
436 }
437
438 #[derive(Diagnostic)]
439 #[diag(passes_rustc_legacy_const_generics_index)]
440 pub struct RustcLegacyConstGenericsIndex {
441     #[primary_span]
442     pub attr_span: Span,
443     #[label]
444     pub generics_span: Span,
445 }
446
447 #[derive(Diagnostic)]
448 #[diag(passes_rustc_legacy_const_generics_index_exceed)]
449 pub struct RustcLegacyConstGenericsIndexExceed {
450     #[primary_span]
451     #[label]
452     pub span: Span,
453     pub arg_count: usize,
454 }
455
456 #[derive(Diagnostic)]
457 #[diag(passes_rustc_legacy_const_generics_index_negative)]
458 pub struct RustcLegacyConstGenericsIndexNegative {
459     #[primary_span]
460     pub invalid_args: Vec<Span>,
461 }
462
463 #[derive(Diagnostic)]
464 #[diag(passes_rustc_dirty_clean)]
465 pub struct RustcDirtyClean {
466     #[primary_span]
467     pub span: Span,
468 }
469
470 #[derive(LintDiagnostic)]
471 #[diag(passes_link_section)]
472 #[warning]
473 pub struct LinkSection {
474     #[label]
475     pub span: Span,
476 }
477
478 #[derive(LintDiagnostic)]
479 #[diag(passes_no_mangle_foreign)]
480 #[warning]
481 #[note]
482 pub struct NoMangleForeign {
483     #[label]
484     pub span: Span,
485     #[suggestion(code = "", applicability = "machine-applicable")]
486     pub attr_span: Span,
487     pub foreign_item_kind: &'static str,
488 }
489
490 #[derive(LintDiagnostic)]
491 #[diag(passes_no_mangle)]
492 #[warning]
493 pub struct NoMangle {
494     #[label]
495     pub span: Span,
496 }
497
498 #[derive(Diagnostic)]
499 #[diag(passes_repr_ident, code = "E0565")]
500 pub struct ReprIdent {
501     #[primary_span]
502     pub span: Span,
503 }
504
505 #[derive(LintDiagnostic)]
506 #[diag(passes_repr_conflicting, code = "E0566")]
507 pub struct ReprConflicting;
508
509 #[derive(Diagnostic)]
510 #[diag(passes_used_static)]
511 pub struct UsedStatic {
512     #[primary_span]
513     pub span: Span,
514 }
515
516 #[derive(Diagnostic)]
517 #[diag(passes_used_compiler_linker)]
518 pub struct UsedCompilerLinker {
519     #[primary_span]
520     pub spans: Vec<Span>,
521 }
522
523 #[derive(Diagnostic)]
524 #[diag(passes_allow_internal_unstable)]
525 pub struct AllowInternalUnstable {
526     #[primary_span]
527     pub attr_span: Span,
528     #[label]
529     pub span: Span,
530 }
531
532 #[derive(Diagnostic)]
533 #[diag(passes_debug_visualizer_placement)]
534 pub struct DebugVisualizerPlacement {
535     #[primary_span]
536     pub span: Span,
537 }
538
539 #[derive(Diagnostic)]
540 #[diag(passes_debug_visualizer_invalid)]
541 #[note(note_1)]
542 #[note(note_2)]
543 #[note(note_3)]
544 pub struct DebugVisualizerInvalid {
545     #[primary_span]
546     pub span: Span,
547 }
548
549 #[derive(Diagnostic)]
550 #[diag(passes_debug_visualizer_unreadable)]
551 pub struct DebugVisualizerUnreadable<'a> {
552     #[primary_span]
553     pub span: Span,
554     pub file: &'a Path,
555     pub error: Error,
556 }
557
558 #[derive(Diagnostic)]
559 #[diag(passes_rustc_allow_const_fn_unstable)]
560 pub struct RustcAllowConstFnUnstable {
561     #[primary_span]
562     pub attr_span: Span,
563     #[label]
564     pub span: Span,
565 }
566
567 #[derive(Diagnostic)]
568 #[diag(passes_rustc_std_internal_symbol)]
569 pub struct RustcStdInternalSymbol {
570     #[primary_span]
571     pub attr_span: Span,
572     #[label]
573     pub span: Span,
574 }
575
576 #[derive(Diagnostic)]
577 #[diag(passes_const_trait)]
578 pub struct ConstTrait {
579     #[primary_span]
580     pub attr_span: Span,
581 }
582
583 #[derive(Diagnostic)]
584 #[diag(passes_link_ordinal)]
585 pub struct LinkOrdinal {
586     #[primary_span]
587     pub attr_span: Span,
588 }
589
590 #[derive(Diagnostic)]
591 #[diag(passes_stability_promotable)]
592 pub struct StabilityPromotable {
593     #[primary_span]
594     pub attr_span: Span,
595 }
596
597 #[derive(LintDiagnostic)]
598 #[diag(passes_deprecated)]
599 pub struct Deprecated;
600
601 #[derive(LintDiagnostic)]
602 #[diag(passes_macro_use)]
603 pub struct MacroUse {
604     pub name: Symbol,
605 }
606
607 #[derive(LintDiagnostic)]
608 #[diag(passes_macro_export)]
609 pub struct MacroExport;
610
611 #[derive(LintDiagnostic)]
612 #[diag(passes_plugin_registrar)]
613 pub struct PluginRegistrar;
614
615 #[derive(Subdiagnostic)]
616 pub enum UnusedNote {
617     #[note(passes_unused_empty_lints_note)]
618     EmptyList { name: Symbol },
619     #[note(passes_unused_no_lints_note)]
620     NoLints { name: Symbol },
621     #[note(passes_unused_default_method_body_const_note)]
622     DefaultMethodBodyConst,
623 }
624
625 #[derive(LintDiagnostic)]
626 #[diag(passes_unused)]
627 pub struct Unused {
628     #[suggestion(code = "", applicability = "machine-applicable")]
629     pub attr_span: Span,
630     #[subdiagnostic]
631     pub note: UnusedNote,
632 }
633
634 #[derive(Diagnostic)]
635 #[diag(passes_non_exported_macro_invalid_attrs, code = "E0518")]
636 pub struct NonExportedMacroInvalidAttrs {
637     #[primary_span]
638     #[label]
639     pub attr_span: Span,
640 }
641
642 #[derive(LintDiagnostic)]
643 #[diag(passes_unused_duplicate)]
644 pub struct UnusedDuplicate {
645     #[suggestion(code = "", applicability = "machine-applicable")]
646     pub this: Span,
647     #[note]
648     pub other: Span,
649     #[warning]
650     pub warning: Option<()>,
651 }
652
653 #[derive(Diagnostic)]
654 #[diag(passes_unused_multiple)]
655 pub struct UnusedMultiple {
656     #[primary_span]
657     #[suggestion(code = "", applicability = "machine-applicable")]
658     pub this: Span,
659     #[note]
660     pub other: Span,
661     pub name: Symbol,
662 }
663
664 #[derive(Diagnostic)]
665 #[diag(passes_rustc_lint_opt_ty)]
666 pub struct RustcLintOptTy {
667     #[primary_span]
668     pub attr_span: Span,
669     #[label]
670     pub span: Span,
671 }
672
673 #[derive(Diagnostic)]
674 #[diag(passes_rustc_lint_opt_deny_field_access)]
675 pub struct RustcLintOptDenyFieldAccess {
676     #[primary_span]
677     pub attr_span: Span,
678     #[label]
679     pub span: Span,
680 }
681
682 #[derive(Diagnostic)]
683 #[diag(passes_collapse_debuginfo)]
684 pub struct CollapseDebuginfo {
685     #[primary_span]
686     pub attr_span: Span,
687     #[label]
688     pub defn_span: Span,
689 }
690
691 #[derive(LintDiagnostic)]
692 #[diag(passes_deprecated_annotation_has_no_effect)]
693 pub struct DeprecatedAnnotationHasNoEffect {
694     #[suggestion(applicability = "machine-applicable", code = "")]
695     pub span: Span,
696 }
697
698 #[derive(Diagnostic)]
699 #[diag(passes_unknown_external_lang_item, code = "E0264")]
700 pub struct UnknownExternLangItem {
701     #[primary_span]
702     pub span: Span,
703     pub lang_item: Symbol,
704 }
705
706 #[derive(Diagnostic)]
707 #[diag(passes_missing_panic_handler)]
708 pub struct MissingPanicHandler;
709
710 #[derive(Diagnostic)]
711 #[diag(passes_missing_lang_item)]
712 #[note]
713 #[help]
714 pub struct MissingLangItem {
715     pub name: Symbol,
716 }
717
718 #[derive(Diagnostic)]
719 #[diag(passes_lang_item_on_incorrect_target, code = "E0718")]
720 pub struct LangItemOnIncorrectTarget {
721     #[primary_span]
722     #[label]
723     pub span: Span,
724     pub name: Symbol,
725     pub expected_target: Target,
726     pub actual_target: Target,
727 }
728
729 #[derive(Diagnostic)]
730 #[diag(passes_unknown_lang_item, code = "E0522")]
731 pub struct UnknownLangItem {
732     #[primary_span]
733     #[label]
734     pub span: Span,
735     pub name: Symbol,
736 }
737
738 pub struct InvalidAttrAtCrateLevel {
739     pub span: Span,
740     pub snippet: Option<String>,
741     pub name: Symbol,
742 }
743
744 impl IntoDiagnostic<'_> for InvalidAttrAtCrateLevel {
745     #[track_caller]
746     fn into_diagnostic(
747         self,
748         handler: &'_ rustc_errors::Handler,
749     ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
750         let mut diag = handler.struct_err(rustc_errors::fluent::passes_invalid_attr_at_crate_level);
751         diag.set_span(self.span);
752         diag.set_arg("name", self.name);
753         // Only emit an error with a suggestion if we can create a string out
754         // of the attribute span
755         if let Some(src) = self.snippet {
756             let replacement = src.replace("#!", "#");
757             diag.span_suggestion_verbose(
758                 self.span,
759                 rustc_errors::fluent::suggestion,
760                 replacement,
761                 rustc_errors::Applicability::MachineApplicable,
762             );
763         }
764         diag
765     }
766 }
767
768 #[derive(Diagnostic)]
769 #[diag(passes_duplicate_diagnostic_item)]
770 pub struct DuplicateDiagnosticItem {
771     #[primary_span]
772     pub span: Span,
773     pub name: Symbol,
774 }
775
776 #[derive(Diagnostic)]
777 #[diag(passes_duplicate_diagnostic_item_in_crate)]
778 pub struct DuplicateDiagnosticItemInCrate {
779     #[note(passes_diagnostic_item_first_defined)]
780     pub span: Option<Span>,
781     pub orig_crate_name: Symbol,
782     #[note]
783     pub have_orig_crate_name: Option<()>,
784     pub crate_name: Symbol,
785     pub name: Symbol,
786 }
787
788 #[derive(Diagnostic)]
789 #[diag(passes_abi)]
790 pub struct Abi {
791     #[primary_span]
792     pub span: Span,
793     pub abi: String,
794 }
795
796 #[derive(Diagnostic)]
797 #[diag(passes_align)]
798 pub struct Align {
799     #[primary_span]
800     pub span: Span,
801     pub align: String,
802 }
803
804 #[derive(Diagnostic)]
805 #[diag(passes_size)]
806 pub struct Size {
807     #[primary_span]
808     pub span: Span,
809     pub size: String,
810 }
811
812 #[derive(Diagnostic)]
813 #[diag(passes_homogeneous_aggregate)]
814 pub struct HomogeneousAggregate {
815     #[primary_span]
816     pub span: Span,
817     pub homogeneous_aggregate: String,
818 }
819
820 #[derive(Diagnostic)]
821 #[diag(passes_layout_of)]
822 pub struct LayoutOf {
823     #[primary_span]
824     pub span: Span,
825     pub normalized_ty: String,
826     pub ty_layout: String,
827 }
828
829 #[derive(Diagnostic)]
830 #[diag(passes_unrecognized_field)]
831 pub struct UnrecognizedField {
832     #[primary_span]
833     pub span: Span,
834     pub name: Symbol,
835 }
836
837 #[derive(Diagnostic)]
838 #[diag(passes_feature_stable_twice, code = "E0711")]
839 pub struct FeatureStableTwice {
840     #[primary_span]
841     pub span: Span,
842     pub feature: Symbol,
843     pub since: Symbol,
844     pub prev_since: Symbol,
845 }
846
847 #[derive(Diagnostic)]
848 #[diag(passes_feature_previously_declared, code = "E0711")]
849 pub struct FeaturePreviouslyDeclared<'a, 'b> {
850     #[primary_span]
851     pub span: Span,
852     pub feature: Symbol,
853     pub declared: &'a str,
854     pub prev_declared: &'b str,
855 }
856
857 #[derive(Diagnostic)]
858 #[diag(passes_expr_not_allowed_in_context, code = "E0744")]
859 pub struct ExprNotAllowedInContext<'a> {
860     #[primary_span]
861     pub span: Span,
862     pub expr: String,
863     pub context: &'a str,
864 }
865
866 pub struct BreakNonLoop<'a> {
867     pub span: Span,
868     pub head: Option<Span>,
869     pub kind: &'a str,
870     pub suggestion: String,
871     pub loop_label: Option<Label>,
872     pub break_label: Option<Label>,
873     pub break_expr_kind: &'a ExprKind<'a>,
874     pub break_expr_span: Span,
875 }
876
877 impl<'a> IntoDiagnostic<'_> for BreakNonLoop<'a> {
878     #[track_caller]
879     fn into_diagnostic(
880         self,
881         handler: &rustc_errors::Handler,
882     ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
883         let mut diag = handler.struct_span_err_with_code(
884             self.span,
885             rustc_errors::fluent::passes_break_non_loop,
886             error_code!(E0571),
887         );
888         diag.set_arg("kind", self.kind);
889         diag.span_label(self.span, rustc_errors::fluent::label);
890         if let Some(head) = self.head {
891             diag.span_label(head, rustc_errors::fluent::label2);
892         }
893         diag.span_suggestion(
894             self.span,
895             rustc_errors::fluent::suggestion,
896             self.suggestion,
897             Applicability::MaybeIncorrect,
898         );
899         if let (Some(label), None) = (self.loop_label, self.break_label) {
900             match self.break_expr_kind {
901                 ExprKind::Path(hir::QPath::Resolved(
902                     None,
903                     hir::Path { segments: [segment], res: hir::def::Res::Err, .. },
904                 )) if label.ident.to_string() == format!("'{}", segment.ident) => {
905                     // This error is redundant, we will have already emitted a
906                     // suggestion to use the label when `segment` wasn't found
907                     // (hence the `Res::Err` check).
908                     diag.delay_as_bug();
909                 }
910                 _ => {
911                     diag.span_suggestion(
912                         self.break_expr_span,
913                         rustc_errors::fluent::break_expr_suggestion,
914                         label.ident,
915                         Applicability::MaybeIncorrect,
916                     );
917                 }
918             }
919         }
920         diag
921     }
922 }
923
924 #[derive(Diagnostic)]
925 #[diag(passes_continue_labeled_block, code = "E0696")]
926 pub struct ContinueLabeledBlock {
927     #[primary_span]
928     #[label]
929     pub span: Span,
930     #[label(block_label)]
931     pub block_span: Span,
932 }
933
934 #[derive(Diagnostic)]
935 #[diag(passes_break_inside_closure, code = "E0267")]
936 pub struct BreakInsideClosure<'a> {
937     #[primary_span]
938     #[label]
939     pub span: Span,
940     #[label(closure_label)]
941     pub closure_span: Span,
942     pub name: &'a str,
943 }
944
945 #[derive(Diagnostic)]
946 #[diag(passes_break_inside_async_block, code = "E0267")]
947 pub struct BreakInsideAsyncBlock<'a> {
948     #[primary_span]
949     #[label]
950     pub span: Span,
951     #[label(async_block_label)]
952     pub closure_span: Span,
953     pub name: &'a str,
954 }
955
956 #[derive(Diagnostic)]
957 #[diag(passes_outside_loop, code = "E0268")]
958 pub struct OutsideLoop<'a> {
959     #[primary_span]
960     #[label]
961     pub span: Span,
962     pub name: &'a str,
963     pub is_break: bool,
964 }
965
966 #[derive(Diagnostic)]
967 #[diag(passes_unlabeled_in_labeled_block, code = "E0695")]
968 pub struct UnlabeledInLabeledBlock<'a> {
969     #[primary_span]
970     #[label]
971     pub span: Span,
972     pub cf_type: &'a str,
973 }
974
975 #[derive(Diagnostic)]
976 #[diag(passes_unlabeled_cf_in_while_condition, code = "E0590")]
977 pub struct UnlabeledCfInWhileCondition<'a> {
978     #[primary_span]
979     #[label]
980     pub span: Span,
981     pub cf_type: &'a str,
982 }
983
984 #[derive(Diagnostic)]
985 #[diag(passes_cannot_inline_naked_function)]
986 pub struct CannotInlineNakedFunction {
987     #[primary_span]
988     pub span: Span,
989 }
990
991 #[derive(LintDiagnostic)]
992 #[diag(passes_undefined_naked_function_abi)]
993 pub struct UndefinedNakedFunctionAbi;
994
995 #[derive(Diagnostic)]
996 #[diag(passes_no_patterns)]
997 pub struct NoPatterns {
998     #[primary_span]
999     pub span: Span,
1000 }
1001
1002 #[derive(Diagnostic)]
1003 #[diag(passes_params_not_allowed)]
1004 #[help]
1005 pub struct ParamsNotAllowed {
1006     #[primary_span]
1007     pub span: Span,
1008 }
1009
1010 pub struct NakedFunctionsAsmBlock {
1011     pub span: Span,
1012     pub multiple_asms: Vec<Span>,
1013     pub non_asms: Vec<Span>,
1014 }
1015
1016 impl IntoDiagnostic<'_> for NakedFunctionsAsmBlock {
1017     #[track_caller]
1018     fn into_diagnostic(
1019         self,
1020         handler: &rustc_errors::Handler,
1021     ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
1022         let mut diag = handler.struct_span_err_with_code(
1023             self.span,
1024             rustc_errors::fluent::passes_naked_functions_asm_block,
1025             error_code!(E0787),
1026         );
1027         for span in self.multiple_asms.iter() {
1028             diag.span_label(*span, rustc_errors::fluent::label_multiple_asm);
1029         }
1030         for span in self.non_asms.iter() {
1031             diag.span_label(*span, rustc_errors::fluent::label_non_asm);
1032         }
1033         diag
1034     }
1035 }
1036
1037 #[derive(Diagnostic)]
1038 #[diag(passes_naked_functions_operands, code = "E0787")]
1039 pub struct NakedFunctionsOperands {
1040     #[primary_span]
1041     pub unsupported_operands: Vec<Span>,
1042 }
1043
1044 #[derive(Diagnostic)]
1045 #[diag(passes_naked_functions_asm_options, code = "E0787")]
1046 pub struct NakedFunctionsAsmOptions {
1047     #[primary_span]
1048     pub span: Span,
1049     pub unsupported_options: String,
1050 }
1051
1052 #[derive(Diagnostic)]
1053 #[diag(passes_naked_functions_must_use_noreturn, code = "E0787")]
1054 pub struct NakedFunctionsMustUseNoreturn {
1055     #[primary_span]
1056     pub span: Span,
1057     #[suggestion(code = ", options(noreturn)", applicability = "machine-applicable")]
1058     pub last_span: Span,
1059 }
1060
1061 #[derive(Diagnostic)]
1062 #[diag(passes_attr_only_on_main)]
1063 pub struct AttrOnlyOnMain {
1064     #[primary_span]
1065     pub span: Span,
1066     pub attr: Symbol,
1067 }
1068
1069 #[derive(Diagnostic)]
1070 #[diag(passes_attr_only_on_root_main)]
1071 pub struct AttrOnlyOnRootMain {
1072     #[primary_span]
1073     pub span: Span,
1074     pub attr: Symbol,
1075 }
1076
1077 #[derive(Diagnostic)]
1078 #[diag(passes_attr_only_in_functions)]
1079 pub struct AttrOnlyInFunctions {
1080     #[primary_span]
1081     pub span: Span,
1082     pub attr: Symbol,
1083 }
1084
1085 #[derive(Diagnostic)]
1086 #[diag(passes_multiple_rustc_main, code = "E0137")]
1087 pub struct MultipleRustcMain {
1088     #[primary_span]
1089     pub span: Span,
1090     #[label(first)]
1091     pub first: Span,
1092     #[label(additional)]
1093     pub additional: Span,
1094 }
1095
1096 #[derive(Diagnostic)]
1097 #[diag(passes_multiple_start_functions, code = "E0138")]
1098 pub struct MultipleStartFunctions {
1099     #[primary_span]
1100     pub span: Span,
1101     #[label]
1102     pub labeled: Span,
1103     #[label(previous)]
1104     pub previous: Span,
1105 }
1106
1107 #[derive(Diagnostic)]
1108 #[diag(passes_extern_main)]
1109 pub struct ExternMain {
1110     #[primary_span]
1111     pub span: Span,
1112 }
1113
1114 #[derive(Diagnostic)]
1115 #[diag(passes_unix_sigpipe_values)]
1116 pub struct UnixSigpipeValues {
1117     #[primary_span]
1118     pub span: Span,
1119 }
1120
1121 #[derive(Diagnostic)]
1122 #[diag(passes_no_main_function, code = "E0601")]
1123 pub struct NoMainFunction {
1124     #[primary_span]
1125     pub span: Span,
1126     pub crate_name: String,
1127 }
1128
1129 pub struct NoMainErr {
1130     pub sp: Span,
1131     pub crate_name: Symbol,
1132     pub has_filename: bool,
1133     pub filename: PathBuf,
1134     pub file_empty: bool,
1135     pub non_main_fns: Vec<Span>,
1136     pub main_def_opt: Option<MainDefinition>,
1137     pub add_teach_note: bool,
1138 }
1139
1140 impl<'a> IntoDiagnostic<'a> for NoMainErr {
1141     #[track_caller]
1142     fn into_diagnostic(
1143         self,
1144         handler: &'a rustc_errors::Handler,
1145     ) -> rustc_errors::DiagnosticBuilder<'a, ErrorGuaranteed> {
1146         let mut diag = handler.struct_span_err_with_code(
1147             DUMMY_SP,
1148             rustc_errors::fluent::passes_no_main_function,
1149             error_code!(E0601),
1150         );
1151         diag.set_arg("crate_name", self.crate_name);
1152         diag.set_arg("filename", self.filename);
1153         diag.set_arg("has_filename", self.has_filename);
1154         let note = if !self.non_main_fns.is_empty() {
1155             for &span in &self.non_main_fns {
1156                 diag.span_note(span, rustc_errors::fluent::here_is_main);
1157             }
1158             diag.note(rustc_errors::fluent::one_or_more_possible_main);
1159             diag.help(rustc_errors::fluent::consider_moving_main);
1160             // There were some functions named `main` though. Try to give the user a hint.
1161             rustc_errors::fluent::main_must_be_defined_at_crate
1162         } else if self.has_filename {
1163             rustc_errors::fluent::consider_adding_main_to_file
1164         } else {
1165             rustc_errors::fluent::consider_adding_main_at_crate
1166         };
1167         if self.file_empty {
1168             diag.note(note);
1169         } else {
1170             diag.set_span(self.sp.shrink_to_hi());
1171             diag.span_label(self.sp.shrink_to_hi(), note);
1172         }
1173
1174         if let Some(main_def) = self.main_def_opt && main_def.opt_fn_def_id().is_none(){
1175             // There is something at `crate::main`, but it is not a function definition.
1176             diag.span_label(main_def.span, rustc_errors::fluent::non_function_main);
1177         }
1178
1179         if self.add_teach_note {
1180             diag.note(rustc_errors::fluent::teach_note);
1181         }
1182         diag
1183     }
1184 }
1185
1186 pub struct DuplicateLangItem {
1187     pub local_span: Option<Span>,
1188     pub lang_item_name: Symbol,
1189     pub crate_name: Symbol,
1190     pub dependency_of: Symbol,
1191     pub is_local: bool,
1192     pub path: String,
1193     pub first_defined_span: Option<Span>,
1194     pub orig_crate_name: Symbol,
1195     pub orig_dependency_of: Symbol,
1196     pub orig_is_local: bool,
1197     pub orig_path: String,
1198     pub(crate) duplicate: Duplicate,
1199 }
1200
1201 impl IntoDiagnostic<'_> for DuplicateLangItem {
1202     #[track_caller]
1203     fn into_diagnostic(
1204         self,
1205         handler: &rustc_errors::Handler,
1206     ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
1207         let mut diag = handler.struct_err_with_code(
1208             match self.duplicate {
1209                 Duplicate::Plain => rustc_errors::fluent::passes_duplicate_lang_item,
1210
1211                 Duplicate::Crate => rustc_errors::fluent::passes_duplicate_lang_item_crate,
1212                 Duplicate::CrateDepends => {
1213                     rustc_errors::fluent::passes_duplicate_lang_item_crate_depends
1214                 }
1215             },
1216             error_code!(E0152),
1217         );
1218         diag.set_arg("lang_item_name", self.lang_item_name);
1219         diag.set_arg("crate_name", self.crate_name);
1220         diag.set_arg("dependency_of", self.dependency_of);
1221         diag.set_arg("path", self.path);
1222         diag.set_arg("orig_crate_name", self.orig_crate_name);
1223         diag.set_arg("orig_dependency_of", self.orig_dependency_of);
1224         diag.set_arg("orig_path", self.orig_path);
1225         if let Some(span) = self.local_span {
1226             diag.set_span(span);
1227         }
1228         if let Some(span) = self.first_defined_span {
1229             diag.span_note(span, rustc_errors::fluent::first_defined_span);
1230         } else {
1231             if self.orig_dependency_of.is_empty() {
1232                 diag.note(rustc_errors::fluent::first_defined_crate);
1233             } else {
1234                 diag.note(rustc_errors::fluent::first_defined_crate_depends);
1235             }
1236
1237             if self.orig_is_local {
1238                 diag.note(rustc_errors::fluent::first_definition_local);
1239             } else {
1240                 diag.note(rustc_errors::fluent::first_definition_path);
1241             }
1242
1243             if self.is_local {
1244                 diag.note(rustc_errors::fluent::second_definition_local);
1245             } else {
1246                 diag.note(rustc_errors::fluent::second_definition_path);
1247             }
1248         }
1249         diag
1250     }
1251 }
1252
1253 #[derive(Diagnostic)]
1254 #[diag(passes_incorrect_target, code = "E0718")]
1255 pub struct IncorrectTarget<'a> {
1256     #[primary_span]
1257     pub span: Span,
1258     #[label]
1259     pub generics_span: Span,
1260     pub name: &'a str, // cannot be symbol because it renders e.g. `r#fn` instead of `fn`
1261     pub kind: &'static str,
1262     pub num: usize,
1263     pub actual_num: usize,
1264     pub at_least: bool,
1265 }
1266
1267 #[derive(LintDiagnostic)]
1268 #[diag(passes_useless_assignment)]
1269 pub struct UselessAssignment<'a> {
1270     pub is_field_assign: bool,
1271     pub ty: Ty<'a>,
1272 }
1273
1274 #[derive(LintDiagnostic)]
1275 #[diag(passes_only_has_effect_on)]
1276 pub struct OnlyHasEffectOn {
1277     pub attr_name: Symbol,
1278     pub target_name: String,
1279 }
1280
1281 #[derive(Diagnostic)]
1282 #[diag(passes_object_lifetime_err)]
1283 pub struct ObjectLifetimeErr {
1284     #[primary_span]
1285     pub span: Span,
1286     pub repr: String,
1287 }
1288
1289 #[derive(Diagnostic)]
1290 #[diag(passes_unrecognized_repr_hint, code = "E0552")]
1291 #[help]
1292 pub struct UnrecognizedReprHint {
1293     #[primary_span]
1294     pub span: Span,
1295 }
1296
1297 #[derive(Diagnostic)]
1298 pub enum AttrApplication {
1299     #[diag(passes_attr_application_enum, code = "E0517")]
1300     Enum {
1301         #[primary_span]
1302         hint_span: Span,
1303         #[label]
1304         span: Span,
1305     },
1306     #[diag(passes_attr_application_struct, code = "E0517")]
1307     Struct {
1308         #[primary_span]
1309         hint_span: Span,
1310         #[label]
1311         span: Span,
1312     },
1313     #[diag(passes_attr_application_struct_union, code = "E0517")]
1314     StructUnion {
1315         #[primary_span]
1316         hint_span: Span,
1317         #[label]
1318         span: Span,
1319     },
1320     #[diag(passes_attr_application_struct_enum_union, code = "E0517")]
1321     StructEnumUnion {
1322         #[primary_span]
1323         hint_span: Span,
1324         #[label]
1325         span: Span,
1326     },
1327     #[diag(passes_attr_application_struct_enum_function_union, code = "E0517")]
1328     StructEnumFunctionUnion {
1329         #[primary_span]
1330         hint_span: Span,
1331         #[label]
1332         span: Span,
1333     },
1334 }
1335
1336 #[derive(Diagnostic)]
1337 #[diag(passes_transparent_incompatible, code = "E0692")]
1338 pub struct TransparentIncompatible {
1339     #[primary_span]
1340     pub hint_spans: Vec<Span>,
1341     pub target: String,
1342 }
1343
1344 #[derive(Diagnostic)]
1345 #[diag(passes_deprecated_attribute, code = "E0549")]
1346 pub struct DeprecatedAttribute {
1347     #[primary_span]
1348     pub span: Span,
1349 }
1350
1351 #[derive(Diagnostic)]
1352 #[diag(passes_useless_stability)]
1353 pub struct UselessStability {
1354     #[primary_span]
1355     #[label]
1356     pub span: Span,
1357     #[label(item)]
1358     pub item_sp: Span,
1359 }
1360
1361 #[derive(Diagnostic)]
1362 #[diag(passes_invalid_stability)]
1363 pub struct InvalidStability {
1364     #[primary_span]
1365     #[label]
1366     pub span: Span,
1367     #[label(item)]
1368     pub item_sp: Span,
1369 }
1370
1371 #[derive(Diagnostic)]
1372 #[diag(passes_cannot_stabilize_deprecated)]
1373 pub struct CannotStabilizeDeprecated {
1374     #[primary_span]
1375     #[label]
1376     pub span: Span,
1377     #[label(item)]
1378     pub item_sp: Span,
1379 }
1380
1381 #[derive(Diagnostic)]
1382 #[diag(passes_invalid_deprecation_version)]
1383 pub struct InvalidDeprecationVersion {
1384     #[primary_span]
1385     #[label]
1386     pub span: Span,
1387     #[label(item)]
1388     pub item_sp: Span,
1389 }
1390
1391 #[derive(Diagnostic)]
1392 #[diag(passes_missing_stability_attr)]
1393 pub struct MissingStabilityAttr<'a> {
1394     #[primary_span]
1395     pub span: Span,
1396     pub descr: &'a str,
1397 }
1398
1399 #[derive(Diagnostic)]
1400 #[diag(passes_missing_const_stab_attr)]
1401 pub struct MissingConstStabAttr<'a> {
1402     #[primary_span]
1403     pub span: Span,
1404     pub descr: &'a str,
1405 }
1406
1407 #[derive(Diagnostic)]
1408 #[diag(passes_trait_impl_const_stable)]
1409 #[note]
1410 pub struct TraitImplConstStable {
1411     #[primary_span]
1412     pub span: Span,
1413 }
1414
1415 #[derive(Diagnostic)]
1416 #[diag(passes_feature_only_on_nightly, code = "E0554")]
1417 pub struct FeatureOnlyOnNightly {
1418     #[primary_span]
1419     pub span: Span,
1420     pub release_channel: &'static str,
1421 }
1422
1423 #[derive(Diagnostic)]
1424 #[diag(passes_unknown_feature, code = "E0635")]
1425 pub struct UnknownFeature {
1426     #[primary_span]
1427     pub span: Span,
1428     pub feature: Symbol,
1429 }
1430
1431 #[derive(Diagnostic)]
1432 #[diag(passes_implied_feature_not_exist)]
1433 pub struct ImpliedFeatureNotExist {
1434     #[primary_span]
1435     pub span: Span,
1436     pub feature: Symbol,
1437     pub implied_by: Symbol,
1438 }
1439
1440 #[derive(Diagnostic)]
1441 #[diag(passes_duplicate_feature_err, code = "E0636")]
1442 pub struct DuplicateFeatureErr {
1443     #[primary_span]
1444     pub span: Span,
1445     pub feature: Symbol,
1446 }
1447 #[derive(Diagnostic)]
1448 #[diag(passes_missing_const_err)]
1449 pub struct MissingConstErr {
1450     #[primary_span]
1451     #[help]
1452     pub fn_sig_span: Span,
1453     #[label]
1454     pub const_span: Span,
1455 }
1456
1457 #[derive(LintDiagnostic)]
1458 pub enum MultipleDeadCodes<'tcx> {
1459     #[diag(passes_dead_codes)]
1460     DeadCodes {
1461         multiple: bool,
1462         num: usize,
1463         descr: &'tcx str,
1464         participle: &'tcx str,
1465         name_list: DiagnosticSymbolList,
1466         #[subdiagnostic]
1467         parent_info: Option<ParentInfo<'tcx>>,
1468         #[subdiagnostic]
1469         ignored_derived_impls: Option<IgnoredDerivedImpls>,
1470     },
1471     #[diag(passes_dead_codes)]
1472     UnusedTupleStructFields {
1473         multiple: bool,
1474         num: usize,
1475         descr: &'tcx str,
1476         participle: &'tcx str,
1477         name_list: DiagnosticSymbolList,
1478         #[subdiagnostic]
1479         change_fields_suggestion: ChangeFieldsToBeOfUnitType,
1480         #[subdiagnostic]
1481         parent_info: Option<ParentInfo<'tcx>>,
1482         #[subdiagnostic]
1483         ignored_derived_impls: Option<IgnoredDerivedImpls>,
1484     },
1485 }
1486
1487 #[derive(Subdiagnostic)]
1488 #[label(passes_parent_info)]
1489 pub struct ParentInfo<'tcx> {
1490     pub num: usize,
1491     pub descr: &'tcx str,
1492     pub parent_descr: &'tcx str,
1493     #[primary_span]
1494     pub span: Span,
1495 }
1496
1497 #[derive(Subdiagnostic)]
1498 #[note(passes_ignored_derived_impls)]
1499 pub struct IgnoredDerivedImpls {
1500     pub name: Symbol,
1501     pub trait_list: DiagnosticSymbolList,
1502     pub trait_list_len: usize,
1503 }
1504
1505 #[derive(Subdiagnostic)]
1506 #[multipart_suggestion(passes_change_fields_to_be_of_unit_type, applicability = "has-placeholders")]
1507 pub struct ChangeFieldsToBeOfUnitType {
1508     pub num: usize,
1509     #[suggestion_part(code = "()")]
1510     pub spans: Vec<Span>,
1511 }
1512
1513 #[derive(Diagnostic)]
1514 #[diag(passes_proc_macro_typeerror)]
1515 #[note]
1516 pub(crate) struct ProcMacroTypeError<'tcx> {
1517     #[primary_span]
1518     #[label]
1519     pub span: Span,
1520     pub found: Ty<'tcx>,
1521     pub kind: ProcMacroKind,
1522     pub expected_signature: &'static str,
1523 }
1524
1525 #[derive(Diagnostic)]
1526 #[diag(passes_proc_macro_diff_arg_count)]
1527 pub(crate) struct ProcMacroDiffArguments {
1528     #[primary_span]
1529     #[label]
1530     pub span: Span,
1531     pub count: usize,
1532     pub kind: ProcMacroKind,
1533     pub expected_signature: &'static str,
1534 }
1535
1536 #[derive(Diagnostic)]
1537 #[diag(passes_proc_macro_missing_args)]
1538 pub(crate) struct ProcMacroMissingArguments {
1539     #[primary_span]
1540     #[label]
1541     pub span: Span,
1542     pub expected_input_count: usize,
1543     pub kind: ProcMacroKind,
1544     pub expected_signature: &'static str,
1545 }
1546
1547 #[derive(Diagnostic)]
1548 #[diag(passes_proc_macro_invalid_abi)]
1549 pub(crate) struct ProcMacroInvalidAbi {
1550     #[primary_span]
1551     pub span: Span,
1552     pub abi: &'static str,
1553 }
1554
1555 #[derive(Diagnostic)]
1556 #[diag(passes_proc_macro_unsafe)]
1557 pub(crate) struct ProcMacroUnsafe {
1558     #[primary_span]
1559     pub span: Span,
1560 }