]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_passes/src/errors.rs
Auto merge of #107141 - notriddle:notriddle/max-lev-distance-2023, r=GuillaumeGomez
[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(Diagnostic)]
352 #[diag(passes_both_ffi_const_and_pure, code = "E0757")]
353 pub struct BothFfiConstAndPure {
354     #[primary_span]
355     pub attr_span: Span,
356 }
357
358 #[derive(Diagnostic)]
359 #[diag(passes_ffi_pure_invalid_target, code = "E0755")]
360 pub struct FfiPureInvalidTarget {
361     #[primary_span]
362     pub attr_span: Span,
363 }
364
365 #[derive(Diagnostic)]
366 #[diag(passes_ffi_const_invalid_target, code = "E0756")]
367 pub struct FfiConstInvalidTarget {
368     #[primary_span]
369     pub attr_span: Span,
370 }
371
372 #[derive(Diagnostic)]
373 #[diag(passes_ffi_returns_twice_invalid_target, code = "E0724")]
374 pub struct FfiReturnsTwiceInvalidTarget {
375     #[primary_span]
376     pub attr_span: Span,
377 }
378
379 #[derive(LintDiagnostic)]
380 #[diag(passes_must_use_async)]
381 pub struct MustUseAsync {
382     #[label]
383     pub span: Span,
384 }
385
386 #[derive(LintDiagnostic)]
387 #[diag(passes_must_use_no_effect)]
388 pub struct MustUseNoEffect {
389     pub article: &'static str,
390     pub target: rustc_hir::Target,
391 }
392
393 #[derive(Diagnostic)]
394 #[diag(passes_must_not_suspend)]
395 pub struct MustNotSuspend {
396     #[primary_span]
397     pub attr_span: Span,
398     #[label]
399     pub span: Span,
400 }
401
402 #[derive(LintDiagnostic)]
403 #[diag(passes_cold)]
404 #[warning]
405 pub struct Cold {
406     #[label]
407     pub span: Span,
408     pub on_crate: bool,
409 }
410
411 #[derive(LintDiagnostic)]
412 #[diag(passes_link)]
413 #[warning]
414 pub struct Link {
415     #[label]
416     pub span: Option<Span>,
417 }
418
419 #[derive(LintDiagnostic)]
420 #[diag(passes_link_name)]
421 #[warning]
422 pub struct LinkName<'a> {
423     #[help]
424     pub attr_span: Option<Span>,
425     #[label]
426     pub span: Span,
427     pub value: &'a str,
428 }
429
430 #[derive(Diagnostic)]
431 #[diag(passes_no_link)]
432 pub struct NoLink {
433     #[primary_span]
434     pub attr_span: Span,
435     #[label]
436     pub span: Span,
437 }
438
439 #[derive(Diagnostic)]
440 #[diag(passes_export_name)]
441 pub struct ExportName {
442     #[primary_span]
443     pub attr_span: Span,
444     #[label]
445     pub span: Span,
446 }
447
448 #[derive(Diagnostic)]
449 #[diag(passes_rustc_layout_scalar_valid_range_not_struct)]
450 pub struct RustcLayoutScalarValidRangeNotStruct {
451     #[primary_span]
452     pub attr_span: Span,
453     #[label]
454     pub span: Span,
455 }
456
457 #[derive(Diagnostic)]
458 #[diag(passes_rustc_layout_scalar_valid_range_arg)]
459 pub struct RustcLayoutScalarValidRangeArg {
460     #[primary_span]
461     pub attr_span: Span,
462 }
463
464 #[derive(Diagnostic)]
465 #[diag(passes_rustc_legacy_const_generics_only)]
466 pub struct RustcLegacyConstGenericsOnly {
467     #[primary_span]
468     pub attr_span: Span,
469     #[label]
470     pub param_span: Span,
471 }
472
473 #[derive(Diagnostic)]
474 #[diag(passes_rustc_legacy_const_generics_index)]
475 pub struct RustcLegacyConstGenericsIndex {
476     #[primary_span]
477     pub attr_span: Span,
478     #[label]
479     pub generics_span: Span,
480 }
481
482 #[derive(Diagnostic)]
483 #[diag(passes_rustc_legacy_const_generics_index_exceed)]
484 pub struct RustcLegacyConstGenericsIndexExceed {
485     #[primary_span]
486     #[label]
487     pub span: Span,
488     pub arg_count: usize,
489 }
490
491 #[derive(Diagnostic)]
492 #[diag(passes_rustc_legacy_const_generics_index_negative)]
493 pub struct RustcLegacyConstGenericsIndexNegative {
494     #[primary_span]
495     pub invalid_args: Vec<Span>,
496 }
497
498 #[derive(Diagnostic)]
499 #[diag(passes_rustc_dirty_clean)]
500 pub struct RustcDirtyClean {
501     #[primary_span]
502     pub span: Span,
503 }
504
505 #[derive(LintDiagnostic)]
506 #[diag(passes_link_section)]
507 #[warning]
508 pub struct LinkSection {
509     #[label]
510     pub span: Span,
511 }
512
513 #[derive(LintDiagnostic)]
514 #[diag(passes_no_mangle_foreign)]
515 #[warning]
516 #[note]
517 pub struct NoMangleForeign {
518     #[label]
519     pub span: Span,
520     #[suggestion(code = "", applicability = "machine-applicable")]
521     pub attr_span: Span,
522     pub foreign_item_kind: &'static str,
523 }
524
525 #[derive(LintDiagnostic)]
526 #[diag(passes_no_mangle)]
527 #[warning]
528 pub struct NoMangle {
529     #[label]
530     pub span: Span,
531 }
532
533 #[derive(Diagnostic)]
534 #[diag(passes_repr_ident, code = "E0565")]
535 pub struct ReprIdent {
536     #[primary_span]
537     pub span: Span,
538 }
539
540 #[derive(LintDiagnostic)]
541 #[diag(passes_repr_conflicting, code = "E0566")]
542 pub struct ReprConflicting;
543
544 #[derive(Diagnostic)]
545 #[diag(passes_used_static)]
546 pub struct UsedStatic {
547     #[primary_span]
548     pub span: Span,
549 }
550
551 #[derive(Diagnostic)]
552 #[diag(passes_used_compiler_linker)]
553 pub struct UsedCompilerLinker {
554     #[primary_span]
555     pub spans: Vec<Span>,
556 }
557
558 #[derive(Diagnostic)]
559 #[diag(passes_allow_internal_unstable)]
560 pub struct AllowInternalUnstable {
561     #[primary_span]
562     pub attr_span: Span,
563     #[label]
564     pub span: Span,
565 }
566
567 #[derive(Diagnostic)]
568 #[diag(passes_debug_visualizer_placement)]
569 pub struct DebugVisualizerPlacement {
570     #[primary_span]
571     pub span: Span,
572 }
573
574 #[derive(Diagnostic)]
575 #[diag(passes_debug_visualizer_invalid)]
576 #[note(note_1)]
577 #[note(note_2)]
578 #[note(note_3)]
579 pub struct DebugVisualizerInvalid {
580     #[primary_span]
581     pub span: Span,
582 }
583
584 #[derive(Diagnostic)]
585 #[diag(passes_debug_visualizer_unreadable)]
586 pub struct DebugVisualizerUnreadable<'a> {
587     #[primary_span]
588     pub span: Span,
589     pub file: &'a Path,
590     pub error: Error,
591 }
592
593 #[derive(Diagnostic)]
594 #[diag(passes_rustc_allow_const_fn_unstable)]
595 pub struct RustcAllowConstFnUnstable {
596     #[primary_span]
597     pub attr_span: Span,
598     #[label]
599     pub span: Span,
600 }
601
602 #[derive(Diagnostic)]
603 #[diag(passes_rustc_std_internal_symbol)]
604 pub struct RustcStdInternalSymbol {
605     #[primary_span]
606     pub attr_span: Span,
607     #[label]
608     pub span: Span,
609 }
610
611 #[derive(Diagnostic)]
612 #[diag(passes_const_trait)]
613 pub struct ConstTrait {
614     #[primary_span]
615     pub attr_span: Span,
616 }
617
618 #[derive(Diagnostic)]
619 #[diag(passes_link_ordinal)]
620 pub struct LinkOrdinal {
621     #[primary_span]
622     pub attr_span: Span,
623 }
624
625 #[derive(Diagnostic)]
626 #[diag(passes_stability_promotable)]
627 pub struct StabilityPromotable {
628     #[primary_span]
629     pub attr_span: Span,
630 }
631
632 #[derive(LintDiagnostic)]
633 #[diag(passes_deprecated)]
634 pub struct Deprecated;
635
636 #[derive(LintDiagnostic)]
637 #[diag(passes_macro_use)]
638 pub struct MacroUse {
639     pub name: Symbol,
640 }
641
642 #[derive(LintDiagnostic)]
643 #[diag(passes_macro_export)]
644 pub struct MacroExport;
645
646 #[derive(LintDiagnostic)]
647 #[diag(passes_plugin_registrar)]
648 pub struct PluginRegistrar;
649
650 #[derive(Subdiagnostic)]
651 pub enum UnusedNote {
652     #[note(passes_unused_empty_lints_note)]
653     EmptyList { name: Symbol },
654     #[note(passes_unused_no_lints_note)]
655     NoLints { name: Symbol },
656     #[note(passes_unused_default_method_body_const_note)]
657     DefaultMethodBodyConst,
658 }
659
660 #[derive(LintDiagnostic)]
661 #[diag(passes_unused)]
662 pub struct Unused {
663     #[suggestion(code = "", applicability = "machine-applicable")]
664     pub attr_span: Span,
665     #[subdiagnostic]
666     pub note: UnusedNote,
667 }
668
669 #[derive(Diagnostic)]
670 #[diag(passes_non_exported_macro_invalid_attrs, code = "E0518")]
671 pub struct NonExportedMacroInvalidAttrs {
672     #[primary_span]
673     #[label]
674     pub attr_span: Span,
675 }
676
677 #[derive(LintDiagnostic)]
678 #[diag(passes_unused_duplicate)]
679 pub struct UnusedDuplicate {
680     #[suggestion(code = "", applicability = "machine-applicable")]
681     pub this: Span,
682     #[note]
683     pub other: Span,
684     #[warning]
685     pub warning: Option<()>,
686 }
687
688 #[derive(Diagnostic)]
689 #[diag(passes_unused_multiple)]
690 pub struct UnusedMultiple {
691     #[primary_span]
692     #[suggestion(code = "", applicability = "machine-applicable")]
693     pub this: Span,
694     #[note]
695     pub other: Span,
696     pub name: Symbol,
697 }
698
699 #[derive(Diagnostic)]
700 #[diag(passes_rustc_lint_opt_ty)]
701 pub struct RustcLintOptTy {
702     #[primary_span]
703     pub attr_span: Span,
704     #[label]
705     pub span: Span,
706 }
707
708 #[derive(Diagnostic)]
709 #[diag(passes_rustc_lint_opt_deny_field_access)]
710 pub struct RustcLintOptDenyFieldAccess {
711     #[primary_span]
712     pub attr_span: Span,
713     #[label]
714     pub span: Span,
715 }
716
717 #[derive(Diagnostic)]
718 #[diag(passes_collapse_debuginfo)]
719 pub struct CollapseDebuginfo {
720     #[primary_span]
721     pub attr_span: Span,
722     #[label]
723     pub defn_span: Span,
724 }
725
726 #[derive(LintDiagnostic)]
727 #[diag(passes_deprecated_annotation_has_no_effect)]
728 pub struct DeprecatedAnnotationHasNoEffect {
729     #[suggestion(applicability = "machine-applicable", code = "")]
730     pub span: Span,
731 }
732
733 #[derive(Diagnostic)]
734 #[diag(passes_unknown_external_lang_item, code = "E0264")]
735 pub struct UnknownExternLangItem {
736     #[primary_span]
737     pub span: Span,
738     pub lang_item: Symbol,
739 }
740
741 #[derive(Diagnostic)]
742 #[diag(passes_missing_panic_handler)]
743 pub struct MissingPanicHandler;
744
745 #[derive(Diagnostic)]
746 #[diag(passes_missing_lang_item)]
747 #[note]
748 #[help]
749 pub struct MissingLangItem {
750     pub name: Symbol,
751 }
752
753 #[derive(Diagnostic)]
754 #[diag(passes_lang_item_on_incorrect_target, code = "E0718")]
755 pub struct LangItemOnIncorrectTarget {
756     #[primary_span]
757     #[label]
758     pub span: Span,
759     pub name: Symbol,
760     pub expected_target: Target,
761     pub actual_target: Target,
762 }
763
764 #[derive(Diagnostic)]
765 #[diag(passes_unknown_lang_item, code = "E0522")]
766 pub struct UnknownLangItem {
767     #[primary_span]
768     #[label]
769     pub span: Span,
770     pub name: Symbol,
771 }
772
773 pub struct InvalidAttrAtCrateLevel {
774     pub span: Span,
775     pub snippet: Option<String>,
776     pub name: Symbol,
777 }
778
779 impl IntoDiagnostic<'_> for InvalidAttrAtCrateLevel {
780     #[track_caller]
781     fn into_diagnostic(
782         self,
783         handler: &'_ rustc_errors::Handler,
784     ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
785         let mut diag = handler.struct_err(rustc_errors::fluent::passes_invalid_attr_at_crate_level);
786         diag.set_span(self.span);
787         diag.set_arg("name", self.name);
788         // Only emit an error with a suggestion if we can create a string out
789         // of the attribute span
790         if let Some(src) = self.snippet {
791             let replacement = src.replace("#!", "#");
792             diag.span_suggestion_verbose(
793                 self.span,
794                 rustc_errors::fluent::suggestion,
795                 replacement,
796                 rustc_errors::Applicability::MachineApplicable,
797             );
798         }
799         diag
800     }
801 }
802
803 #[derive(Diagnostic)]
804 #[diag(passes_duplicate_diagnostic_item)]
805 pub struct DuplicateDiagnosticItem {
806     #[primary_span]
807     pub span: Span,
808     pub name: Symbol,
809 }
810
811 #[derive(Diagnostic)]
812 #[diag(passes_duplicate_diagnostic_item_in_crate)]
813 pub struct DuplicateDiagnosticItemInCrate {
814     #[note(passes_diagnostic_item_first_defined)]
815     pub span: Option<Span>,
816     pub orig_crate_name: Symbol,
817     #[note]
818     pub have_orig_crate_name: Option<()>,
819     pub crate_name: Symbol,
820     pub name: Symbol,
821 }
822
823 #[derive(Diagnostic)]
824 #[diag(passes_abi)]
825 pub struct Abi {
826     #[primary_span]
827     pub span: Span,
828     pub abi: String,
829 }
830
831 #[derive(Diagnostic)]
832 #[diag(passes_align)]
833 pub struct Align {
834     #[primary_span]
835     pub span: Span,
836     pub align: String,
837 }
838
839 #[derive(Diagnostic)]
840 #[diag(passes_size)]
841 pub struct Size {
842     #[primary_span]
843     pub span: Span,
844     pub size: String,
845 }
846
847 #[derive(Diagnostic)]
848 #[diag(passes_homogeneous_aggregate)]
849 pub struct HomogeneousAggregate {
850     #[primary_span]
851     pub span: Span,
852     pub homogeneous_aggregate: String,
853 }
854
855 #[derive(Diagnostic)]
856 #[diag(passes_layout_of)]
857 pub struct LayoutOf {
858     #[primary_span]
859     pub span: Span,
860     pub normalized_ty: String,
861     pub ty_layout: String,
862 }
863
864 #[derive(Diagnostic)]
865 #[diag(passes_unrecognized_field)]
866 pub struct UnrecognizedField {
867     #[primary_span]
868     pub span: Span,
869     pub name: Symbol,
870 }
871
872 #[derive(Diagnostic)]
873 #[diag(passes_feature_stable_twice, code = "E0711")]
874 pub struct FeatureStableTwice {
875     #[primary_span]
876     pub span: Span,
877     pub feature: Symbol,
878     pub since: Symbol,
879     pub prev_since: Symbol,
880 }
881
882 #[derive(Diagnostic)]
883 #[diag(passes_feature_previously_declared, code = "E0711")]
884 pub struct FeaturePreviouslyDeclared<'a, 'b> {
885     #[primary_span]
886     pub span: Span,
887     pub feature: Symbol,
888     pub declared: &'a str,
889     pub prev_declared: &'b str,
890 }
891
892 #[derive(Diagnostic)]
893 #[diag(passes_expr_not_allowed_in_context, code = "E0744")]
894 pub struct ExprNotAllowedInContext<'a> {
895     #[primary_span]
896     pub span: Span,
897     pub expr: String,
898     pub context: &'a str,
899 }
900
901 pub struct BreakNonLoop<'a> {
902     pub span: Span,
903     pub head: Option<Span>,
904     pub kind: &'a str,
905     pub suggestion: String,
906     pub loop_label: Option<Label>,
907     pub break_label: Option<Label>,
908     pub break_expr_kind: &'a ExprKind<'a>,
909     pub break_expr_span: Span,
910 }
911
912 impl<'a> IntoDiagnostic<'_> for BreakNonLoop<'a> {
913     #[track_caller]
914     fn into_diagnostic(
915         self,
916         handler: &rustc_errors::Handler,
917     ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
918         let mut diag = handler.struct_span_err_with_code(
919             self.span,
920             rustc_errors::fluent::passes_break_non_loop,
921             error_code!(E0571),
922         );
923         diag.set_arg("kind", self.kind);
924         diag.span_label(self.span, rustc_errors::fluent::label);
925         if let Some(head) = self.head {
926             diag.span_label(head, rustc_errors::fluent::label2);
927         }
928         diag.span_suggestion(
929             self.span,
930             rustc_errors::fluent::suggestion,
931             self.suggestion,
932             Applicability::MaybeIncorrect,
933         );
934         if let (Some(label), None) = (self.loop_label, self.break_label) {
935             match self.break_expr_kind {
936                 ExprKind::Path(hir::QPath::Resolved(
937                     None,
938                     hir::Path { segments: [segment], res: hir::def::Res::Err, .. },
939                 )) if label.ident.to_string() == format!("'{}", segment.ident) => {
940                     // This error is redundant, we will have already emitted a
941                     // suggestion to use the label when `segment` wasn't found
942                     // (hence the `Res::Err` check).
943                     diag.delay_as_bug();
944                 }
945                 _ => {
946                     diag.span_suggestion(
947                         self.break_expr_span,
948                         rustc_errors::fluent::break_expr_suggestion,
949                         label.ident,
950                         Applicability::MaybeIncorrect,
951                     );
952                 }
953             }
954         }
955         diag
956     }
957 }
958
959 #[derive(Diagnostic)]
960 #[diag(passes_continue_labeled_block, code = "E0696")]
961 pub struct ContinueLabeledBlock {
962     #[primary_span]
963     #[label]
964     pub span: Span,
965     #[label(block_label)]
966     pub block_span: Span,
967 }
968
969 #[derive(Diagnostic)]
970 #[diag(passes_break_inside_closure, code = "E0267")]
971 pub struct BreakInsideClosure<'a> {
972     #[primary_span]
973     #[label]
974     pub span: Span,
975     #[label(closure_label)]
976     pub closure_span: Span,
977     pub name: &'a str,
978 }
979
980 #[derive(Diagnostic)]
981 #[diag(passes_break_inside_async_block, code = "E0267")]
982 pub struct BreakInsideAsyncBlock<'a> {
983     #[primary_span]
984     #[label]
985     pub span: Span,
986     #[label(async_block_label)]
987     pub closure_span: Span,
988     pub name: &'a str,
989 }
990
991 #[derive(Diagnostic)]
992 #[diag(passes_outside_loop, code = "E0268")]
993 pub struct OutsideLoop<'a> {
994     #[primary_span]
995     #[label]
996     pub span: Span,
997     pub name: &'a str,
998     pub is_break: bool,
999 }
1000
1001 #[derive(Diagnostic)]
1002 #[diag(passes_unlabeled_in_labeled_block, code = "E0695")]
1003 pub struct UnlabeledInLabeledBlock<'a> {
1004     #[primary_span]
1005     #[label]
1006     pub span: Span,
1007     pub cf_type: &'a str,
1008 }
1009
1010 #[derive(Diagnostic)]
1011 #[diag(passes_unlabeled_cf_in_while_condition, code = "E0590")]
1012 pub struct UnlabeledCfInWhileCondition<'a> {
1013     #[primary_span]
1014     #[label]
1015     pub span: Span,
1016     pub cf_type: &'a str,
1017 }
1018
1019 #[derive(Diagnostic)]
1020 #[diag(passes_cannot_inline_naked_function)]
1021 pub struct CannotInlineNakedFunction {
1022     #[primary_span]
1023     pub span: Span,
1024 }
1025
1026 #[derive(LintDiagnostic)]
1027 #[diag(passes_undefined_naked_function_abi)]
1028 pub struct UndefinedNakedFunctionAbi;
1029
1030 #[derive(Diagnostic)]
1031 #[diag(passes_no_patterns)]
1032 pub struct NoPatterns {
1033     #[primary_span]
1034     pub span: Span,
1035 }
1036
1037 #[derive(Diagnostic)]
1038 #[diag(passes_params_not_allowed)]
1039 #[help]
1040 pub struct ParamsNotAllowed {
1041     #[primary_span]
1042     pub span: Span,
1043 }
1044
1045 pub struct NakedFunctionsAsmBlock {
1046     pub span: Span,
1047     pub multiple_asms: Vec<Span>,
1048     pub non_asms: Vec<Span>,
1049 }
1050
1051 impl IntoDiagnostic<'_> for NakedFunctionsAsmBlock {
1052     #[track_caller]
1053     fn into_diagnostic(
1054         self,
1055         handler: &rustc_errors::Handler,
1056     ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
1057         let mut diag = handler.struct_span_err_with_code(
1058             self.span,
1059             rustc_errors::fluent::passes_naked_functions_asm_block,
1060             error_code!(E0787),
1061         );
1062         for span in self.multiple_asms.iter() {
1063             diag.span_label(*span, rustc_errors::fluent::label_multiple_asm);
1064         }
1065         for span in self.non_asms.iter() {
1066             diag.span_label(*span, rustc_errors::fluent::label_non_asm);
1067         }
1068         diag
1069     }
1070 }
1071
1072 #[derive(Diagnostic)]
1073 #[diag(passes_naked_functions_operands, code = "E0787")]
1074 pub struct NakedFunctionsOperands {
1075     #[primary_span]
1076     pub unsupported_operands: Vec<Span>,
1077 }
1078
1079 #[derive(Diagnostic)]
1080 #[diag(passes_naked_functions_asm_options, code = "E0787")]
1081 pub struct NakedFunctionsAsmOptions {
1082     #[primary_span]
1083     pub span: Span,
1084     pub unsupported_options: String,
1085 }
1086
1087 #[derive(Diagnostic)]
1088 #[diag(passes_naked_functions_must_use_noreturn, code = "E0787")]
1089 pub struct NakedFunctionsMustUseNoreturn {
1090     #[primary_span]
1091     pub span: Span,
1092     #[suggestion(code = ", options(noreturn)", applicability = "machine-applicable")]
1093     pub last_span: Span,
1094 }
1095
1096 #[derive(Diagnostic)]
1097 #[diag(passes_attr_only_on_main)]
1098 pub struct AttrOnlyOnMain {
1099     #[primary_span]
1100     pub span: Span,
1101     pub attr: Symbol,
1102 }
1103
1104 #[derive(Diagnostic)]
1105 #[diag(passes_attr_only_on_root_main)]
1106 pub struct AttrOnlyOnRootMain {
1107     #[primary_span]
1108     pub span: Span,
1109     pub attr: Symbol,
1110 }
1111
1112 #[derive(Diagnostic)]
1113 #[diag(passes_attr_only_in_functions)]
1114 pub struct AttrOnlyInFunctions {
1115     #[primary_span]
1116     pub span: Span,
1117     pub attr: Symbol,
1118 }
1119
1120 #[derive(Diagnostic)]
1121 #[diag(passes_multiple_rustc_main, code = "E0137")]
1122 pub struct MultipleRustcMain {
1123     #[primary_span]
1124     pub span: Span,
1125     #[label(first)]
1126     pub first: Span,
1127     #[label(additional)]
1128     pub additional: Span,
1129 }
1130
1131 #[derive(Diagnostic)]
1132 #[diag(passes_multiple_start_functions, code = "E0138")]
1133 pub struct MultipleStartFunctions {
1134     #[primary_span]
1135     pub span: Span,
1136     #[label]
1137     pub labeled: Span,
1138     #[label(previous)]
1139     pub previous: Span,
1140 }
1141
1142 #[derive(Diagnostic)]
1143 #[diag(passes_extern_main)]
1144 pub struct ExternMain {
1145     #[primary_span]
1146     pub span: Span,
1147 }
1148
1149 #[derive(Diagnostic)]
1150 #[diag(passes_unix_sigpipe_values)]
1151 pub struct UnixSigpipeValues {
1152     #[primary_span]
1153     pub span: Span,
1154 }
1155
1156 #[derive(Diagnostic)]
1157 #[diag(passes_no_main_function, code = "E0601")]
1158 pub struct NoMainFunction {
1159     #[primary_span]
1160     pub span: Span,
1161     pub crate_name: String,
1162 }
1163
1164 pub struct NoMainErr {
1165     pub sp: Span,
1166     pub crate_name: Symbol,
1167     pub has_filename: bool,
1168     pub filename: PathBuf,
1169     pub file_empty: bool,
1170     pub non_main_fns: Vec<Span>,
1171     pub main_def_opt: Option<MainDefinition>,
1172     pub add_teach_note: bool,
1173 }
1174
1175 impl<'a> IntoDiagnostic<'a> for NoMainErr {
1176     #[track_caller]
1177     fn into_diagnostic(
1178         self,
1179         handler: &'a rustc_errors::Handler,
1180     ) -> rustc_errors::DiagnosticBuilder<'a, ErrorGuaranteed> {
1181         let mut diag = handler.struct_span_err_with_code(
1182             DUMMY_SP,
1183             rustc_errors::fluent::passes_no_main_function,
1184             error_code!(E0601),
1185         );
1186         diag.set_arg("crate_name", self.crate_name);
1187         diag.set_arg("filename", self.filename);
1188         diag.set_arg("has_filename", self.has_filename);
1189         let note = if !self.non_main_fns.is_empty() {
1190             for &span in &self.non_main_fns {
1191                 diag.span_note(span, rustc_errors::fluent::here_is_main);
1192             }
1193             diag.note(rustc_errors::fluent::one_or_more_possible_main);
1194             diag.help(rustc_errors::fluent::consider_moving_main);
1195             // There were some functions named `main` though. Try to give the user a hint.
1196             rustc_errors::fluent::main_must_be_defined_at_crate
1197         } else if self.has_filename {
1198             rustc_errors::fluent::consider_adding_main_to_file
1199         } else {
1200             rustc_errors::fluent::consider_adding_main_at_crate
1201         };
1202         if self.file_empty {
1203             diag.note(note);
1204         } else {
1205             diag.set_span(self.sp.shrink_to_hi());
1206             diag.span_label(self.sp.shrink_to_hi(), note);
1207         }
1208
1209         if let Some(main_def) = self.main_def_opt && main_def.opt_fn_def_id().is_none(){
1210             // There is something at `crate::main`, but it is not a function definition.
1211             diag.span_label(main_def.span, rustc_errors::fluent::non_function_main);
1212         }
1213
1214         if self.add_teach_note {
1215             diag.note(rustc_errors::fluent::teach_note);
1216         }
1217         diag
1218     }
1219 }
1220
1221 pub struct DuplicateLangItem {
1222     pub local_span: Option<Span>,
1223     pub lang_item_name: Symbol,
1224     pub crate_name: Symbol,
1225     pub dependency_of: Symbol,
1226     pub is_local: bool,
1227     pub path: String,
1228     pub first_defined_span: Option<Span>,
1229     pub orig_crate_name: Symbol,
1230     pub orig_dependency_of: Symbol,
1231     pub orig_is_local: bool,
1232     pub orig_path: String,
1233     pub(crate) duplicate: Duplicate,
1234 }
1235
1236 impl IntoDiagnostic<'_> for DuplicateLangItem {
1237     #[track_caller]
1238     fn into_diagnostic(
1239         self,
1240         handler: &rustc_errors::Handler,
1241     ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
1242         let mut diag = handler.struct_err_with_code(
1243             match self.duplicate {
1244                 Duplicate::Plain => rustc_errors::fluent::passes_duplicate_lang_item,
1245
1246                 Duplicate::Crate => rustc_errors::fluent::passes_duplicate_lang_item_crate,
1247                 Duplicate::CrateDepends => {
1248                     rustc_errors::fluent::passes_duplicate_lang_item_crate_depends
1249                 }
1250             },
1251             error_code!(E0152),
1252         );
1253         diag.set_arg("lang_item_name", self.lang_item_name);
1254         diag.set_arg("crate_name", self.crate_name);
1255         diag.set_arg("dependency_of", self.dependency_of);
1256         diag.set_arg("path", self.path);
1257         diag.set_arg("orig_crate_name", self.orig_crate_name);
1258         diag.set_arg("orig_dependency_of", self.orig_dependency_of);
1259         diag.set_arg("orig_path", self.orig_path);
1260         if let Some(span) = self.local_span {
1261             diag.set_span(span);
1262         }
1263         if let Some(span) = self.first_defined_span {
1264             diag.span_note(span, rustc_errors::fluent::first_defined_span);
1265         } else {
1266             if self.orig_dependency_of.is_empty() {
1267                 diag.note(rustc_errors::fluent::first_defined_crate);
1268             } else {
1269                 diag.note(rustc_errors::fluent::first_defined_crate_depends);
1270             }
1271
1272             if self.orig_is_local {
1273                 diag.note(rustc_errors::fluent::first_definition_local);
1274             } else {
1275                 diag.note(rustc_errors::fluent::first_definition_path);
1276             }
1277
1278             if self.is_local {
1279                 diag.note(rustc_errors::fluent::second_definition_local);
1280             } else {
1281                 diag.note(rustc_errors::fluent::second_definition_path);
1282             }
1283         }
1284         diag
1285     }
1286 }
1287
1288 #[derive(Diagnostic)]
1289 #[diag(passes_incorrect_target, code = "E0718")]
1290 pub struct IncorrectTarget<'a> {
1291     #[primary_span]
1292     pub span: Span,
1293     #[label]
1294     pub generics_span: Span,
1295     pub name: &'a str, // cannot be symbol because it renders e.g. `r#fn` instead of `fn`
1296     pub kind: &'static str,
1297     pub num: usize,
1298     pub actual_num: usize,
1299     pub at_least: bool,
1300 }
1301
1302 #[derive(LintDiagnostic)]
1303 #[diag(passes_useless_assignment)]
1304 pub struct UselessAssignment<'a> {
1305     pub is_field_assign: bool,
1306     pub ty: Ty<'a>,
1307 }
1308
1309 #[derive(LintDiagnostic)]
1310 #[diag(passes_only_has_effect_on)]
1311 pub struct OnlyHasEffectOn {
1312     pub attr_name: Symbol,
1313     pub target_name: String,
1314 }
1315
1316 #[derive(Diagnostic)]
1317 #[diag(passes_object_lifetime_err)]
1318 pub struct ObjectLifetimeErr {
1319     #[primary_span]
1320     pub span: Span,
1321     pub repr: String,
1322 }
1323
1324 #[derive(Diagnostic)]
1325 #[diag(passes_unrecognized_repr_hint, code = "E0552")]
1326 #[help]
1327 pub struct UnrecognizedReprHint {
1328     #[primary_span]
1329     pub span: Span,
1330 }
1331
1332 #[derive(Diagnostic)]
1333 pub enum AttrApplication {
1334     #[diag(passes_attr_application_enum, code = "E0517")]
1335     Enum {
1336         #[primary_span]
1337         hint_span: Span,
1338         #[label]
1339         span: Span,
1340     },
1341     #[diag(passes_attr_application_struct, code = "E0517")]
1342     Struct {
1343         #[primary_span]
1344         hint_span: Span,
1345         #[label]
1346         span: Span,
1347     },
1348     #[diag(passes_attr_application_struct_union, code = "E0517")]
1349     StructUnion {
1350         #[primary_span]
1351         hint_span: Span,
1352         #[label]
1353         span: Span,
1354     },
1355     #[diag(passes_attr_application_struct_enum_union, code = "E0517")]
1356     StructEnumUnion {
1357         #[primary_span]
1358         hint_span: Span,
1359         #[label]
1360         span: Span,
1361     },
1362     #[diag(passes_attr_application_struct_enum_function_union, code = "E0517")]
1363     StructEnumFunctionUnion {
1364         #[primary_span]
1365         hint_span: Span,
1366         #[label]
1367         span: Span,
1368     },
1369 }
1370
1371 #[derive(Diagnostic)]
1372 #[diag(passes_transparent_incompatible, code = "E0692")]
1373 pub struct TransparentIncompatible {
1374     #[primary_span]
1375     pub hint_spans: Vec<Span>,
1376     pub target: String,
1377 }
1378
1379 #[derive(Diagnostic)]
1380 #[diag(passes_deprecated_attribute, code = "E0549")]
1381 pub struct DeprecatedAttribute {
1382     #[primary_span]
1383     pub span: Span,
1384 }
1385
1386 #[derive(Diagnostic)]
1387 #[diag(passes_useless_stability)]
1388 pub struct UselessStability {
1389     #[primary_span]
1390     #[label]
1391     pub span: Span,
1392     #[label(item)]
1393     pub item_sp: Span,
1394 }
1395
1396 #[derive(Diagnostic)]
1397 #[diag(passes_invalid_stability)]
1398 pub struct InvalidStability {
1399     #[primary_span]
1400     #[label]
1401     pub span: Span,
1402     #[label(item)]
1403     pub item_sp: Span,
1404 }
1405
1406 #[derive(Diagnostic)]
1407 #[diag(passes_cannot_stabilize_deprecated)]
1408 pub struct CannotStabilizeDeprecated {
1409     #[primary_span]
1410     #[label]
1411     pub span: Span,
1412     #[label(item)]
1413     pub item_sp: Span,
1414 }
1415
1416 #[derive(Diagnostic)]
1417 #[diag(passes_invalid_deprecation_version)]
1418 pub struct InvalidDeprecationVersion {
1419     #[primary_span]
1420     #[label]
1421     pub span: Span,
1422     #[label(item)]
1423     pub item_sp: Span,
1424 }
1425
1426 #[derive(Diagnostic)]
1427 #[diag(passes_missing_stability_attr)]
1428 pub struct MissingStabilityAttr<'a> {
1429     #[primary_span]
1430     pub span: Span,
1431     pub descr: &'a str,
1432 }
1433
1434 #[derive(Diagnostic)]
1435 #[diag(passes_missing_const_stab_attr)]
1436 pub struct MissingConstStabAttr<'a> {
1437     #[primary_span]
1438     pub span: Span,
1439     pub descr: &'a str,
1440 }
1441
1442 #[derive(Diagnostic)]
1443 #[diag(passes_trait_impl_const_stable)]
1444 #[note]
1445 pub struct TraitImplConstStable {
1446     #[primary_span]
1447     pub span: Span,
1448 }
1449
1450 #[derive(Diagnostic)]
1451 #[diag(passes_feature_only_on_nightly, code = "E0554")]
1452 pub struct FeatureOnlyOnNightly {
1453     #[primary_span]
1454     pub span: Span,
1455     pub release_channel: &'static str,
1456 }
1457
1458 #[derive(Diagnostic)]
1459 #[diag(passes_unknown_feature, code = "E0635")]
1460 pub struct UnknownFeature {
1461     #[primary_span]
1462     pub span: Span,
1463     pub feature: Symbol,
1464 }
1465
1466 #[derive(Diagnostic)]
1467 #[diag(passes_implied_feature_not_exist)]
1468 pub struct ImpliedFeatureNotExist {
1469     #[primary_span]
1470     pub span: Span,
1471     pub feature: Symbol,
1472     pub implied_by: Symbol,
1473 }
1474
1475 #[derive(Diagnostic)]
1476 #[diag(passes_duplicate_feature_err, code = "E0636")]
1477 pub struct DuplicateFeatureErr {
1478     #[primary_span]
1479     pub span: Span,
1480     pub feature: Symbol,
1481 }
1482 #[derive(Diagnostic)]
1483 #[diag(passes_missing_const_err)]
1484 pub struct MissingConstErr {
1485     #[primary_span]
1486     #[help]
1487     pub fn_sig_span: Span,
1488     #[label]
1489     pub const_span: Span,
1490 }
1491
1492 #[derive(LintDiagnostic)]
1493 pub enum MultipleDeadCodes<'tcx> {
1494     #[diag(passes_dead_codes)]
1495     DeadCodes {
1496         multiple: bool,
1497         num: usize,
1498         descr: &'tcx str,
1499         participle: &'tcx str,
1500         name_list: DiagnosticSymbolList,
1501         #[subdiagnostic]
1502         parent_info: Option<ParentInfo<'tcx>>,
1503         #[subdiagnostic]
1504         ignored_derived_impls: Option<IgnoredDerivedImpls>,
1505     },
1506     #[diag(passes_dead_codes)]
1507     UnusedTupleStructFields {
1508         multiple: bool,
1509         num: usize,
1510         descr: &'tcx str,
1511         participle: &'tcx str,
1512         name_list: DiagnosticSymbolList,
1513         #[subdiagnostic]
1514         change_fields_suggestion: ChangeFieldsToBeOfUnitType,
1515         #[subdiagnostic]
1516         parent_info: Option<ParentInfo<'tcx>>,
1517         #[subdiagnostic]
1518         ignored_derived_impls: Option<IgnoredDerivedImpls>,
1519     },
1520 }
1521
1522 #[derive(Subdiagnostic)]
1523 #[label(passes_parent_info)]
1524 pub struct ParentInfo<'tcx> {
1525     pub num: usize,
1526     pub descr: &'tcx str,
1527     pub parent_descr: &'tcx str,
1528     #[primary_span]
1529     pub span: Span,
1530 }
1531
1532 #[derive(Subdiagnostic)]
1533 #[note(passes_ignored_derived_impls)]
1534 pub struct IgnoredDerivedImpls {
1535     pub name: Symbol,
1536     pub trait_list: DiagnosticSymbolList,
1537     pub trait_list_len: usize,
1538 }
1539
1540 #[derive(Subdiagnostic)]
1541 #[multipart_suggestion(passes_change_fields_to_be_of_unit_type, applicability = "has-placeholders")]
1542 pub struct ChangeFieldsToBeOfUnitType {
1543     pub num: usize,
1544     #[suggestion_part(code = "()")]
1545     pub spans: Vec<Span>,
1546 }
1547
1548 #[derive(Diagnostic)]
1549 #[diag(passes_proc_macro_typeerror)]
1550 #[note]
1551 pub(crate) struct ProcMacroTypeError<'tcx> {
1552     #[primary_span]
1553     #[label]
1554     pub span: Span,
1555     pub found: Ty<'tcx>,
1556     pub kind: ProcMacroKind,
1557     pub expected_signature: &'static str,
1558 }
1559
1560 #[derive(Diagnostic)]
1561 #[diag(passes_proc_macro_diff_arg_count)]
1562 pub(crate) struct ProcMacroDiffArguments {
1563     #[primary_span]
1564     #[label]
1565     pub span: Span,
1566     pub count: usize,
1567     pub kind: ProcMacroKind,
1568     pub expected_signature: &'static str,
1569 }
1570
1571 #[derive(Diagnostic)]
1572 #[diag(passes_proc_macro_missing_args)]
1573 pub(crate) struct ProcMacroMissingArguments {
1574     #[primary_span]
1575     #[label]
1576     pub span: Span,
1577     pub expected_input_count: usize,
1578     pub kind: ProcMacroKind,
1579     pub expected_signature: &'static str,
1580 }
1581
1582 #[derive(Diagnostic)]
1583 #[diag(passes_proc_macro_invalid_abi)]
1584 pub(crate) struct ProcMacroInvalidAbi {
1585     #[primary_span]
1586     pub span: Span,
1587     pub abi: &'static str,
1588 }
1589
1590 #[derive(Diagnostic)]
1591 #[diag(passes_proc_macro_unsafe)]
1592 pub(crate) struct ProcMacroUnsafe {
1593     #[primary_span]
1594     pub span: Span,
1595 }
1596
1597 #[derive(Diagnostic)]
1598 #[diag(passes_skipping_const_checks)]
1599 pub struct SkippingConstChecks {
1600     #[primary_span]
1601     pub span: Span,
1602 }