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(Diagnostic)]
362#[diag(passes_must_not_suspend)]
363pub(crate) struct MustNotSuspend {
364    #[primary_span]
365    pub attr_span: Span,
366    #[label]
367    pub span: Span,
368}
369
370#[derive(LintDiagnostic)]
371#[diag(passes_link)]
372#[warning]
373pub(crate) struct Link {
374    #[label]
375    pub span: Option<Span>,
376}
377
378#[derive(Diagnostic)]
379#[diag(passes_no_link)]
380pub(crate) struct NoLink {
381    #[primary_span]
382    pub attr_span: Span,
383    #[label]
384    pub span: Span,
385}
386
387#[derive(Diagnostic)]
388#[diag(passes_rustc_legacy_const_generics_only)]
389pub(crate) struct RustcLegacyConstGenericsOnly {
390    #[primary_span]
391    pub attr_span: Span,
392    #[label]
393    pub param_span: Span,
394}
395
396#[derive(Diagnostic)]
397#[diag(passes_rustc_legacy_const_generics_index)]
398pub(crate) struct RustcLegacyConstGenericsIndex {
399    #[primary_span]
400    pub attr_span: Span,
401    #[label]
402    pub generics_span: Span,
403}
404
405#[derive(Diagnostic)]
406#[diag(passes_rustc_legacy_const_generics_index_exceed)]
407pub(crate) struct RustcLegacyConstGenericsIndexExceed {
408    #[primary_span]
409    #[label]
410    pub span: Span,
411    pub arg_count: usize,
412}
413
414#[derive(Diagnostic)]
415#[diag(passes_rustc_legacy_const_generics_index_negative)]
416pub(crate) struct RustcLegacyConstGenericsIndexNegative {
417    #[primary_span]
418    pub invalid_args: Vec<Span>,
419}
420
421#[derive(Diagnostic)]
422#[diag(passes_rustc_dirty_clean)]
423pub(crate) struct RustcDirtyClean {
424    #[primary_span]
425    pub span: Span,
426}
427
428#[derive(Diagnostic)]
429#[diag(passes_repr_conflicting, code = E0566)]
430pub(crate) struct ReprConflicting {
431    #[primary_span]
432    pub hint_spans: Vec<Span>,
433}
434
435#[derive(Diagnostic)]
436#[diag(passes_repr_align_greater_than_target_max, code = E0589)]
437#[note]
438pub(crate) struct InvalidReprAlignForTarget {
439    #[primary_span]
440    pub span: Span,
441    pub size: u64,
442}
443
444#[derive(LintDiagnostic)]
445#[diag(passes_repr_conflicting, code = E0566)]
446pub(crate) struct ReprConflictingLint;
447
448#[derive(Diagnostic)]
449#[diag(passes_macro_only_attribute)]
450pub(crate) struct MacroOnlyAttribute {
451    #[primary_span]
452    pub attr_span: Span,
453    #[label]
454    pub span: Span,
455}
456
457#[derive(Diagnostic)]
458#[diag(passes_debug_visualizer_placement)]
459pub(crate) struct DebugVisualizerPlacement {
460    #[primary_span]
461    pub span: Span,
462}
463
464#[derive(Diagnostic)]
465#[diag(passes_debug_visualizer_invalid)]
466#[note(passes_note_1)]
467#[note(passes_note_2)]
468#[note(passes_note_3)]
469pub(crate) struct DebugVisualizerInvalid {
470    #[primary_span]
471    pub span: Span,
472}
473
474#[derive(Diagnostic)]
475#[diag(passes_debug_visualizer_unreadable)]
476pub(crate) struct DebugVisualizerUnreadable<'a> {
477    #[primary_span]
478    pub span: Span,
479    pub file: &'a Path,
480    pub error: Error,
481}
482
483#[derive(Diagnostic)]
484#[diag(passes_rustc_allow_const_fn_unstable)]
485pub(crate) struct RustcAllowConstFnUnstable {
486    #[primary_span]
487    pub attr_span: Span,
488    #[label]
489    pub span: Span,
490}
491
492#[derive(Diagnostic)]
493#[diag(passes_rustc_pub_transparent)]
494pub(crate) struct RustcPubTransparent {
495    #[primary_span]
496    pub attr_span: Span,
497    #[label]
498    pub span: Span,
499}
500
501#[derive(Diagnostic)]
502#[diag(passes_rustc_force_inline_coro)]
503pub(crate) struct RustcForceInlineCoro {
504    #[primary_span]
505    pub attr_span: Span,
506    #[label]
507    pub span: Span,
508}
509
510#[derive(LintDiagnostic)]
511pub(crate) enum MacroExport {
512    #[diag(passes_macro_export)]
513    Normal,
514
515    #[diag(passes_macro_export_on_decl_macro)]
516    #[note]
517    OnDeclMacro,
518
519    #[diag(passes_invalid_macro_export_arguments)]
520    InvalidArgument,
521
522    #[diag(passes_invalid_macro_export_arguments_too_many_items)]
523    TooManyItems,
524}
525
526#[derive(Subdiagnostic)]
527pub(crate) enum UnusedNote {
528    #[note(passes_unused_empty_lints_note)]
529    EmptyList { name: Symbol },
530    #[note(passes_unused_no_lints_note)]
531    NoLints { name: Symbol },
532    #[note(passes_unused_default_method_body_const_note)]
533    DefaultMethodBodyConst,
534    #[note(passes_unused_linker_messages_note)]
535    LinkerMessagesBinaryCrateOnly,
536}
537
538#[derive(LintDiagnostic)]
539#[diag(passes_unused)]
540pub(crate) struct Unused {
541    #[suggestion(code = "", applicability = "machine-applicable")]
542    pub attr_span: Span,
543    #[subdiagnostic]
544    pub note: UnusedNote,
545}
546
547#[derive(Diagnostic)]
548#[diag(passes_non_exported_macro_invalid_attrs, code = E0518)]
549pub(crate) struct NonExportedMacroInvalidAttrs {
550    #[primary_span]
551    #[label]
552    pub attr_span: Span,
553}
554
555#[derive(Diagnostic)]
556#[diag(passes_may_dangle)]
557pub(crate) struct InvalidMayDangle {
558    #[primary_span]
559    pub attr_span: Span,
560}
561
562#[derive(LintDiagnostic)]
563#[diag(passes_unused_duplicate)]
564pub(crate) struct UnusedDuplicate {
565    #[suggestion(code = "", applicability = "machine-applicable")]
566    pub this: Span,
567    #[note]
568    pub other: Span,
569    #[warning]
570    pub warning: bool,
571}
572
573#[derive(Diagnostic)]
574#[diag(passes_unused_multiple)]
575pub(crate) struct UnusedMultiple {
576    #[primary_span]
577    #[suggestion(code = "", applicability = "machine-applicable")]
578    pub this: Span,
579    #[note]
580    pub other: Span,
581    pub name: Symbol,
582}
583
584#[derive(Diagnostic)]
585#[diag(passes_rustc_lint_opt_ty)]
586pub(crate) struct RustcLintOptTy {
587    #[primary_span]
588    pub attr_span: Span,
589    #[label]
590    pub span: Span,
591}
592
593#[derive(Diagnostic)]
594#[diag(passes_rustc_lint_opt_deny_field_access)]
595pub(crate) struct RustcLintOptDenyFieldAccess {
596    #[primary_span]
597    pub attr_span: Span,
598    #[label]
599    pub span: Span,
600}
601
602#[derive(Diagnostic)]
603#[diag(passes_collapse_debuginfo)]
604pub(crate) struct CollapseDebuginfo {
605    #[primary_span]
606    pub attr_span: Span,
607    #[label]
608    pub defn_span: Span,
609}
610
611#[derive(LintDiagnostic)]
612#[diag(passes_deprecated_annotation_has_no_effect)]
613pub(crate) struct DeprecatedAnnotationHasNoEffect {
614    #[suggestion(applicability = "machine-applicable", code = "")]
615    pub span: Span,
616}
617
618#[derive(Diagnostic)]
619#[diag(passes_unknown_external_lang_item, code = E0264)]
620pub(crate) struct UnknownExternLangItem {
621    #[primary_span]
622    pub span: Span,
623    pub lang_item: Symbol,
624}
625
626#[derive(Diagnostic)]
627#[diag(passes_missing_panic_handler)]
628pub(crate) struct MissingPanicHandler;
629
630#[derive(Diagnostic)]
631#[diag(passes_panic_unwind_without_std)]
632#[help]
633#[note]
634pub(crate) struct PanicUnwindWithoutStd;
635
636#[derive(Diagnostic)]
637#[diag(passes_missing_lang_item)]
638#[note]
639#[help]
640pub(crate) struct MissingLangItem {
641    pub name: Symbol,
642}
643
644#[derive(Diagnostic)]
645#[diag(passes_lang_item_fn_with_track_caller)]
646pub(crate) struct LangItemWithTrackCaller {
647    #[primary_span]
648    pub attr_span: Span,
649    pub name: Symbol,
650    #[label]
651    pub sig_span: Span,
652}
653
654#[derive(Diagnostic)]
655#[diag(passes_lang_item_fn_with_target_feature)]
656pub(crate) struct LangItemWithTargetFeature {
657    #[primary_span]
658    pub attr_span: Span,
659    pub name: Symbol,
660    #[label]
661    pub sig_span: Span,
662}
663
664#[derive(Diagnostic)]
665#[diag(passes_lang_item_on_incorrect_target, code = E0718)]
666pub(crate) struct LangItemOnIncorrectTarget {
667    #[primary_span]
668    #[label]
669    pub span: Span,
670    pub name: Symbol,
671    pub expected_target: Target,
672    pub actual_target: Target,
673}
674
675#[derive(Diagnostic)]
676#[diag(passes_unknown_lang_item, code = E0522)]
677pub(crate) struct UnknownLangItem {
678    #[primary_span]
679    #[label]
680    pub span: Span,
681    pub name: Symbol,
682}
683
684pub(crate) struct InvalidAttrAtCrateLevel {
685    pub span: Span,
686    pub sugg_span: Option<Span>,
687    pub name: Symbol,
688    pub item: Option<ItemFollowingInnerAttr>,
689}
690
691#[derive(Clone, Copy)]
692pub(crate) struct ItemFollowingInnerAttr {
693    pub span: Span,
694    pub kind: &'static str,
695}
696
697impl<G: EmissionGuarantee> Diagnostic<'_, G> for InvalidAttrAtCrateLevel {
698    #[track_caller]
699    fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
700        let mut diag = Diag::new(dcx, level, fluent::passes_invalid_attr_at_crate_level);
701        diag.span(self.span);
702        diag.arg("name", self.name);
703        // Only emit an error with a suggestion if we can create a string out
704        // of the attribute span
705        if let Some(span) = self.sugg_span {
706            diag.span_suggestion_verbose(
707                span,
708                fluent::passes_suggestion,
709                String::new(),
710                Applicability::MachineApplicable,
711            );
712        }
713        if let Some(item) = self.item {
714            diag.arg("kind", item.kind);
715            diag.span_label(item.span, fluent::passes_invalid_attr_at_crate_level_item);
716        }
717        diag
718    }
719}
720
721#[derive(Diagnostic)]
722#[diag(passes_duplicate_diagnostic_item_in_crate)]
723pub(crate) struct DuplicateDiagnosticItemInCrate {
724    #[primary_span]
725    pub duplicate_span: Option<Span>,
726    #[note(passes_diagnostic_item_first_defined)]
727    pub orig_span: Option<Span>,
728    #[note]
729    pub different_crates: bool,
730    pub crate_name: Symbol,
731    pub orig_crate_name: Symbol,
732    pub name: Symbol,
733}
734
735#[derive(Diagnostic)]
736#[diag(passes_layout_abi)]
737pub(crate) struct LayoutAbi {
738    #[primary_span]
739    pub span: Span,
740    pub abi: String,
741}
742
743#[derive(Diagnostic)]
744#[diag(passes_layout_align)]
745pub(crate) struct LayoutAlign {
746    #[primary_span]
747    pub span: Span,
748    pub align: String,
749}
750
751#[derive(Diagnostic)]
752#[diag(passes_layout_size)]
753pub(crate) struct LayoutSize {
754    #[primary_span]
755    pub span: Span,
756    pub size: String,
757}
758
759#[derive(Diagnostic)]
760#[diag(passes_layout_homogeneous_aggregate)]
761pub(crate) struct LayoutHomogeneousAggregate {
762    #[primary_span]
763    pub span: Span,
764    pub homogeneous_aggregate: String,
765}
766
767#[derive(Diagnostic)]
768#[diag(passes_layout_of)]
769pub(crate) struct LayoutOf<'tcx> {
770    #[primary_span]
771    pub span: Span,
772    pub normalized_ty: Ty<'tcx>,
773    pub ty_layout: String,
774}
775
776#[derive(Diagnostic)]
777#[diag(passes_layout_invalid_attribute)]
778pub(crate) struct LayoutInvalidAttribute {
779    #[primary_span]
780    pub span: Span,
781}
782
783#[derive(Diagnostic)]
784#[diag(passes_abi_of)]
785pub(crate) struct AbiOf {
786    #[primary_span]
787    pub span: Span,
788    pub fn_name: Symbol,
789    pub fn_abi: String,
790}
791
792#[derive(Diagnostic)]
793#[diag(passes_abi_ne)]
794pub(crate) struct AbiNe {
795    #[primary_span]
796    pub span: Span,
797    pub left: String,
798    pub right: String,
799}
800
801#[derive(Diagnostic)]
802#[diag(passes_abi_invalid_attribute)]
803pub(crate) struct AbiInvalidAttribute {
804    #[primary_span]
805    pub span: Span,
806}
807
808#[derive(Diagnostic)]
809#[diag(passes_unrecognized_argument)]
810pub(crate) struct UnrecognizedArgument {
811    #[primary_span]
812    pub span: Span,
813}
814
815#[derive(Diagnostic)]
816#[diag(passes_feature_stable_twice, code = E0711)]
817pub(crate) struct FeatureStableTwice {
818    #[primary_span]
819    pub span: Span,
820    pub feature: Symbol,
821    pub since: Symbol,
822    pub prev_since: Symbol,
823}
824
825#[derive(Diagnostic)]
826#[diag(passes_feature_previously_declared, code = E0711)]
827pub(crate) struct FeaturePreviouslyDeclared<'a> {
828    #[primary_span]
829    pub span: Span,
830    pub feature: Symbol,
831    pub declared: &'a str,
832    pub prev_declared: &'a str,
833}
834
835#[derive(Diagnostic)]
836#[diag(passes_attr_only_in_functions)]
837pub(crate) struct AttrOnlyInFunctions {
838    #[primary_span]
839    pub span: Span,
840    pub attr: Symbol,
841}
842
843#[derive(Diagnostic)]
844#[diag(passes_multiple_rustc_main, code = E0137)]
845pub(crate) struct MultipleRustcMain {
846    #[primary_span]
847    pub span: Span,
848    #[label(passes_first)]
849    pub first: Span,
850    #[label(passes_additional)]
851    pub additional: Span,
852}
853
854#[derive(Diagnostic)]
855#[diag(passes_extern_main)]
856pub(crate) struct ExternMain {
857    #[primary_span]
858    pub span: Span,
859}
860
861pub(crate) struct NoMainErr {
862    pub sp: Span,
863    pub crate_name: Symbol,
864    pub has_filename: bool,
865    pub filename: PathBuf,
866    pub file_empty: bool,
867    pub non_main_fns: Vec<Span>,
868    pub main_def_opt: Option<MainDefinition>,
869    pub add_teach_note: bool,
870}
871
872impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for NoMainErr {
873    #[track_caller]
874    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
875        let mut diag = Diag::new(dcx, level, fluent::passes_no_main_function);
876        diag.span(DUMMY_SP);
877        diag.code(E0601);
878        diag.arg("crate_name", self.crate_name);
879        diag.arg("filename", self.filename);
880        diag.arg("has_filename", self.has_filename);
881        let note = if !self.non_main_fns.is_empty() {
882            for &span in &self.non_main_fns {
883                diag.span_note(span, fluent::passes_here_is_main);
884            }
885            diag.note(fluent::passes_one_or_more_possible_main);
886            diag.help(fluent::passes_consider_moving_main);
887            // There were some functions named `main` though. Try to give the user a hint.
888            fluent::passes_main_must_be_defined_at_crate
889        } else if self.has_filename {
890            fluent::passes_consider_adding_main_to_file
891        } else {
892            fluent::passes_consider_adding_main_at_crate
893        };
894        if self.file_empty {
895            diag.note(note);
896        } else {
897            diag.span(self.sp.shrink_to_hi());
898            diag.span_label(self.sp.shrink_to_hi(), note);
899        }
900
901        if let Some(main_def) = self.main_def_opt
902            && main_def.opt_fn_def_id().is_none()
903        {
904            // There is something at `crate::main`, but it is not a function definition.
905            diag.span_label(main_def.span, fluent::passes_non_function_main);
906        }
907
908        if self.add_teach_note {
909            diag.note(fluent::passes_teach_note);
910        }
911        diag
912    }
913}
914
915pub(crate) struct DuplicateLangItem {
916    pub local_span: Option<Span>,
917    pub lang_item_name: Symbol,
918    pub crate_name: Symbol,
919    pub dependency_of: Option<Symbol>,
920    pub is_local: bool,
921    pub path: String,
922    pub first_defined_span: Option<Span>,
923    pub orig_crate_name: Option<Symbol>,
924    pub orig_dependency_of: Option<Symbol>,
925    pub orig_is_local: bool,
926    pub orig_path: String,
927    pub(crate) duplicate: Duplicate,
928}
929
930impl<G: EmissionGuarantee> Diagnostic<'_, G> for DuplicateLangItem {
931    #[track_caller]
932    fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
933        let mut diag = Diag::new(
934            dcx,
935            level,
936            match self.duplicate {
937                Duplicate::Plain => fluent::passes_duplicate_lang_item,
938                Duplicate::Crate => fluent::passes_duplicate_lang_item_crate,
939                Duplicate::CrateDepends => fluent::passes_duplicate_lang_item_crate_depends,
940            },
941        );
942        diag.code(E0152);
943        diag.arg("lang_item_name", self.lang_item_name);
944        diag.arg("crate_name", self.crate_name);
945        if let Some(dependency_of) = self.dependency_of {
946            diag.arg("dependency_of", dependency_of);
947        }
948        diag.arg("path", self.path);
949        if let Some(orig_crate_name) = self.orig_crate_name {
950            diag.arg("orig_crate_name", orig_crate_name);
951        }
952        if let Some(orig_dependency_of) = self.orig_dependency_of {
953            diag.arg("orig_dependency_of", orig_dependency_of);
954        }
955        diag.arg("orig_path", self.orig_path);
956        if let Some(span) = self.local_span {
957            diag.span(span);
958        }
959        if let Some(span) = self.first_defined_span {
960            diag.span_note(span, fluent::passes_first_defined_span);
961        } else {
962            if self.orig_dependency_of.is_none() {
963                diag.note(fluent::passes_first_defined_crate);
964            } else {
965                diag.note(fluent::passes_first_defined_crate_depends);
966            }
967
968            if self.orig_is_local {
969                diag.note(fluent::passes_first_definition_local);
970            } else {
971                diag.note(fluent::passes_first_definition_path);
972            }
973
974            if self.is_local {
975                diag.note(fluent::passes_second_definition_local);
976            } else {
977                diag.note(fluent::passes_second_definition_path);
978            }
979        }
980        diag
981    }
982}
983
984#[derive(Diagnostic)]
985#[diag(passes_incorrect_target, code = E0718)]
986pub(crate) struct IncorrectTarget<'a> {
987    #[primary_span]
988    pub span: Span,
989    #[label]
990    pub generics_span: Span,
991    pub name: &'a str, // cannot be symbol because it renders e.g. `r#fn` instead of `fn`
992    pub kind: &'static str,
993    pub num: usize,
994    pub actual_num: usize,
995    pub at_least: bool,
996}
997
998#[derive(Diagnostic)]
999#[diag(passes_incorrect_crate_type)]
1000pub(crate) struct IncorrectCrateType {
1001    #[primary_span]
1002    pub span: Span,
1003}
1004
1005#[derive(LintDiagnostic)]
1006#[diag(passes_useless_assignment)]
1007pub(crate) struct UselessAssignment<'a> {
1008    pub is_field_assign: bool,
1009    pub ty: Ty<'a>,
1010}
1011
1012#[derive(LintDiagnostic)]
1013#[diag(passes_inline_ignored_for_exported)]
1014#[help]
1015pub(crate) struct InlineIgnoredForExported {}
1016
1017#[derive(Diagnostic)]
1018#[diag(passes_object_lifetime_err)]
1019pub(crate) struct ObjectLifetimeErr {
1020    #[primary_span]
1021    pub span: Span,
1022    pub repr: String,
1023}
1024
1025#[derive(Diagnostic)]
1026pub(crate) enum AttrApplication {
1027    #[diag(passes_attr_application_enum, code = E0517)]
1028    Enum {
1029        #[primary_span]
1030        hint_span: Span,
1031        #[label]
1032        span: Span,
1033    },
1034    #[diag(passes_attr_application_struct, code = E0517)]
1035    Struct {
1036        #[primary_span]
1037        hint_span: Span,
1038        #[label]
1039        span: Span,
1040    },
1041    #[diag(passes_attr_application_struct_union, code = E0517)]
1042    StructUnion {
1043        #[primary_span]
1044        hint_span: Span,
1045        #[label]
1046        span: Span,
1047    },
1048    #[diag(passes_attr_application_struct_enum_union, code = E0517)]
1049    StructEnumUnion {
1050        #[primary_span]
1051        hint_span: Span,
1052        #[label]
1053        span: Span,
1054    },
1055}
1056
1057#[derive(Diagnostic)]
1058#[diag(passes_transparent_incompatible, code = E0692)]
1059pub(crate) struct TransparentIncompatible {
1060    #[primary_span]
1061    pub hint_spans: Vec<Span>,
1062    pub target: String,
1063}
1064
1065#[derive(Diagnostic)]
1066#[diag(passes_deprecated_attribute, code = E0549)]
1067pub(crate) struct DeprecatedAttribute {
1068    #[primary_span]
1069    pub span: Span,
1070}
1071
1072#[derive(Diagnostic)]
1073#[diag(passes_useless_stability)]
1074pub(crate) struct UselessStability {
1075    #[primary_span]
1076    #[label]
1077    pub span: Span,
1078    #[label(passes_item)]
1079    pub item_sp: Span,
1080}
1081
1082#[derive(Diagnostic)]
1083#[diag(passes_cannot_stabilize_deprecated)]
1084pub(crate) struct CannotStabilizeDeprecated {
1085    #[primary_span]
1086    #[label]
1087    pub span: Span,
1088    #[label(passes_item)]
1089    pub item_sp: Span,
1090}
1091
1092#[derive(Diagnostic)]
1093#[diag(passes_unstable_attr_for_already_stable_feature)]
1094pub(crate) struct UnstableAttrForAlreadyStableFeature {
1095    #[primary_span]
1096    #[label]
1097    #[help]
1098    pub attr_span: Span,
1099    #[label(passes_item)]
1100    pub item_span: Span,
1101}
1102
1103#[derive(Diagnostic)]
1104#[diag(passes_missing_stability_attr)]
1105pub(crate) struct MissingStabilityAttr<'a> {
1106    #[primary_span]
1107    pub span: Span,
1108    pub descr: &'a str,
1109}
1110
1111#[derive(Diagnostic)]
1112#[diag(passes_missing_const_stab_attr)]
1113pub(crate) struct MissingConstStabAttr<'a> {
1114    #[primary_span]
1115    pub span: Span,
1116    pub descr: &'a str,
1117}
1118
1119#[derive(Diagnostic)]
1120#[diag(passes_trait_impl_const_stable)]
1121#[note]
1122pub(crate) struct TraitImplConstStable {
1123    #[primary_span]
1124    pub span: Span,
1125}
1126
1127#[derive(Diagnostic)]
1128#[diag(passes_trait_impl_const_stability_mismatch)]
1129pub(crate) struct TraitImplConstStabilityMismatch {
1130    #[primary_span]
1131    pub span: Span,
1132    #[subdiagnostic]
1133    pub impl_stability: ImplConstStability,
1134    #[subdiagnostic]
1135    pub trait_stability: TraitConstStability,
1136}
1137
1138#[derive(Subdiagnostic)]
1139pub(crate) enum TraitConstStability {
1140    #[note(passes_trait_impl_const_stability_mismatch_trait_stable)]
1141    Stable {
1142        #[primary_span]
1143        span: Span,
1144    },
1145    #[note(passes_trait_impl_const_stability_mismatch_trait_unstable)]
1146    Unstable {
1147        #[primary_span]
1148        span: Span,
1149    },
1150}
1151
1152#[derive(Subdiagnostic)]
1153pub(crate) enum ImplConstStability {
1154    #[note(passes_trait_impl_const_stability_mismatch_impl_stable)]
1155    Stable {
1156        #[primary_span]
1157        span: Span,
1158    },
1159    #[note(passes_trait_impl_const_stability_mismatch_impl_unstable)]
1160    Unstable {
1161        #[primary_span]
1162        span: Span,
1163    },
1164}
1165
1166#[derive(Diagnostic)]
1167#[diag(passes_unknown_feature, code = E0635)]
1168pub(crate) struct UnknownFeature {
1169    #[primary_span]
1170    pub span: Span,
1171    pub feature: Symbol,
1172}
1173
1174#[derive(Diagnostic)]
1175#[diag(passes_unknown_feature_alias, code = E0635)]
1176pub(crate) struct RenamedFeature {
1177    #[primary_span]
1178    pub span: Span,
1179    pub feature: Symbol,
1180    pub alias: Symbol,
1181}
1182
1183#[derive(Diagnostic)]
1184#[diag(passes_implied_feature_not_exist)]
1185pub(crate) struct ImpliedFeatureNotExist {
1186    #[primary_span]
1187    pub span: Span,
1188    pub feature: Symbol,
1189    pub implied_by: Symbol,
1190}
1191
1192#[derive(Diagnostic)]
1193#[diag(passes_duplicate_feature_err, code = E0636)]
1194pub(crate) struct DuplicateFeatureErr {
1195    #[primary_span]
1196    pub span: Span,
1197    pub feature: Symbol,
1198}
1199
1200#[derive(Diagnostic)]
1201#[diag(passes_missing_const_err)]
1202pub(crate) struct MissingConstErr {
1203    #[primary_span]
1204    #[help]
1205    pub fn_sig_span: Span,
1206}
1207
1208#[derive(Diagnostic)]
1209#[diag(passes_const_stable_not_stable)]
1210pub(crate) struct ConstStableNotStable {
1211    #[primary_span]
1212    pub fn_sig_span: Span,
1213    #[label]
1214    pub const_span: Span,
1215}
1216
1217#[derive(LintDiagnostic)]
1218pub(crate) enum MultipleDeadCodes<'tcx> {
1219    #[diag(passes_dead_codes)]
1220    DeadCodes {
1221        multiple: bool,
1222        num: usize,
1223        descr: &'tcx str,
1224        participle: &'tcx str,
1225        name_list: DiagSymbolList,
1226        #[subdiagnostic]
1227        // only on DeadCodes since it's never a problem for tuple struct fields
1228        enum_variants_with_same_name: Vec<EnumVariantSameName<'tcx>>,
1229        #[subdiagnostic]
1230        parent_info: Option<ParentInfo<'tcx>>,
1231        #[subdiagnostic]
1232        ignored_derived_impls: Option<IgnoredDerivedImpls>,
1233    },
1234    #[diag(passes_dead_codes)]
1235    UnusedTupleStructFields {
1236        multiple: bool,
1237        num: usize,
1238        descr: &'tcx str,
1239        participle: &'tcx str,
1240        name_list: DiagSymbolList,
1241        #[subdiagnostic]
1242        change_fields_suggestion: ChangeFields,
1243        #[subdiagnostic]
1244        parent_info: Option<ParentInfo<'tcx>>,
1245        #[subdiagnostic]
1246        ignored_derived_impls: Option<IgnoredDerivedImpls>,
1247    },
1248}
1249
1250#[derive(Subdiagnostic)]
1251#[note(passes_enum_variant_same_name)]
1252pub(crate) struct EnumVariantSameName<'tcx> {
1253    #[primary_span]
1254    pub variant_span: Span,
1255    pub dead_name: Symbol,
1256    pub dead_descr: &'tcx str,
1257}
1258
1259#[derive(Subdiagnostic)]
1260#[label(passes_parent_info)]
1261pub(crate) struct ParentInfo<'tcx> {
1262    pub num: usize,
1263    pub descr: &'tcx str,
1264    pub parent_descr: &'tcx str,
1265    #[primary_span]
1266    pub span: Span,
1267}
1268
1269#[derive(Subdiagnostic)]
1270#[note(passes_ignored_derived_impls)]
1271pub(crate) struct IgnoredDerivedImpls {
1272    pub name: Symbol,
1273    pub trait_list: DiagSymbolList,
1274    pub trait_list_len: usize,
1275}
1276
1277#[derive(Subdiagnostic)]
1278pub(crate) enum ChangeFields {
1279    #[multipart_suggestion(
1280        passes_change_fields_to_be_of_unit_type,
1281        applicability = "has-placeholders"
1282    )]
1283    ChangeToUnitTypeOrRemove {
1284        num: usize,
1285        #[suggestion_part(code = "()")]
1286        spans: Vec<Span>,
1287    },
1288    #[help(passes_remove_fields)]
1289    Remove { num: usize },
1290}
1291
1292#[derive(Diagnostic)]
1293#[diag(passes_proc_macro_bad_sig)]
1294pub(crate) struct ProcMacroBadSig {
1295    #[primary_span]
1296    pub span: Span,
1297    pub kind: ProcMacroKind,
1298}
1299
1300#[derive(LintDiagnostic)]
1301#[diag(passes_unreachable_due_to_uninhabited)]
1302pub(crate) struct UnreachableDueToUninhabited<'desc, 'tcx> {
1303    pub descr: &'desc str,
1304    #[label]
1305    pub expr: Span,
1306    #[label(passes_label_orig)]
1307    #[note]
1308    pub orig: Span,
1309    pub ty: Ty<'tcx>,
1310}
1311
1312#[derive(LintDiagnostic)]
1313#[diag(passes_unused_var_maybe_capture_ref)]
1314#[help]
1315pub(crate) struct UnusedVarMaybeCaptureRef {
1316    pub name: String,
1317}
1318
1319#[derive(LintDiagnostic)]
1320#[diag(passes_unused_capture_maybe_capture_ref)]
1321#[help]
1322pub(crate) struct UnusedCaptureMaybeCaptureRef {
1323    pub name: String,
1324}
1325
1326#[derive(LintDiagnostic)]
1327#[diag(passes_unused_var_remove_field)]
1328pub(crate) struct UnusedVarRemoveField {
1329    pub name: String,
1330    #[subdiagnostic]
1331    pub sugg: UnusedVarRemoveFieldSugg,
1332}
1333
1334#[derive(Subdiagnostic)]
1335#[multipart_suggestion(
1336    passes_unused_var_remove_field_suggestion,
1337    applicability = "machine-applicable"
1338)]
1339pub(crate) struct UnusedVarRemoveFieldSugg {
1340    #[suggestion_part(code = "")]
1341    pub spans: Vec<Span>,
1342}
1343
1344#[derive(LintDiagnostic)]
1345#[diag(passes_unused_var_assigned_only)]
1346#[note]
1347pub(crate) struct UnusedVarAssignedOnly {
1348    pub name: String,
1349}
1350
1351#[derive(LintDiagnostic)]
1352#[diag(passes_unnecessary_stable_feature)]
1353pub(crate) struct UnnecessaryStableFeature {
1354    pub feature: Symbol,
1355    pub since: Symbol,
1356}
1357
1358#[derive(LintDiagnostic)]
1359#[diag(passes_unnecessary_partial_stable_feature)]
1360pub(crate) struct UnnecessaryPartialStableFeature {
1361    #[suggestion(code = "{implies}", applicability = "maybe-incorrect")]
1362    pub span: Span,
1363    #[suggestion(passes_suggestion_remove, code = "", applicability = "maybe-incorrect")]
1364    pub line: Span,
1365    pub feature: Symbol,
1366    pub since: Symbol,
1367    pub implies: Symbol,
1368}
1369
1370#[derive(LintDiagnostic)]
1371#[diag(passes_ineffective_unstable_impl)]
1372#[note]
1373pub(crate) struct IneffectiveUnstableImpl;
1374
1375#[derive(LintDiagnostic)]
1376#[diag(passes_unused_assign)]
1377pub(crate) struct UnusedAssign {
1378    pub name: String,
1379    #[subdiagnostic]
1380    pub suggestion: Option<UnusedAssignSuggestion>,
1381    #[help]
1382    pub help: bool,
1383}
1384
1385#[derive(Subdiagnostic)]
1386#[multipart_suggestion(passes_unused_assign_suggestion, applicability = "maybe-incorrect")]
1387pub(crate) struct UnusedAssignSuggestion {
1388    pub pre: &'static str,
1389    #[suggestion_part(code = "{pre}mut ")]
1390    pub ty_span: Option<Span>,
1391    #[suggestion_part(code = "")]
1392    pub ty_ref_span: Span,
1393    #[suggestion_part(code = "*")]
1394    pub ident_span: Span,
1395    #[suggestion_part(code = "")]
1396    pub expr_ref_span: Span,
1397}
1398
1399#[derive(LintDiagnostic)]
1400#[diag(passes_unused_assign_passed)]
1401#[help]
1402pub(crate) struct UnusedAssignPassed {
1403    pub name: String,
1404}
1405
1406#[derive(LintDiagnostic)]
1407#[diag(passes_unused_variable_try_prefix)]
1408pub(crate) struct UnusedVariableTryPrefix {
1409    #[label]
1410    pub label: Option<Span>,
1411    #[subdiagnostic]
1412    pub string_interp: Vec<UnusedVariableStringInterp>,
1413    #[subdiagnostic]
1414    pub sugg: UnusedVariableSugg,
1415    pub name: String,
1416}
1417
1418#[derive(Subdiagnostic)]
1419pub(crate) enum UnusedVariableSugg {
1420    #[multipart_suggestion(passes_suggestion, applicability = "maybe-incorrect")]
1421    TryPrefixSugg {
1422        #[suggestion_part(code = "_{name}")]
1423        spans: Vec<Span>,
1424        name: String,
1425    },
1426    #[help(passes_unused_variable_args_in_macro)]
1427    NoSugg {
1428        #[primary_span]
1429        span: Span,
1430        name: String,
1431    },
1432}
1433
1434pub(crate) struct UnusedVariableStringInterp {
1435    pub lit: Span,
1436    pub lo: Span,
1437    pub hi: Span,
1438}
1439
1440impl Subdiagnostic for UnusedVariableStringInterp {
1441    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1442        diag.span_label(self.lit, crate::fluent_generated::passes_maybe_string_interpolation);
1443        diag.multipart_suggestion(
1444            crate::fluent_generated::passes_string_interpolation_only_works,
1445            vec![(self.lo, String::from("format!(")), (self.hi, String::from(")"))],
1446            Applicability::MachineApplicable,
1447        );
1448    }
1449}
1450
1451#[derive(LintDiagnostic)]
1452#[diag(passes_unused_variable_try_ignore)]
1453pub(crate) struct UnusedVarTryIgnore {
1454    pub name: String,
1455    #[subdiagnostic]
1456    pub sugg: UnusedVarTryIgnoreSugg,
1457}
1458
1459#[derive(Subdiagnostic)]
1460#[multipart_suggestion(passes_suggestion, applicability = "maybe-incorrect")]
1461pub(crate) struct UnusedVarTryIgnoreSugg {
1462    #[suggestion_part(code = "{name}: _")]
1463    pub shorthands: Vec<Span>,
1464    #[suggestion_part(code = "_")]
1465    pub non_shorthands: Vec<Span>,
1466    pub name: String,
1467}
1468
1469#[derive(LintDiagnostic)]
1470#[diag(passes_attr_crate_level)]
1471#[note]
1472pub(crate) struct AttrCrateLevelOnly {
1473    #[subdiagnostic]
1474    pub sugg: Option<AttrCrateLevelOnlySugg>,
1475}
1476
1477#[derive(Subdiagnostic)]
1478#[suggestion(passes_suggestion, applicability = "maybe-incorrect", code = "!", style = "verbose")]
1479pub(crate) struct AttrCrateLevelOnlySugg {
1480    #[primary_span]
1481    pub attr: Span,
1482}
1483
1484/// "sanitize attribute not allowed here"
1485#[derive(Diagnostic)]
1486#[diag(passes_sanitize_attribute_not_allowed)]
1487pub(crate) struct SanitizeAttributeNotAllowed {
1488    #[primary_span]
1489    pub attr_span: Span,
1490    /// "not a function, impl block, or module"
1491    #[label(passes_not_fn_impl_mod)]
1492    pub not_fn_impl_mod: Option<Span>,
1493    /// "function has no body"
1494    #[label(passes_no_body)]
1495    pub no_body: Option<Span>,
1496    /// "sanitize attribute can be applied to a function (with body), impl block, or module"
1497    #[help]
1498    pub help: (),
1499}
1500
1501// FIXME(jdonszelmann): move back to rustc_attr
1502#[derive(Diagnostic)]
1503#[diag(passes_rustc_const_stable_indirect_pairing)]
1504pub(crate) struct RustcConstStableIndirectPairing {
1505    #[primary_span]
1506    pub span: Span,
1507}
1508
1509#[derive(Diagnostic)]
1510#[diag(passes_unsupported_attributes_in_where)]
1511#[help]
1512pub(crate) struct UnsupportedAttributesInWhere {
1513    #[primary_span]
1514    pub span: MultiSpan,
1515}
1516
1517#[derive(Diagnostic)]
1518pub(crate) enum UnexportableItem<'a> {
1519    #[diag(passes_unexportable_item)]
1520    Item {
1521        #[primary_span]
1522        span: Span,
1523        descr: &'a str,
1524    },
1525
1526    #[diag(passes_unexportable_generic_fn)]
1527    GenericFn(#[primary_span] Span),
1528
1529    #[diag(passes_unexportable_fn_abi)]
1530    FnAbi(#[primary_span] Span),
1531
1532    #[diag(passes_unexportable_type_repr)]
1533    TypeRepr(#[primary_span] Span),
1534
1535    #[diag(passes_unexportable_type_in_interface)]
1536    TypeInInterface {
1537        #[primary_span]
1538        span: Span,
1539        desc: &'a str,
1540        ty: &'a str,
1541        #[label]
1542        ty_span: Span,
1543    },
1544
1545    #[diag(passes_unexportable_priv_item)]
1546    PrivItem {
1547        #[primary_span]
1548        span: Span,
1549        #[note]
1550        vis_note: Span,
1551        vis_descr: &'a str,
1552    },
1553
1554    #[diag(passes_unexportable_adt_with_private_fields)]
1555    AdtWithPrivFields {
1556        #[primary_span]
1557        span: Span,
1558        #[note]
1559        vis_note: Span,
1560        field_name: &'a str,
1561    },
1562}
1563
1564#[derive(Diagnostic)]
1565#[diag(passes_repr_align_should_be_align)]
1566pub(crate) struct ReprAlignShouldBeAlign {
1567    #[primary_span]
1568    #[help]
1569    pub span: Span,
1570    pub item: &'static str,
1571}
1572
1573#[derive(Diagnostic)]
1574#[diag(passes_custom_mir_phase_requires_dialect)]
1575pub(crate) struct CustomMirPhaseRequiresDialect {
1576    #[primary_span]
1577    pub attr_span: Span,
1578    #[label]
1579    pub phase_span: Span,
1580}
1581
1582#[derive(Diagnostic)]
1583#[diag(passes_custom_mir_incompatible_dialect_and_phase)]
1584pub(crate) struct CustomMirIncompatibleDialectAndPhase {
1585    pub dialect: MirDialect,
1586    pub phase: MirPhase,
1587    #[primary_span]
1588    pub attr_span: Span,
1589    #[label]
1590    pub dialect_span: Span,
1591    #[label]
1592    pub phase_span: Span,
1593}