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