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