rustc_passes/
errors.rs

1use std::io::Error;
2use std::path::{Path, PathBuf};
3
4use rustc_errors::codes::*;
5use rustc_errors::{
6    Applicability, Diag, DiagCtxtHandle, DiagSymbolList, Diagnostic, EmissionGuarantee, Level,
7    MultiSpan, Subdiagnostic,
8};
9use rustc_hir::Target;
10use rustc_hir::attrs::{MirDialect, MirPhase};
11use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
12use rustc_middle::ty::{MainDefinition, Ty};
13use rustc_span::{DUMMY_SP, Span, Symbol};
14
15use crate::check_attr::ProcMacroKind;
16use crate::fluent_generated as fluent;
17use crate::lang_items::Duplicate;
18
19#[derive(LintDiagnostic)]
20#[diag(passes_incorrect_do_not_recommend_location)]
21pub(crate) struct IncorrectDoNotRecommendLocation;
22
23#[derive(LintDiagnostic)]
24#[diag(passes_incorrect_do_not_recommend_args)]
25pub(crate) struct DoNotRecommendDoesNotExpectArgs;
26
27#[derive(Diagnostic)]
28#[diag(passes_autodiff_attr)]
29pub(crate) struct AutoDiffAttr {
30    #[primary_span]
31    #[label]
32    pub attr_span: Span,
33}
34
35#[derive(Diagnostic)]
36#[diag(passes_loop_match_attr)]
37pub(crate) struct LoopMatchAttr {
38    #[primary_span]
39    pub attr_span: Span,
40    #[label]
41    pub node_span: Span,
42}
43
44#[derive(Diagnostic)]
45#[diag(passes_const_continue_attr)]
46pub(crate) struct ConstContinueAttr {
47    #[primary_span]
48    pub attr_span: Span,
49    #[label]
50    pub node_span: Span,
51}
52
53#[derive(LintDiagnostic)]
54#[diag(passes_mixed_export_name_and_no_mangle)]
55pub(crate) struct MixedExportNameAndNoMangle {
56    #[label]
57    #[suggestion(style = "verbose", code = "", applicability = "machine-applicable")]
58    pub no_mangle_span: Span,
59    #[note]
60    pub export_name_span: Span,
61    pub no_mangle_attr: &'static str,
62    pub export_name_attr: &'static str,
63}
64
65#[derive(LintDiagnostic)]
66#[diag(passes_outer_crate_level_attr)]
67pub(crate) struct OuterCrateLevelAttr;
68
69#[derive(LintDiagnostic)]
70#[diag(passes_inner_crate_level_attr)]
71pub(crate) struct InnerCrateLevelAttr;
72
73#[derive(LintDiagnostic)]
74#[diag(passes_ignored_attr_with_macro)]
75pub(crate) struct IgnoredAttrWithMacro<'a> {
76    pub sym: &'a str,
77}
78
79#[derive(Diagnostic)]
80#[diag(passes_should_be_applied_to_fn)]
81pub(crate) struct AttrShouldBeAppliedToFn {
82    #[primary_span]
83    pub attr_span: Span,
84    #[label]
85    pub defn_span: Span,
86    pub on_crate: bool,
87}
88
89#[derive(Diagnostic)]
90#[diag(passes_non_exhaustive_with_default_field_values)]
91pub(crate) struct NonExhaustiveWithDefaultFieldValues {
92    #[primary_span]
93    pub attr_span: Span,
94    #[label]
95    pub defn_span: Span,
96}
97
98#[derive(Diagnostic)]
99#[diag(passes_should_be_applied_to_trait)]
100pub(crate) struct AttrShouldBeAppliedToTrait {
101    #[primary_span]
102    pub attr_span: Span,
103    #[label]
104    pub defn_span: Span,
105}
106
107#[derive(Diagnostic)]
108#[diag(passes_should_be_applied_to_static)]
109pub(crate) struct AttrShouldBeAppliedToStatic {
110    #[primary_span]
111    pub attr_span: Span,
112    #[label]
113    pub defn_span: Span,
114}
115
116#[derive(Diagnostic)]
117#[diag(passes_doc_expect_str)]
118pub(crate) struct DocExpectStr<'a> {
119    #[primary_span]
120    pub attr_span: Span,
121    pub attr_name: &'a str,
122}
123
124#[derive(Diagnostic)]
125#[diag(passes_doc_alias_empty)]
126pub(crate) struct DocAliasEmpty<'a> {
127    #[primary_span]
128    pub span: Span,
129    pub attr_str: &'a str,
130}
131
132#[derive(Diagnostic)]
133#[diag(passes_doc_alias_bad_char)]
134pub(crate) struct DocAliasBadChar<'a> {
135    #[primary_span]
136    pub span: Span,
137    pub attr_str: &'a str,
138    pub char_: char,
139}
140
141#[derive(Diagnostic)]
142#[diag(passes_doc_alias_start_end)]
143pub(crate) struct DocAliasStartEnd<'a> {
144    #[primary_span]
145    pub span: Span,
146    pub attr_str: &'a str,
147}
148
149#[derive(Diagnostic)]
150#[diag(passes_doc_alias_bad_location)]
151pub(crate) struct DocAliasBadLocation<'a> {
152    #[primary_span]
153    pub span: Span,
154    pub attr_str: &'a str,
155    pub location: &'a str,
156}
157
158#[derive(Diagnostic)]
159#[diag(passes_doc_alias_not_an_alias)]
160pub(crate) struct DocAliasNotAnAlias<'a> {
161    #[primary_span]
162    pub span: Span,
163    pub attr_str: &'a str,
164}
165
166#[derive(LintDiagnostic)]
167#[diag(passes_doc_alias_duplicated)]
168pub(crate) struct DocAliasDuplicated {
169    #[label]
170    pub first_defn: Span,
171}
172
173#[derive(Diagnostic)]
174#[diag(passes_doc_alias_not_string_literal)]
175pub(crate) struct DocAliasNotStringLiteral {
176    #[primary_span]
177    pub span: Span,
178}
179
180#[derive(Diagnostic)]
181#[diag(passes_doc_alias_malformed)]
182pub(crate) struct DocAliasMalformed {
183    #[primary_span]
184    pub span: Span,
185}
186
187#[derive(Diagnostic)]
188#[diag(passes_doc_keyword_empty_mod)]
189pub(crate) struct DocKeywordEmptyMod {
190    #[primary_span]
191    pub span: Span,
192}
193
194#[derive(Diagnostic)]
195#[diag(passes_doc_keyword_not_keyword)]
196#[help]
197pub(crate) struct DocKeywordNotKeyword {
198    #[primary_span]
199    pub span: Span,
200    pub keyword: Symbol,
201}
202
203#[derive(Diagnostic)]
204#[diag(passes_doc_keyword_not_mod)]
205pub(crate) struct DocKeywordNotMod {
206    #[primary_span]
207    pub span: Span,
208}
209
210#[derive(Diagnostic)]
211#[diag(passes_doc_fake_variadic_not_valid)]
212pub(crate) struct DocFakeVariadicNotValid {
213    #[primary_span]
214    pub span: Span,
215}
216
217#[derive(Diagnostic)]
218#[diag(passes_doc_keyword_only_impl)]
219pub(crate) struct DocKeywordOnlyImpl {
220    #[primary_span]
221    pub span: Span,
222}
223
224#[derive(Diagnostic)]
225#[diag(passes_doc_search_unbox_invalid)]
226pub(crate) struct DocSearchUnboxInvalid {
227    #[primary_span]
228    pub span: Span,
229}
230
231#[derive(Diagnostic)]
232#[diag(passes_doc_inline_conflict)]
233#[help]
234pub(crate) struct DocKeywordConflict {
235    #[primary_span]
236    pub spans: MultiSpan,
237}
238
239#[derive(LintDiagnostic)]
240#[diag(passes_doc_inline_only_use)]
241#[note]
242pub(crate) struct DocInlineOnlyUse {
243    #[label]
244    pub attr_span: Span,
245    #[label(passes_not_a_use_item_label)]
246    pub item_span: Option<Span>,
247}
248
249#[derive(LintDiagnostic)]
250#[diag(passes_doc_masked_only_extern_crate)]
251#[note]
252pub(crate) struct DocMaskedOnlyExternCrate {
253    #[label]
254    pub attr_span: Span,
255    #[label(passes_not_an_extern_crate_label)]
256    pub item_span: Option<Span>,
257}
258
259#[derive(LintDiagnostic)]
260#[diag(passes_doc_masked_not_extern_crate_self)]
261pub(crate) struct DocMaskedNotExternCrateSelf {
262    #[label]
263    pub attr_span: Span,
264    #[label(passes_extern_crate_self_label)]
265    pub item_span: Option<Span>,
266}
267
268#[derive(Diagnostic)]
269#[diag(passes_doc_attr_not_crate_level)]
270pub(crate) 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)]
278pub(crate) struct DocTestUnknown {
279    pub path: String,
280}
281
282#[derive(LintDiagnostic)]
283#[diag(passes_doc_test_literal)]
284pub(crate) struct DocTestLiteral;
285
286#[derive(LintDiagnostic)]
287#[diag(passes_doc_test_takes_list)]
288pub(crate) struct DocTestTakesList;
289
290#[derive(LintDiagnostic)]
291#[diag(passes_doc_cfg_hide_takes_list)]
292pub(crate) struct DocCfgHideTakesList;
293
294#[derive(LintDiagnostic)]
295#[diag(passes_doc_test_unknown_any)]
296pub(crate) struct DocTestUnknownAny {
297    pub path: String,
298}
299
300#[derive(LintDiagnostic)]
301#[diag(passes_doc_test_unknown_spotlight)]
302#[note]
303#[note(passes_no_op_note)]
304pub(crate) 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_passes)]
312#[note]
313#[help]
314#[note(passes_no_op_note)]
315pub(crate) struct DocTestUnknownPasses {
316    pub path: String,
317    #[label]
318    pub span: Span,
319}
320
321#[derive(LintDiagnostic)]
322#[diag(passes_doc_test_unknown_plugins)]
323#[note]
324#[note(passes_no_op_note)]
325pub(crate) struct DocTestUnknownPlugins {
326    pub path: String,
327    #[label]
328    pub span: Span,
329}
330
331#[derive(LintDiagnostic)]
332#[diag(passes_doc_test_unknown_include)]
333pub(crate) struct DocTestUnknownInclude {
334    pub path: String,
335    pub value: String,
336    pub inner: &'static str,
337    #[suggestion(code = "#{inner}[doc = include_str!(\"{value}\")]")]
338    pub sugg: (Span, Applicability),
339}
340
341#[derive(LintDiagnostic)]
342#[diag(passes_doc_invalid)]
343pub(crate) struct DocInvalid;
344
345#[derive(Diagnostic)]
346#[diag(passes_has_incoherent_inherent_impl)]
347pub(crate) struct HasIncoherentInherentImpl {
348    #[primary_span]
349    pub attr_span: Span,
350    #[label]
351    pub span: Span,
352}
353
354#[derive(Diagnostic)]
355#[diag(passes_both_ffi_const_and_pure, code = E0757)]
356pub(crate) struct BothFfiConstAndPure {
357    #[primary_span]
358    pub attr_span: Span,
359}
360
361#[derive(LintDiagnostic)]
362#[diag(passes_must_use_no_effect)]
363pub(crate) struct MustUseNoEffect {
364    pub target: &'static str,
365    #[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
366    pub attr_span: Span,
367}
368
369#[derive(Diagnostic)]
370#[diag(passes_must_not_suspend)]
371pub(crate) struct MustNotSuspend {
372    #[primary_span]
373    pub attr_span: Span,
374    #[label]
375    pub span: Span,
376}
377
378#[derive(LintDiagnostic)]
379#[diag(passes_link)]
380#[warning]
381pub(crate) struct Link {
382    #[label]
383    pub span: Option<Span>,
384}
385
386#[derive(Diagnostic)]
387#[diag(passes_no_link)]
388pub(crate) struct NoLink {
389    #[primary_span]
390    pub attr_span: Span,
391    #[label]
392    pub span: Span,
393}
394
395#[derive(Diagnostic)]
396#[diag(passes_rustc_legacy_const_generics_only)]
397pub(crate) struct RustcLegacyConstGenericsOnly {
398    #[primary_span]
399    pub attr_span: Span,
400    #[label]
401    pub param_span: Span,
402}
403
404#[derive(Diagnostic)]
405#[diag(passes_rustc_legacy_const_generics_index)]
406pub(crate) struct RustcLegacyConstGenericsIndex {
407    #[primary_span]
408    pub attr_span: Span,
409    #[label]
410    pub generics_span: Span,
411}
412
413#[derive(Diagnostic)]
414#[diag(passes_rustc_legacy_const_generics_index_exceed)]
415pub(crate) struct RustcLegacyConstGenericsIndexExceed {
416    #[primary_span]
417    #[label]
418    pub span: Span,
419    pub arg_count: usize,
420}
421
422#[derive(Diagnostic)]
423#[diag(passes_rustc_legacy_const_generics_index_negative)]
424pub(crate) struct RustcLegacyConstGenericsIndexNegative {
425    #[primary_span]
426    pub invalid_args: Vec<Span>,
427}
428
429#[derive(Diagnostic)]
430#[diag(passes_rustc_dirty_clean)]
431pub(crate) struct RustcDirtyClean {
432    #[primary_span]
433    pub span: Span,
434}
435
436#[derive(Diagnostic)]
437#[diag(passes_repr_conflicting, code = E0566)]
438pub(crate) struct ReprConflicting {
439    #[primary_span]
440    pub hint_spans: Vec<Span>,
441}
442
443#[derive(Diagnostic)]
444#[diag(passes_repr_align_greater_than_target_max, code = E0589)]
445#[note]
446pub(crate) struct InvalidReprAlignForTarget {
447    #[primary_span]
448    pub span: Span,
449    pub size: u64,
450}
451
452#[derive(LintDiagnostic)]
453#[diag(passes_repr_conflicting, code = E0566)]
454pub(crate) struct ReprConflictingLint;
455
456#[derive(Diagnostic)]
457#[diag(passes_macro_only_attribute)]
458pub(crate) struct MacroOnlyAttribute {
459    #[primary_span]
460    pub attr_span: Span,
461    #[label]
462    pub span: Span,
463}
464
465#[derive(Diagnostic)]
466#[diag(passes_debug_visualizer_placement)]
467pub(crate) struct DebugVisualizerPlacement {
468    #[primary_span]
469    pub span: Span,
470}
471
472#[derive(Diagnostic)]
473#[diag(passes_debug_visualizer_invalid)]
474#[note(passes_note_1)]
475#[note(passes_note_2)]
476#[note(passes_note_3)]
477pub(crate) struct DebugVisualizerInvalid {
478    #[primary_span]
479    pub span: Span,
480}
481
482#[derive(Diagnostic)]
483#[diag(passes_debug_visualizer_unreadable)]
484pub(crate) struct DebugVisualizerUnreadable<'a> {
485    #[primary_span]
486    pub span: Span,
487    pub file: &'a Path,
488    pub error: Error,
489}
490
491#[derive(Diagnostic)]
492#[diag(passes_rustc_allow_const_fn_unstable)]
493pub(crate) struct RustcAllowConstFnUnstable {
494    #[primary_span]
495    pub attr_span: Span,
496    #[label]
497    pub span: Span,
498}
499
500#[derive(Diagnostic)]
501#[diag(passes_rustc_pub_transparent)]
502pub(crate) struct RustcPubTransparent {
503    #[primary_span]
504    pub attr_span: Span,
505    #[label]
506    pub span: Span,
507}
508
509#[derive(Diagnostic)]
510#[diag(passes_rustc_force_inline_coro)]
511pub(crate) struct RustcForceInlineCoro {
512    #[primary_span]
513    pub attr_span: Span,
514    #[label]
515    pub span: Span,
516}
517
518#[derive(LintDiagnostic)]
519pub(crate) enum MacroExport {
520    #[diag(passes_macro_export)]
521    Normal,
522
523    #[diag(passes_macro_export_on_decl_macro)]
524    #[note]
525    OnDeclMacro,
526
527    #[diag(passes_invalid_macro_export_arguments)]
528    InvalidArgument,
529
530    #[diag(passes_invalid_macro_export_arguments_too_many_items)]
531    TooManyItems,
532}
533
534#[derive(Subdiagnostic)]
535pub(crate) enum UnusedNote {
536    #[note(passes_unused_empty_lints_note)]
537    EmptyList { name: Symbol },
538    #[note(passes_unused_no_lints_note)]
539    NoLints { name: Symbol },
540    #[note(passes_unused_default_method_body_const_note)]
541    DefaultMethodBodyConst,
542    #[note(passes_unused_linker_messages_note)]
543    LinkerMessagesBinaryCrateOnly,
544}
545
546#[derive(LintDiagnostic)]
547#[diag(passes_unused)]
548pub(crate) struct Unused {
549    #[suggestion(code = "", applicability = "machine-applicable")]
550    pub attr_span: Span,
551    #[subdiagnostic]
552    pub note: UnusedNote,
553}
554
555#[derive(Diagnostic)]
556#[diag(passes_non_exported_macro_invalid_attrs, code = E0518)]
557pub(crate) struct NonExportedMacroInvalidAttrs {
558    #[primary_span]
559    #[label]
560    pub attr_span: Span,
561}
562
563#[derive(Diagnostic)]
564#[diag(passes_may_dangle)]
565pub(crate) struct InvalidMayDangle {
566    #[primary_span]
567    pub attr_span: Span,
568}
569
570#[derive(LintDiagnostic)]
571#[diag(passes_unused_duplicate)]
572pub(crate) struct UnusedDuplicate {
573    #[suggestion(code = "", applicability = "machine-applicable")]
574    pub this: Span,
575    #[note]
576    pub other: Span,
577    #[warning]
578    pub warning: bool,
579}
580
581#[derive(Diagnostic)]
582#[diag(passes_unused_multiple)]
583pub(crate) struct UnusedMultiple {
584    #[primary_span]
585    #[suggestion(code = "", applicability = "machine-applicable")]
586    pub this: Span,
587    #[note]
588    pub other: Span,
589    pub name: Symbol,
590}
591
592#[derive(Diagnostic)]
593#[diag(passes_rustc_lint_opt_ty)]
594pub(crate) struct RustcLintOptTy {
595    #[primary_span]
596    pub attr_span: Span,
597    #[label]
598    pub span: Span,
599}
600
601#[derive(Diagnostic)]
602#[diag(passes_rustc_lint_opt_deny_field_access)]
603pub(crate) struct RustcLintOptDenyFieldAccess {
604    #[primary_span]
605    pub attr_span: Span,
606    #[label]
607    pub span: Span,
608}
609
610#[derive(Diagnostic)]
611#[diag(passes_collapse_debuginfo)]
612pub(crate) struct CollapseDebuginfo {
613    #[primary_span]
614    pub attr_span: Span,
615    #[label]
616    pub defn_span: Span,
617}
618
619#[derive(LintDiagnostic)]
620#[diag(passes_deprecated_annotation_has_no_effect)]
621pub(crate) struct DeprecatedAnnotationHasNoEffect {
622    #[suggestion(applicability = "machine-applicable", code = "")]
623    pub span: Span,
624}
625
626#[derive(Diagnostic)]
627#[diag(passes_unknown_external_lang_item, code = E0264)]
628pub(crate) struct UnknownExternLangItem {
629    #[primary_span]
630    pub span: Span,
631    pub lang_item: Symbol,
632}
633
634#[derive(Diagnostic)]
635#[diag(passes_missing_panic_handler)]
636pub(crate) struct MissingPanicHandler;
637
638#[derive(Diagnostic)]
639#[diag(passes_panic_unwind_without_std)]
640#[help]
641#[note]
642pub(crate) struct PanicUnwindWithoutStd;
643
644#[derive(Diagnostic)]
645#[diag(passes_missing_lang_item)]
646#[note]
647#[help]
648pub(crate) struct MissingLangItem {
649    pub name: Symbol,
650}
651
652#[derive(Diagnostic)]
653#[diag(passes_lang_item_fn_with_track_caller)]
654pub(crate) struct LangItemWithTrackCaller {
655    #[primary_span]
656    pub attr_span: Span,
657    pub name: Symbol,
658    #[label]
659    pub sig_span: Span,
660}
661
662#[derive(Diagnostic)]
663#[diag(passes_lang_item_fn_with_target_feature)]
664pub(crate) struct LangItemWithTargetFeature {
665    #[primary_span]
666    pub attr_span: Span,
667    pub name: Symbol,
668    #[label]
669    pub sig_span: Span,
670}
671
672#[derive(Diagnostic)]
673#[diag(passes_lang_item_on_incorrect_target, code = E0718)]
674pub(crate) struct LangItemOnIncorrectTarget {
675    #[primary_span]
676    #[label]
677    pub span: Span,
678    pub name: Symbol,
679    pub expected_target: Target,
680    pub actual_target: Target,
681}
682
683#[derive(Diagnostic)]
684#[diag(passes_unknown_lang_item, code = E0522)]
685pub(crate) struct UnknownLangItem {
686    #[primary_span]
687    #[label]
688    pub span: Span,
689    pub name: Symbol,
690}
691
692pub(crate) struct InvalidAttrAtCrateLevel {
693    pub span: Span,
694    pub sugg_span: Option<Span>,
695    pub name: Symbol,
696    pub item: Option<ItemFollowingInnerAttr>,
697}
698
699#[derive(Clone, Copy)]
700pub(crate) struct ItemFollowingInnerAttr {
701    pub span: Span,
702    pub kind: &'static str,
703}
704
705impl<G: EmissionGuarantee> Diagnostic<'_, G> for InvalidAttrAtCrateLevel {
706    #[track_caller]
707    fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
708        let mut diag = Diag::new(dcx, level, fluent::passes_invalid_attr_at_crate_level);
709        diag.span(self.span);
710        diag.arg("name", self.name);
711        // Only emit an error with a suggestion if we can create a string out
712        // of the attribute span
713        if let Some(span) = self.sugg_span {
714            diag.span_suggestion_verbose(
715                span,
716                fluent::passes_suggestion,
717                String::new(),
718                Applicability::MachineApplicable,
719            );
720        }
721        if let Some(item) = self.item {
722            diag.arg("kind", item.kind);
723            diag.span_label(item.span, fluent::passes_invalid_attr_at_crate_level_item);
724        }
725        diag
726    }
727}
728
729#[derive(Diagnostic)]
730#[diag(passes_duplicate_diagnostic_item_in_crate)]
731pub(crate) struct DuplicateDiagnosticItemInCrate {
732    #[primary_span]
733    pub duplicate_span: Option<Span>,
734    #[note(passes_diagnostic_item_first_defined)]
735    pub orig_span: Option<Span>,
736    #[note]
737    pub different_crates: bool,
738    pub crate_name: Symbol,
739    pub orig_crate_name: Symbol,
740    pub name: Symbol,
741}
742
743#[derive(Diagnostic)]
744#[diag(passes_layout_abi)]
745pub(crate) struct LayoutAbi {
746    #[primary_span]
747    pub span: Span,
748    pub abi: String,
749}
750
751#[derive(Diagnostic)]
752#[diag(passes_layout_align)]
753pub(crate) struct LayoutAlign {
754    #[primary_span]
755    pub span: Span,
756    pub align: String,
757}
758
759#[derive(Diagnostic)]
760#[diag(passes_layout_size)]
761pub(crate) struct LayoutSize {
762    #[primary_span]
763    pub span: Span,
764    pub size: String,
765}
766
767#[derive(Diagnostic)]
768#[diag(passes_layout_homogeneous_aggregate)]
769pub(crate) struct LayoutHomogeneousAggregate {
770    #[primary_span]
771    pub span: Span,
772    pub homogeneous_aggregate: String,
773}
774
775#[derive(Diagnostic)]
776#[diag(passes_layout_of)]
777pub(crate) struct LayoutOf<'tcx> {
778    #[primary_span]
779    pub span: Span,
780    pub normalized_ty: Ty<'tcx>,
781    pub ty_layout: String,
782}
783
784#[derive(Diagnostic)]
785#[diag(passes_layout_invalid_attribute)]
786pub(crate) struct LayoutInvalidAttribute {
787    #[primary_span]
788    pub span: Span,
789}
790
791#[derive(Diagnostic)]
792#[diag(passes_abi_of)]
793pub(crate) struct AbiOf {
794    #[primary_span]
795    pub span: Span,
796    pub fn_name: Symbol,
797    pub fn_abi: String,
798}
799
800#[derive(Diagnostic)]
801#[diag(passes_abi_ne)]
802pub(crate) struct AbiNe {
803    #[primary_span]
804    pub span: Span,
805    pub left: String,
806    pub right: String,
807}
808
809#[derive(Diagnostic)]
810#[diag(passes_abi_invalid_attribute)]
811pub(crate) struct AbiInvalidAttribute {
812    #[primary_span]
813    pub span: Span,
814}
815
816#[derive(Diagnostic)]
817#[diag(passes_unrecognized_argument)]
818pub(crate) struct UnrecognizedArgument {
819    #[primary_span]
820    pub span: Span,
821}
822
823#[derive(Diagnostic)]
824#[diag(passes_feature_stable_twice, code = E0711)]
825pub(crate) struct FeatureStableTwice {
826    #[primary_span]
827    pub span: Span,
828    pub feature: Symbol,
829    pub since: Symbol,
830    pub prev_since: Symbol,
831}
832
833#[derive(Diagnostic)]
834#[diag(passes_feature_previously_declared, code = E0711)]
835pub(crate) struct FeaturePreviouslyDeclared<'a> {
836    #[primary_span]
837    pub span: Span,
838    pub feature: Symbol,
839    pub declared: &'a str,
840    pub prev_declared: &'a str,
841}
842
843#[derive(Diagnostic)]
844#[diag(passes_attr_only_in_functions)]
845pub(crate) struct AttrOnlyInFunctions {
846    #[primary_span]
847    pub span: Span,
848    pub attr: Symbol,
849}
850
851#[derive(Diagnostic)]
852#[diag(passes_multiple_rustc_main, code = E0137)]
853pub(crate) struct MultipleRustcMain {
854    #[primary_span]
855    pub span: Span,
856    #[label(passes_first)]
857    pub first: Span,
858    #[label(passes_additional)]
859    pub additional: Span,
860}
861
862#[derive(Diagnostic)]
863#[diag(passes_extern_main)]
864pub(crate) struct ExternMain {
865    #[primary_span]
866    pub span: Span,
867}
868
869pub(crate) struct NoMainErr {
870    pub sp: Span,
871    pub crate_name: Symbol,
872    pub has_filename: bool,
873    pub filename: PathBuf,
874    pub file_empty: bool,
875    pub non_main_fns: Vec<Span>,
876    pub main_def_opt: Option<MainDefinition>,
877    pub add_teach_note: bool,
878}
879
880impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for NoMainErr {
881    #[track_caller]
882    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
883        let mut diag = Diag::new(dcx, level, fluent::passes_no_main_function);
884        diag.span(DUMMY_SP);
885        diag.code(E0601);
886        diag.arg("crate_name", self.crate_name);
887        diag.arg("filename", self.filename);
888        diag.arg("has_filename", self.has_filename);
889        let note = if !self.non_main_fns.is_empty() {
890            for &span in &self.non_main_fns {
891                diag.span_note(span, fluent::passes_here_is_main);
892            }
893            diag.note(fluent::passes_one_or_more_possible_main);
894            diag.help(fluent::passes_consider_moving_main);
895            // There were some functions named `main` though. Try to give the user a hint.
896            fluent::passes_main_must_be_defined_at_crate
897        } else if self.has_filename {
898            fluent::passes_consider_adding_main_to_file
899        } else {
900            fluent::passes_consider_adding_main_at_crate
901        };
902        if self.file_empty {
903            diag.note(note);
904        } else {
905            diag.span(self.sp.shrink_to_hi());
906            diag.span_label(self.sp.shrink_to_hi(), note);
907        }
908
909        if let Some(main_def) = self.main_def_opt
910            && main_def.opt_fn_def_id().is_none()
911        {
912            // There is something at `crate::main`, but it is not a function definition.
913            diag.span_label(main_def.span, fluent::passes_non_function_main);
914        }
915
916        if self.add_teach_note {
917            diag.note(fluent::passes_teach_note);
918        }
919        diag
920    }
921}
922
923pub(crate) struct DuplicateLangItem {
924    pub local_span: Option<Span>,
925    pub lang_item_name: Symbol,
926    pub crate_name: Symbol,
927    pub dependency_of: Option<Symbol>,
928    pub is_local: bool,
929    pub path: String,
930    pub first_defined_span: Option<Span>,
931    pub orig_crate_name: Option<Symbol>,
932    pub orig_dependency_of: Option<Symbol>,
933    pub orig_is_local: bool,
934    pub orig_path: String,
935    pub(crate) duplicate: Duplicate,
936}
937
938impl<G: EmissionGuarantee> Diagnostic<'_, G> for DuplicateLangItem {
939    #[track_caller]
940    fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
941        let mut diag = Diag::new(
942            dcx,
943            level,
944            match self.duplicate {
945                Duplicate::Plain => fluent::passes_duplicate_lang_item,
946                Duplicate::Crate => fluent::passes_duplicate_lang_item_crate,
947                Duplicate::CrateDepends => fluent::passes_duplicate_lang_item_crate_depends,
948            },
949        );
950        diag.code(E0152);
951        diag.arg("lang_item_name", self.lang_item_name);
952        diag.arg("crate_name", self.crate_name);
953        if let Some(dependency_of) = self.dependency_of {
954            diag.arg("dependency_of", dependency_of);
955        }
956        diag.arg("path", self.path);
957        if let Some(orig_crate_name) = self.orig_crate_name {
958            diag.arg("orig_crate_name", orig_crate_name);
959        }
960        if let Some(orig_dependency_of) = self.orig_dependency_of {
961            diag.arg("orig_dependency_of", orig_dependency_of);
962        }
963        diag.arg("orig_path", self.orig_path);
964        if let Some(span) = self.local_span {
965            diag.span(span);
966        }
967        if let Some(span) = self.first_defined_span {
968            diag.span_note(span, fluent::passes_first_defined_span);
969        } else {
970            if self.orig_dependency_of.is_none() {
971                diag.note(fluent::passes_first_defined_crate);
972            } else {
973                diag.note(fluent::passes_first_defined_crate_depends);
974            }
975
976            if self.orig_is_local {
977                diag.note(fluent::passes_first_definition_local);
978            } else {
979                diag.note(fluent::passes_first_definition_path);
980            }
981
982            if self.is_local {
983                diag.note(fluent::passes_second_definition_local);
984            } else {
985                diag.note(fluent::passes_second_definition_path);
986            }
987        }
988        diag
989    }
990}
991
992#[derive(Diagnostic)]
993#[diag(passes_incorrect_target, code = E0718)]
994pub(crate) struct IncorrectTarget<'a> {
995    #[primary_span]
996    pub span: Span,
997    #[label]
998    pub generics_span: Span,
999    pub name: &'a str, // cannot be symbol because it renders e.g. `r#fn` instead of `fn`
1000    pub kind: &'static str,
1001    pub num: usize,
1002    pub actual_num: usize,
1003    pub at_least: bool,
1004}
1005
1006#[derive(Diagnostic)]
1007#[diag(passes_incorrect_crate_type)]
1008pub(crate) struct IncorrectCrateType {
1009    #[primary_span]
1010    pub span: Span,
1011}
1012
1013#[derive(LintDiagnostic)]
1014#[diag(passes_useless_assignment)]
1015pub(crate) struct UselessAssignment<'a> {
1016    pub is_field_assign: bool,
1017    pub ty: Ty<'a>,
1018}
1019
1020#[derive(LintDiagnostic)]
1021#[diag(passes_inline_ignored_for_exported)]
1022#[help]
1023pub(crate) struct InlineIgnoredForExported {}
1024
1025#[derive(Diagnostic)]
1026#[diag(passes_object_lifetime_err)]
1027pub(crate) struct ObjectLifetimeErr {
1028    #[primary_span]
1029    pub span: Span,
1030    pub repr: String,
1031}
1032
1033#[derive(Diagnostic)]
1034pub(crate) enum AttrApplication {
1035    #[diag(passes_attr_application_enum, code = E0517)]
1036    Enum {
1037        #[primary_span]
1038        hint_span: Span,
1039        #[label]
1040        span: Span,
1041    },
1042    #[diag(passes_attr_application_struct, code = E0517)]
1043    Struct {
1044        #[primary_span]
1045        hint_span: Span,
1046        #[label]
1047        span: Span,
1048    },
1049    #[diag(passes_attr_application_struct_union, code = E0517)]
1050    StructUnion {
1051        #[primary_span]
1052        hint_span: Span,
1053        #[label]
1054        span: Span,
1055    },
1056    #[diag(passes_attr_application_struct_enum_union, code = E0517)]
1057    StructEnumUnion {
1058        #[primary_span]
1059        hint_span: Span,
1060        #[label]
1061        span: Span,
1062    },
1063}
1064
1065#[derive(Diagnostic)]
1066#[diag(passes_transparent_incompatible, code = E0692)]
1067pub(crate) struct TransparentIncompatible {
1068    #[primary_span]
1069    pub hint_spans: Vec<Span>,
1070    pub target: String,
1071}
1072
1073#[derive(Diagnostic)]
1074#[diag(passes_deprecated_attribute, code = E0549)]
1075pub(crate) struct DeprecatedAttribute {
1076    #[primary_span]
1077    pub span: Span,
1078}
1079
1080#[derive(Diagnostic)]
1081#[diag(passes_useless_stability)]
1082pub(crate) struct UselessStability {
1083    #[primary_span]
1084    #[label]
1085    pub span: Span,
1086    #[label(passes_item)]
1087    pub item_sp: Span,
1088}
1089
1090#[derive(Diagnostic)]
1091#[diag(passes_cannot_stabilize_deprecated)]
1092pub(crate) struct CannotStabilizeDeprecated {
1093    #[primary_span]
1094    #[label]
1095    pub span: Span,
1096    #[label(passes_item)]
1097    pub item_sp: Span,
1098}
1099
1100#[derive(Diagnostic)]
1101#[diag(passes_unstable_attr_for_already_stable_feature)]
1102pub(crate) struct UnstableAttrForAlreadyStableFeature {
1103    #[primary_span]
1104    #[label]
1105    #[help]
1106    pub attr_span: Span,
1107    #[label(passes_item)]
1108    pub item_span: Span,
1109}
1110
1111#[derive(Diagnostic)]
1112#[diag(passes_missing_stability_attr)]
1113pub(crate) struct MissingStabilityAttr<'a> {
1114    #[primary_span]
1115    pub span: Span,
1116    pub descr: &'a str,
1117}
1118
1119#[derive(Diagnostic)]
1120#[diag(passes_missing_const_stab_attr)]
1121pub(crate) struct MissingConstStabAttr<'a> {
1122    #[primary_span]
1123    pub span: Span,
1124    pub descr: &'a str,
1125}
1126
1127#[derive(Diagnostic)]
1128#[diag(passes_trait_impl_const_stable)]
1129#[note]
1130pub(crate) struct TraitImplConstStable {
1131    #[primary_span]
1132    pub span: Span,
1133}
1134
1135#[derive(Diagnostic)]
1136#[diag(passes_trait_impl_const_stability_mismatch)]
1137pub(crate) struct TraitImplConstStabilityMismatch {
1138    #[primary_span]
1139    pub span: Span,
1140    #[subdiagnostic]
1141    pub impl_stability: ImplConstStability,
1142    #[subdiagnostic]
1143    pub trait_stability: TraitConstStability,
1144}
1145
1146#[derive(Subdiagnostic)]
1147pub(crate) enum TraitConstStability {
1148    #[note(passes_trait_impl_const_stability_mismatch_trait_stable)]
1149    Stable {
1150        #[primary_span]
1151        span: Span,
1152    },
1153    #[note(passes_trait_impl_const_stability_mismatch_trait_unstable)]
1154    Unstable {
1155        #[primary_span]
1156        span: Span,
1157    },
1158}
1159
1160#[derive(Subdiagnostic)]
1161pub(crate) enum ImplConstStability {
1162    #[note(passes_trait_impl_const_stability_mismatch_impl_stable)]
1163    Stable {
1164        #[primary_span]
1165        span: Span,
1166    },
1167    #[note(passes_trait_impl_const_stability_mismatch_impl_unstable)]
1168    Unstable {
1169        #[primary_span]
1170        span: Span,
1171    },
1172}
1173
1174#[derive(Diagnostic)]
1175#[diag(passes_unknown_feature, code = E0635)]
1176pub(crate) struct UnknownFeature {
1177    #[primary_span]
1178    pub span: Span,
1179    pub feature: Symbol,
1180}
1181
1182#[derive(Diagnostic)]
1183#[diag(passes_unknown_feature_alias, code = E0635)]
1184pub(crate) struct RenamedFeature {
1185    #[primary_span]
1186    pub span: Span,
1187    pub feature: Symbol,
1188    pub alias: Symbol,
1189}
1190
1191#[derive(Diagnostic)]
1192#[diag(passes_implied_feature_not_exist)]
1193pub(crate) struct ImpliedFeatureNotExist {
1194    #[primary_span]
1195    pub span: Span,
1196    pub feature: Symbol,
1197    pub implied_by: Symbol,
1198}
1199
1200#[derive(Diagnostic)]
1201#[diag(passes_duplicate_feature_err, code = E0636)]
1202pub(crate) struct DuplicateFeatureErr {
1203    #[primary_span]
1204    pub span: Span,
1205    pub feature: Symbol,
1206}
1207
1208#[derive(Diagnostic)]
1209#[diag(passes_missing_const_err)]
1210pub(crate) struct MissingConstErr {
1211    #[primary_span]
1212    #[help]
1213    pub fn_sig_span: Span,
1214}
1215
1216#[derive(Diagnostic)]
1217#[diag(passes_const_stable_not_stable)]
1218pub(crate) struct ConstStableNotStable {
1219    #[primary_span]
1220    pub fn_sig_span: Span,
1221    #[label]
1222    pub const_span: Span,
1223}
1224
1225#[derive(LintDiagnostic)]
1226pub(crate) enum MultipleDeadCodes<'tcx> {
1227    #[diag(passes_dead_codes)]
1228    DeadCodes {
1229        multiple: bool,
1230        num: usize,
1231        descr: &'tcx str,
1232        participle: &'tcx str,
1233        name_list: DiagSymbolList,
1234        #[subdiagnostic]
1235        // only on DeadCodes since it's never a problem for tuple struct fields
1236        enum_variants_with_same_name: Vec<EnumVariantSameName<'tcx>>,
1237        #[subdiagnostic]
1238        parent_info: Option<ParentInfo<'tcx>>,
1239        #[subdiagnostic]
1240        ignored_derived_impls: Option<IgnoredDerivedImpls>,
1241    },
1242    #[diag(passes_dead_codes)]
1243    UnusedTupleStructFields {
1244        multiple: bool,
1245        num: usize,
1246        descr: &'tcx str,
1247        participle: &'tcx str,
1248        name_list: DiagSymbolList,
1249        #[subdiagnostic]
1250        change_fields_suggestion: ChangeFields,
1251        #[subdiagnostic]
1252        parent_info: Option<ParentInfo<'tcx>>,
1253        #[subdiagnostic]
1254        ignored_derived_impls: Option<IgnoredDerivedImpls>,
1255    },
1256}
1257
1258#[derive(Subdiagnostic)]
1259#[note(passes_enum_variant_same_name)]
1260pub(crate) struct EnumVariantSameName<'tcx> {
1261    #[primary_span]
1262    pub variant_span: Span,
1263    pub dead_name: Symbol,
1264    pub dead_descr: &'tcx str,
1265}
1266
1267#[derive(Subdiagnostic)]
1268#[label(passes_parent_info)]
1269pub(crate) struct ParentInfo<'tcx> {
1270    pub num: usize,
1271    pub descr: &'tcx str,
1272    pub parent_descr: &'tcx str,
1273    #[primary_span]
1274    pub span: Span,
1275}
1276
1277#[derive(Subdiagnostic)]
1278#[note(passes_ignored_derived_impls)]
1279pub(crate) struct IgnoredDerivedImpls {
1280    pub name: Symbol,
1281    pub trait_list: DiagSymbolList,
1282    pub trait_list_len: usize,
1283}
1284
1285#[derive(Subdiagnostic)]
1286pub(crate) enum ChangeFields {
1287    #[multipart_suggestion(
1288        passes_change_fields_to_be_of_unit_type,
1289        applicability = "has-placeholders"
1290    )]
1291    ChangeToUnitTypeOrRemove {
1292        num: usize,
1293        #[suggestion_part(code = "()")]
1294        spans: Vec<Span>,
1295    },
1296    #[help(passes_remove_fields)]
1297    Remove { num: usize },
1298}
1299
1300#[derive(Diagnostic)]
1301#[diag(passes_proc_macro_bad_sig)]
1302pub(crate) struct ProcMacroBadSig {
1303    #[primary_span]
1304    pub span: Span,
1305    pub kind: ProcMacroKind,
1306}
1307
1308#[derive(LintDiagnostic)]
1309#[diag(passes_unreachable_due_to_uninhabited)]
1310pub(crate) struct UnreachableDueToUninhabited<'desc, 'tcx> {
1311    pub descr: &'desc str,
1312    #[label]
1313    pub expr: Span,
1314    #[label(passes_label_orig)]
1315    #[note]
1316    pub orig: Span,
1317    pub ty: Ty<'tcx>,
1318}
1319
1320#[derive(LintDiagnostic)]
1321#[diag(passes_unused_var_maybe_capture_ref)]
1322#[help]
1323pub(crate) struct UnusedVarMaybeCaptureRef {
1324    pub name: String,
1325}
1326
1327#[derive(LintDiagnostic)]
1328#[diag(passes_unused_capture_maybe_capture_ref)]
1329#[help]
1330pub(crate) struct UnusedCaptureMaybeCaptureRef {
1331    pub name: String,
1332}
1333
1334#[derive(LintDiagnostic)]
1335#[diag(passes_unused_var_remove_field)]
1336pub(crate) struct UnusedVarRemoveField {
1337    pub name: String,
1338    #[subdiagnostic]
1339    pub sugg: UnusedVarRemoveFieldSugg,
1340}
1341
1342#[derive(Subdiagnostic)]
1343#[multipart_suggestion(
1344    passes_unused_var_remove_field_suggestion,
1345    applicability = "machine-applicable"
1346)]
1347pub(crate) struct UnusedVarRemoveFieldSugg {
1348    #[suggestion_part(code = "")]
1349    pub spans: Vec<Span>,
1350}
1351
1352#[derive(LintDiagnostic)]
1353#[diag(passes_unused_var_assigned_only)]
1354#[note]
1355pub(crate) struct UnusedVarAssignedOnly {
1356    pub name: String,
1357}
1358
1359#[derive(LintDiagnostic)]
1360#[diag(passes_unnecessary_stable_feature)]
1361pub(crate) struct UnnecessaryStableFeature {
1362    pub feature: Symbol,
1363    pub since: Symbol,
1364}
1365
1366#[derive(LintDiagnostic)]
1367#[diag(passes_unnecessary_partial_stable_feature)]
1368pub(crate) struct UnnecessaryPartialStableFeature {
1369    #[suggestion(code = "{implies}", applicability = "maybe-incorrect")]
1370    pub span: Span,
1371    #[suggestion(passes_suggestion_remove, code = "", applicability = "maybe-incorrect")]
1372    pub line: Span,
1373    pub feature: Symbol,
1374    pub since: Symbol,
1375    pub implies: Symbol,
1376}
1377
1378#[derive(LintDiagnostic)]
1379#[diag(passes_ineffective_unstable_impl)]
1380#[note]
1381pub(crate) struct IneffectiveUnstableImpl;
1382
1383#[derive(LintDiagnostic)]
1384#[diag(passes_unused_assign)]
1385pub(crate) struct UnusedAssign {
1386    pub name: String,
1387    #[subdiagnostic]
1388    pub suggestion: Option<UnusedAssignSuggestion>,
1389    #[help]
1390    pub help: bool,
1391}
1392
1393#[derive(Subdiagnostic)]
1394#[multipart_suggestion(passes_unused_assign_suggestion, applicability = "maybe-incorrect")]
1395pub(crate) struct UnusedAssignSuggestion {
1396    pub pre: &'static str,
1397    #[suggestion_part(code = "{pre}mut ")]
1398    pub ty_span: Option<Span>,
1399    #[suggestion_part(code = "")]
1400    pub ty_ref_span: Span,
1401    #[suggestion_part(code = "*")]
1402    pub ident_span: Span,
1403    #[suggestion_part(code = "")]
1404    pub expr_ref_span: Span,
1405}
1406
1407#[derive(LintDiagnostic)]
1408#[diag(passes_unused_assign_passed)]
1409#[help]
1410pub(crate) struct UnusedAssignPassed {
1411    pub name: String,
1412}
1413
1414#[derive(LintDiagnostic)]
1415#[diag(passes_unused_variable_try_prefix)]
1416pub(crate) struct UnusedVariableTryPrefix {
1417    #[label]
1418    pub label: Option<Span>,
1419    #[subdiagnostic]
1420    pub string_interp: Vec<UnusedVariableStringInterp>,
1421    #[subdiagnostic]
1422    pub sugg: UnusedVariableSugg,
1423    pub name: String,
1424}
1425
1426#[derive(Subdiagnostic)]
1427pub(crate) enum UnusedVariableSugg {
1428    #[multipart_suggestion(passes_suggestion, applicability = "maybe-incorrect")]
1429    TryPrefixSugg {
1430        #[suggestion_part(code = "_{name}")]
1431        spans: Vec<Span>,
1432        name: String,
1433    },
1434    #[help(passes_unused_variable_args_in_macro)]
1435    NoSugg {
1436        #[primary_span]
1437        span: Span,
1438        name: String,
1439    },
1440}
1441
1442pub(crate) struct UnusedVariableStringInterp {
1443    pub lit: Span,
1444    pub lo: Span,
1445    pub hi: Span,
1446}
1447
1448impl Subdiagnostic for UnusedVariableStringInterp {
1449    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1450        diag.span_label(self.lit, crate::fluent_generated::passes_maybe_string_interpolation);
1451        diag.multipart_suggestion(
1452            crate::fluent_generated::passes_string_interpolation_only_works,
1453            vec![(self.lo, String::from("format!(")), (self.hi, String::from(")"))],
1454            Applicability::MachineApplicable,
1455        );
1456    }
1457}
1458
1459#[derive(LintDiagnostic)]
1460#[diag(passes_unused_variable_try_ignore)]
1461pub(crate) struct UnusedVarTryIgnore {
1462    pub name: String,
1463    #[subdiagnostic]
1464    pub sugg: UnusedVarTryIgnoreSugg,
1465}
1466
1467#[derive(Subdiagnostic)]
1468#[multipart_suggestion(passes_suggestion, applicability = "maybe-incorrect")]
1469pub(crate) struct UnusedVarTryIgnoreSugg {
1470    #[suggestion_part(code = "{name}: _")]
1471    pub shorthands: Vec<Span>,
1472    #[suggestion_part(code = "_")]
1473    pub non_shorthands: Vec<Span>,
1474    pub name: String,
1475}
1476
1477#[derive(LintDiagnostic)]
1478#[diag(passes_attr_crate_level)]
1479#[note]
1480pub(crate) struct AttrCrateLevelOnly {
1481    #[subdiagnostic]
1482    pub sugg: Option<AttrCrateLevelOnlySugg>,
1483}
1484
1485#[derive(Subdiagnostic)]
1486#[suggestion(passes_suggestion, applicability = "maybe-incorrect", code = "!", style = "verbose")]
1487pub(crate) struct AttrCrateLevelOnlySugg {
1488    #[primary_span]
1489    pub attr: Span,
1490}
1491
1492#[derive(Diagnostic)]
1493#[diag(passes_no_sanitize)]
1494pub(crate) struct NoSanitize<'a> {
1495    #[primary_span]
1496    pub attr_span: Span,
1497    #[label]
1498    pub defn_span: Span,
1499    pub accepted_kind: &'a str,
1500    pub attr_str: &'a str,
1501}
1502
1503// FIXME(jdonszelmann): move back to rustc_attr
1504#[derive(Diagnostic)]
1505#[diag(passes_rustc_const_stable_indirect_pairing)]
1506pub(crate) struct RustcConstStableIndirectPairing {
1507    #[primary_span]
1508    pub span: Span,
1509}
1510
1511#[derive(Diagnostic)]
1512#[diag(passes_unsupported_attributes_in_where)]
1513#[help]
1514pub(crate) struct UnsupportedAttributesInWhere {
1515    #[primary_span]
1516    pub span: MultiSpan,
1517}
1518
1519#[derive(Diagnostic)]
1520pub(crate) enum UnexportableItem<'a> {
1521    #[diag(passes_unexportable_item)]
1522    Item {
1523        #[primary_span]
1524        span: Span,
1525        descr: &'a str,
1526    },
1527
1528    #[diag(passes_unexportable_generic_fn)]
1529    GenericFn(#[primary_span] Span),
1530
1531    #[diag(passes_unexportable_fn_abi)]
1532    FnAbi(#[primary_span] Span),
1533
1534    #[diag(passes_unexportable_type_repr)]
1535    TypeRepr(#[primary_span] Span),
1536
1537    #[diag(passes_unexportable_type_in_interface)]
1538    TypeInInterface {
1539        #[primary_span]
1540        span: Span,
1541        desc: &'a str,
1542        ty: &'a str,
1543        #[label]
1544        ty_span: Span,
1545    },
1546
1547    #[diag(passes_unexportable_priv_item)]
1548    PrivItem {
1549        #[primary_span]
1550        span: Span,
1551        #[note]
1552        vis_note: Span,
1553        vis_descr: &'a str,
1554    },
1555
1556    #[diag(passes_unexportable_adt_with_private_fields)]
1557    AdtWithPrivFields {
1558        #[primary_span]
1559        span: Span,
1560        #[note]
1561        vis_note: Span,
1562        field_name: &'a str,
1563    },
1564}
1565
1566#[derive(Diagnostic)]
1567#[diag(passes_repr_align_should_be_align)]
1568pub(crate) struct ReprAlignShouldBeAlign {
1569    #[primary_span]
1570    #[help]
1571    pub span: Span,
1572    pub item: &'static str,
1573}
1574
1575#[derive(Diagnostic)]
1576#[diag(passes_custom_mir_phase_requires_dialect)]
1577pub(crate) struct CustomMirPhaseRequiresDialect {
1578    #[primary_span]
1579    pub attr_span: Span,
1580    #[label]
1581    pub phase_span: Span,
1582}
1583
1584#[derive(Diagnostic)]
1585#[diag(passes_custom_mir_incompatible_dialect_and_phase)]
1586pub(crate) struct CustomMirIncompatibleDialectAndPhase {
1587    pub dialect: MirDialect,
1588    pub phase: MirPhase,
1589    #[primary_span]
1590    pub attr_span: Span,
1591    #[label]
1592    pub dialect_span: Span,
1593    #[label]
1594    pub phase_span: Span,
1595}