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