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