rustc_hir_analysis/
errors.rs

1//! Errors emitted by `rustc_hir_analysis`.
2
3use rustc_abi::ExternAbi;
4use rustc_errors::codes::*;
5use rustc_errors::{
6    Applicability, Diag, DiagCtxtHandle, DiagSymbolList, Diagnostic, EmissionGuarantee, Level,
7    MultiSpan,
8};
9use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
10use rustc_middle::ty::Ty;
11use rustc_span::{Ident, Span, Symbol};
12
13use crate::fluent_generated as fluent;
14pub(crate) mod wrong_number_of_generic_args;
15
16mod precise_captures;
17pub(crate) use precise_captures::*;
18
19#[derive(Diagnostic)]
20#[diag(hir_analysis_ambiguous_assoc_item)]
21pub(crate) struct AmbiguousAssocItem<'a> {
22    #[primary_span]
23    #[label]
24    pub span: Span,
25    pub assoc_kind: &'static str,
26    pub assoc_ident: Ident,
27    pub qself: &'a str,
28}
29
30#[derive(Diagnostic)]
31#[diag(hir_analysis_assoc_kind_mismatch)]
32pub(crate) struct AssocKindMismatch {
33    #[primary_span]
34    #[label]
35    pub span: Span,
36    pub expected: &'static str,
37    pub got: &'static str,
38    #[label(hir_analysis_expected_because_label)]
39    pub expected_because_label: Option<Span>,
40    pub assoc_kind: &'static str,
41    #[note]
42    pub def_span: Span,
43    #[label(hir_analysis_bound_on_assoc_const_label)]
44    pub bound_on_assoc_const_label: Option<Span>,
45    #[subdiagnostic]
46    pub wrap_in_braces_sugg: Option<AssocKindMismatchWrapInBracesSugg>,
47}
48
49#[derive(Subdiagnostic)]
50#[multipart_suggestion(
51    hir_analysis_assoc_kind_mismatch_wrap_in_braces_sugg,
52    applicability = "maybe-incorrect"
53)]
54pub(crate) struct AssocKindMismatchWrapInBracesSugg {
55    #[suggestion_part(code = "{{ ")]
56    pub lo: Span,
57    #[suggestion_part(code = " }}")]
58    pub hi: Span,
59}
60
61#[derive(Diagnostic)]
62#[diag(hir_analysis_assoc_item_is_private, code = E0624)]
63pub(crate) struct AssocItemIsPrivate {
64    #[primary_span]
65    #[label]
66    pub span: Span,
67    pub kind: &'static str,
68    pub name: Ident,
69    #[label(hir_analysis_defined_here_label)]
70    pub defined_here_label: Span,
71}
72
73#[derive(Diagnostic)]
74#[diag(hir_analysis_assoc_item_not_found, code = E0220)]
75pub(crate) struct AssocItemNotFound<'a> {
76    #[primary_span]
77    pub span: Span,
78    pub assoc_ident: Ident,
79    pub assoc_kind: &'static str,
80    pub qself: &'a str,
81    #[subdiagnostic]
82    pub label: Option<AssocItemNotFoundLabel<'a>>,
83    #[subdiagnostic]
84    pub sugg: Option<AssocItemNotFoundSugg<'a>>,
85    #[label(hir_analysis_within_macro)]
86    pub within_macro_span: Option<Span>,
87}
88
89#[derive(Subdiagnostic)]
90pub(crate) enum AssocItemNotFoundLabel<'a> {
91    #[label(hir_analysis_assoc_item_not_found_label)]
92    NotFound {
93        #[primary_span]
94        span: Span,
95    },
96    #[label(hir_analysis_assoc_item_not_found_found_in_other_trait_label)]
97    FoundInOtherTrait {
98        #[primary_span]
99        span: Span,
100        assoc_kind: &'static str,
101        trait_name: &'a str,
102        suggested_name: Symbol,
103        identically_named: bool,
104    },
105}
106
107#[derive(Subdiagnostic)]
108
109pub(crate) enum AssocItemNotFoundSugg<'a> {
110    #[suggestion(
111        hir_analysis_assoc_item_not_found_similar_sugg,
112        code = "{suggested_name}",
113        applicability = "maybe-incorrect"
114    )]
115    Similar {
116        #[primary_span]
117        span: Span,
118        assoc_kind: &'static str,
119        suggested_name: Symbol,
120    },
121    #[suggestion(
122        hir_analysis_assoc_item_not_found_similar_in_other_trait_sugg,
123        code = "{suggested_name}",
124        style = "verbose",
125        applicability = "maybe-incorrect"
126    )]
127    SimilarInOtherTrait {
128        #[primary_span]
129        span: Span,
130        assoc_kind: &'static str,
131        suggested_name: Symbol,
132    },
133    #[multipart_suggestion(
134        hir_analysis_assoc_item_not_found_similar_in_other_trait_qpath_sugg,
135        style = "verbose"
136    )]
137    SimilarInOtherTraitQPath {
138        #[suggestion_part(code = "<")]
139        lo: Span,
140        #[suggestion_part(code = " as {trait_ref}>")]
141        mi: Span,
142        #[suggestion_part(code = "{suggested_name}")]
143        hi: Option<Span>,
144        trait_ref: String,
145        suggested_name: Symbol,
146        identically_named: bool,
147        #[applicability]
148        applicability: Applicability,
149    },
150    #[suggestion(
151        hir_analysis_assoc_item_not_found_other_sugg,
152        code = "{suggested_name}",
153        applicability = "maybe-incorrect"
154    )]
155    Other {
156        #[primary_span]
157        span: Span,
158        qself: &'a str,
159        assoc_kind: &'static str,
160        suggested_name: Symbol,
161    },
162}
163
164#[derive(Diagnostic)]
165#[diag(hir_analysis_wrong_number_of_generic_arguments_to_intrinsic, code = E0094)]
166pub(crate) struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
167    #[primary_span]
168    #[label]
169    pub span: Span,
170    pub found: usize,
171    pub expected: usize,
172    pub descr: &'a str,
173}
174
175#[derive(Diagnostic)]
176#[diag(hir_analysis_unrecognized_intrinsic_function, code = E0093)]
177#[help]
178pub(crate) struct UnrecognizedIntrinsicFunction {
179    #[primary_span]
180    #[label]
181    pub span: Span,
182    pub name: Symbol,
183}
184
185#[derive(Diagnostic)]
186#[diag(hir_analysis_lifetimes_or_bounds_mismatch_on_trait, code = E0195)]
187pub(crate) struct LifetimesOrBoundsMismatchOnTrait {
188    #[primary_span]
189    #[label]
190    pub span: Span,
191    #[label(hir_analysis_generics_label)]
192    pub generics_span: Option<Span>,
193    #[label(hir_analysis_where_label)]
194    pub where_span: Option<Span>,
195    #[label(hir_analysis_bounds_label)]
196    pub bounds_span: Vec<Span>,
197    pub item_kind: &'static str,
198    pub ident: Ident,
199}
200
201#[derive(Diagnostic)]
202#[diag(hir_analysis_drop_impl_on_wrong_item, code = E0120)]
203pub(crate) struct DropImplOnWrongItem {
204    #[primary_span]
205    #[label]
206    pub span: Span,
207}
208
209#[derive(Diagnostic)]
210pub(crate) enum FieldAlreadyDeclared {
211    #[diag(hir_analysis_field_already_declared, code = E0124)]
212    NotNested {
213        field_name: Ident,
214        #[primary_span]
215        #[label]
216        span: Span,
217        #[label(hir_analysis_previous_decl_label)]
218        prev_span: Span,
219    },
220    #[diag(hir_analysis_field_already_declared_current_nested)]
221    CurrentNested {
222        field_name: Ident,
223        #[primary_span]
224        #[label]
225        span: Span,
226        #[note(hir_analysis_nested_field_decl_note)]
227        nested_field_span: Span,
228        #[subdiagnostic]
229        help: FieldAlreadyDeclaredNestedHelp,
230        #[label(hir_analysis_previous_decl_label)]
231        prev_span: Span,
232    },
233    #[diag(hir_analysis_field_already_declared_previous_nested)]
234    PreviousNested {
235        field_name: Ident,
236        #[primary_span]
237        #[label]
238        span: Span,
239        #[label(hir_analysis_previous_decl_label)]
240        prev_span: Span,
241        #[note(hir_analysis_previous_nested_field_decl_note)]
242        prev_nested_field_span: Span,
243        #[subdiagnostic]
244        prev_help: FieldAlreadyDeclaredNestedHelp,
245    },
246    #[diag(hir_analysis_field_already_declared_both_nested)]
247    BothNested {
248        field_name: Ident,
249        #[primary_span]
250        #[label]
251        span: Span,
252        #[note(hir_analysis_nested_field_decl_note)]
253        nested_field_span: Span,
254        #[subdiagnostic]
255        help: FieldAlreadyDeclaredNestedHelp,
256        #[label(hir_analysis_previous_decl_label)]
257        prev_span: Span,
258        #[note(hir_analysis_previous_nested_field_decl_note)]
259        prev_nested_field_span: Span,
260        #[subdiagnostic]
261        prev_help: FieldAlreadyDeclaredNestedHelp,
262    },
263}
264
265#[derive(Subdiagnostic)]
266#[help(hir_analysis_field_already_declared_nested_help)]
267pub(crate) struct FieldAlreadyDeclaredNestedHelp {
268    #[primary_span]
269    pub span: Span,
270}
271
272#[derive(Diagnostic)]
273#[diag(hir_analysis_copy_impl_on_type_with_dtor, code = E0184)]
274pub(crate) struct CopyImplOnTypeWithDtor {
275    #[primary_span]
276    #[label]
277    pub span: Span,
278}
279
280#[derive(Diagnostic)]
281#[diag(hir_analysis_multiple_relaxed_default_bounds, code = E0203)]
282pub(crate) struct MultipleRelaxedDefaultBounds {
283    #[primary_span]
284    pub spans: Vec<Span>,
285}
286
287#[derive(Diagnostic)]
288#[diag(hir_analysis_copy_impl_on_non_adt, code = E0206)]
289pub(crate) struct CopyImplOnNonAdt {
290    #[primary_span]
291    #[label]
292    pub span: Span,
293}
294
295#[derive(Diagnostic)]
296#[diag(hir_analysis_const_param_ty_impl_on_unsized)]
297pub(crate) struct ConstParamTyImplOnUnsized {
298    #[primary_span]
299    #[label]
300    pub span: Span,
301}
302
303#[derive(Diagnostic)]
304#[diag(hir_analysis_const_param_ty_impl_on_non_adt)]
305pub(crate) struct ConstParamTyImplOnNonAdt {
306    #[primary_span]
307    #[label]
308    pub span: Span,
309}
310
311#[derive(Diagnostic)]
312#[diag(hir_analysis_trait_object_declared_with_no_traits, code = E0224)]
313pub(crate) struct TraitObjectDeclaredWithNoTraits {
314    #[primary_span]
315    pub span: Span,
316    #[label(hir_analysis_alias_span)]
317    pub trait_alias_span: Option<Span>,
318}
319
320#[derive(Diagnostic)]
321#[diag(hir_analysis_ambiguous_lifetime_bound, code = E0227)]
322pub(crate) struct AmbiguousLifetimeBound {
323    #[primary_span]
324    pub span: Span,
325}
326
327#[derive(Diagnostic)]
328#[diag(hir_analysis_assoc_item_constraints_not_allowed_here, code = E0229)]
329pub(crate) struct AssocItemConstraintsNotAllowedHere {
330    #[primary_span]
331    #[label]
332    pub span: Span,
333
334    #[subdiagnostic]
335    pub fn_trait_expansion: Option<ParenthesizedFnTraitExpansion>,
336}
337
338#[derive(Diagnostic)]
339#[diag(hir_analysis_param_in_ty_of_assoc_const_binding)]
340pub(crate) struct ParamInTyOfAssocConstBinding<'tcx> {
341    #[primary_span]
342    #[label]
343    pub span: Span,
344    pub assoc_const: Ident,
345    pub param_name: Symbol,
346    pub param_def_kind: &'static str,
347    pub param_category: &'static str,
348    #[label(hir_analysis_param_defined_here_label)]
349    pub param_defined_here_label: Option<Span>,
350    #[subdiagnostic]
351    pub ty_note: Option<TyOfAssocConstBindingNote<'tcx>>,
352}
353
354#[derive(Subdiagnostic, Clone, Copy)]
355#[note(hir_analysis_ty_of_assoc_const_binding_note)]
356pub(crate) struct TyOfAssocConstBindingNote<'tcx> {
357    pub assoc_const: Ident,
358    pub ty: Ty<'tcx>,
359}
360
361#[derive(Diagnostic)]
362#[diag(hir_analysis_escaping_bound_var_in_ty_of_assoc_const_binding)]
363pub(crate) struct EscapingBoundVarInTyOfAssocConstBinding<'tcx> {
364    #[primary_span]
365    #[label]
366    pub span: Span,
367    pub assoc_const: Ident,
368    pub var_name: Symbol,
369    pub var_def_kind: &'static str,
370    #[label(hir_analysis_var_defined_here_label)]
371    pub var_defined_here_label: Span,
372    #[subdiagnostic]
373    pub ty_note: Option<TyOfAssocConstBindingNote<'tcx>>,
374}
375
376#[derive(Subdiagnostic)]
377#[help(hir_analysis_parenthesized_fn_trait_expansion)]
378pub(crate) struct ParenthesizedFnTraitExpansion {
379    #[primary_span]
380    pub span: Span,
381
382    pub expanded_type: String,
383}
384
385#[derive(Diagnostic)]
386#[diag(hir_analysis_typeof_reserved_keyword_used, code = E0516)]
387pub(crate) struct TypeofReservedKeywordUsed<'tcx> {
388    pub ty: Ty<'tcx>,
389    #[primary_span]
390    #[label]
391    pub span: Span,
392    #[suggestion(style = "verbose", code = "{ty}")]
393    pub opt_sugg: Option<(Span, Applicability)>,
394}
395
396#[derive(Diagnostic)]
397#[diag(hir_analysis_value_of_associated_struct_already_specified, code = E0719)]
398pub(crate) struct ValueOfAssociatedStructAlreadySpecified {
399    #[primary_span]
400    #[label]
401    pub span: Span,
402    #[label(hir_analysis_previous_bound_label)]
403    pub prev_span: Span,
404    pub item_name: Ident,
405    pub def_path: String,
406}
407
408#[derive(Diagnostic)]
409#[diag(hir_analysis_unconstrained_opaque_type)]
410#[note]
411pub(crate) struct UnconstrainedOpaqueType {
412    #[primary_span]
413    pub span: Span,
414    pub name: Ident,
415    pub what: &'static str,
416}
417
418#[derive(Diagnostic)]
419#[diag(hir_analysis_tait_forward_compat2)]
420#[note]
421pub(crate) struct TaitForwardCompat2 {
422    #[primary_span]
423    pub span: Span,
424    #[note(hir_analysis_opaque)]
425    pub opaque_type_span: Span,
426    pub opaque_type: String,
427}
428
429pub(crate) struct MissingTypeParams {
430    pub span: Span,
431    pub def_span: Span,
432    pub span_snippet: Option<String>,
433    pub missing_type_params: Vec<Symbol>,
434    pub empty_generic_args: bool,
435}
436
437// Manual implementation of `Diagnostic` to be able to call `span_to_snippet`.
438impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for MissingTypeParams {
439    #[track_caller]
440    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
441        let mut err = Diag::new(dcx, level, fluent::hir_analysis_missing_type_params);
442        err.span(self.span);
443        err.code(E0393);
444        err.arg("parameterCount", self.missing_type_params.len());
445        err.arg(
446            "parameters",
447            self.missing_type_params
448                .iter()
449                .map(|n| format!("`{n}`"))
450                .collect::<Vec<_>>()
451                .join(", "),
452        );
453
454        err.span_label(self.def_span, fluent::hir_analysis_label);
455
456        let mut suggested = false;
457        // Don't suggest setting the type params if there are some already: the order is
458        // tricky to get right and the user will already know what the syntax is.
459        if let Some(snippet) = self.span_snippet
460            && self.empty_generic_args
461        {
462            if snippet.ends_with('>') {
463                // The user wrote `Trait<'a, T>` or similar. To provide an accurate suggestion
464                // we would have to preserve the right order. For now, as clearly the user is
465                // aware of the syntax, we do nothing.
466            } else {
467                // The user wrote `Iterator`, so we don't have a type we can suggest, but at
468                // least we can clue them to the correct syntax `Iterator<Type>`.
469                err.span_suggestion_verbose(
470                    self.span.shrink_to_hi(),
471                    fluent::hir_analysis_suggestion,
472                    format!(
473                        "<{}>",
474                        self.missing_type_params
475                            .iter()
476                            .map(|n| n.to_string())
477                            .collect::<Vec<_>>()
478                            .join(", ")
479                    ),
480                    Applicability::HasPlaceholders,
481                );
482                suggested = true;
483            }
484        }
485        if !suggested {
486            err.span_label(self.span, fluent::hir_analysis_no_suggestion_label);
487        }
488
489        err.note(fluent::hir_analysis_note);
490        err
491    }
492}
493
494#[derive(Diagnostic)]
495#[diag(hir_analysis_manual_implementation, code = E0183)]
496#[help]
497pub(crate) struct ManualImplementation {
498    #[primary_span]
499    #[label]
500    pub span: Span,
501    pub trait_name: String,
502}
503
504#[derive(Diagnostic)]
505#[diag(hir_analysis_generic_args_on_overridden_impl)]
506pub(crate) struct GenericArgsOnOverriddenImpl {
507    #[primary_span]
508    pub span: Span,
509}
510
511#[derive(Diagnostic)]
512#[diag(hir_analysis_const_impl_for_non_const_trait)]
513pub(crate) struct ConstImplForNonConstTrait {
514    #[primary_span]
515    #[label]
516    pub trait_ref_span: Span,
517    pub trait_name: String,
518    #[suggestion(
519        applicability = "machine-applicable",
520        code = "#[const_trait] ",
521        style = "verbose"
522    )]
523    pub local_trait_span: Option<Span>,
524    pub suggestion_pre: &'static str,
525    #[note]
526    pub marking: (),
527    #[note(hir_analysis_adding)]
528    pub adding: (),
529}
530
531#[derive(Diagnostic)]
532#[diag(hir_analysis_const_bound_for_non_const_trait)]
533pub(crate) struct ConstBoundForNonConstTrait {
534    #[primary_span]
535    #[label]
536    pub span: Span,
537    pub modifier: &'static str,
538    #[note]
539    pub def_span: Option<Span>,
540    pub suggestion_pre: &'static str,
541    #[suggestion(
542        applicability = "machine-applicable",
543        code = "#[const_trait] ",
544        style = "verbose"
545    )]
546    pub suggestion: Option<Span>,
547    pub trait_name: String,
548}
549
550#[derive(Diagnostic)]
551#[diag(hir_analysis_self_in_impl_self)]
552pub(crate) struct SelfInImplSelf {
553    #[primary_span]
554    pub span: MultiSpan,
555    #[note]
556    pub note: (),
557}
558
559#[derive(Diagnostic)]
560#[diag(hir_analysis_linkage_type, code = E0791)]
561pub(crate) struct LinkageType {
562    #[primary_span]
563    pub span: Span,
564}
565
566#[derive(Diagnostic)]
567#[help]
568#[diag(hir_analysis_auto_deref_reached_recursion_limit, code = E0055)]
569pub(crate) struct AutoDerefReachedRecursionLimit<'a> {
570    #[primary_span]
571    #[label]
572    pub span: Span,
573    pub ty: Ty<'a>,
574    pub suggested_limit: rustc_session::Limit,
575    pub crate_name: Symbol,
576}
577
578#[derive(Diagnostic)]
579#[diag(hir_analysis_where_clause_on_main, code = E0646)]
580pub(crate) struct WhereClauseOnMain {
581    #[primary_span]
582    pub span: Span,
583    #[label]
584    pub generics_span: Option<Span>,
585}
586
587#[derive(Diagnostic)]
588#[diag(hir_analysis_track_caller_on_main)]
589pub(crate) struct TrackCallerOnMain {
590    #[primary_span]
591    #[suggestion(applicability = "maybe-incorrect", code = "")]
592    pub span: Span,
593    #[label(hir_analysis_track_caller_on_main)]
594    pub annotated: Span,
595}
596
597#[derive(Diagnostic)]
598#[diag(hir_analysis_target_feature_on_main)]
599pub(crate) struct TargetFeatureOnMain {
600    #[primary_span]
601    #[label(hir_analysis_target_feature_on_main)]
602    pub main: Span,
603}
604
605#[derive(Diagnostic)]
606#[diag(hir_analysis_main_function_return_type_generic, code = E0131)]
607pub(crate) struct MainFunctionReturnTypeGeneric {
608    #[primary_span]
609    pub span: Span,
610}
611
612#[derive(Diagnostic)]
613#[diag(hir_analysis_main_function_async, code = E0752)]
614pub(crate) struct MainFunctionAsync {
615    #[primary_span]
616    pub span: Span,
617    #[label]
618    pub asyncness: Option<Span>,
619}
620
621#[derive(Diagnostic)]
622#[diag(hir_analysis_main_function_generic_parameters, code = E0131)]
623pub(crate) struct MainFunctionGenericParameters {
624    #[primary_span]
625    pub span: Span,
626    #[label]
627    pub label_span: Option<Span>,
628}
629
630#[derive(Diagnostic)]
631#[diag(hir_analysis_variadic_function_compatible_convention, code = E0045)]
632pub(crate) struct VariadicFunctionCompatibleConvention<'a> {
633    #[primary_span]
634    #[label]
635    pub span: Span,
636    pub convention: &'a str,
637}
638
639#[derive(Diagnostic)]
640pub(crate) enum CannotCaptureLateBound {
641    #[diag(hir_analysis_cannot_capture_late_bound_ty)]
642    Type {
643        #[primary_span]
644        use_span: Span,
645        #[label]
646        def_span: Span,
647        what: &'static str,
648    },
649    #[diag(hir_analysis_cannot_capture_late_bound_const)]
650    Const {
651        #[primary_span]
652        use_span: Span,
653        #[label]
654        def_span: Span,
655        what: &'static str,
656    },
657    #[diag(hir_analysis_cannot_capture_late_bound_lifetime)]
658    Lifetime {
659        #[primary_span]
660        use_span: Span,
661        #[label]
662        def_span: Span,
663        what: &'static str,
664    },
665}
666
667#[derive(Diagnostic)]
668#[diag(hir_analysis_variances_of)]
669pub(crate) struct VariancesOf {
670    #[primary_span]
671    pub span: Span,
672    pub variances: String,
673}
674
675#[derive(Diagnostic)]
676#[diag(hir_analysis_type_of)]
677pub(crate) struct TypeOf<'tcx> {
678    #[primary_span]
679    pub span: Span,
680    pub ty: Ty<'tcx>,
681}
682
683#[derive(Diagnostic)]
684#[diag(hir_analysis_invalid_union_field, code = E0740)]
685pub(crate) struct InvalidUnionField {
686    #[primary_span]
687    pub field_span: Span,
688    #[subdiagnostic]
689    pub sugg: InvalidUnionFieldSuggestion,
690    #[note]
691    pub note: (),
692}
693
694#[derive(Diagnostic)]
695#[diag(hir_analysis_return_type_notation_on_non_rpitit)]
696pub(crate) struct ReturnTypeNotationOnNonRpitit<'tcx> {
697    #[primary_span]
698    pub span: Span,
699    pub ty: Ty<'tcx>,
700    #[label]
701    pub fn_span: Option<Span>,
702    #[note]
703    pub note: (),
704}
705
706#[derive(Subdiagnostic)]
707#[multipart_suggestion(hir_analysis_invalid_union_field_sugg, applicability = "machine-applicable")]
708pub(crate) struct InvalidUnionFieldSuggestion {
709    #[suggestion_part(code = "std::mem::ManuallyDrop<")]
710    pub lo: Span,
711    #[suggestion_part(code = ">")]
712    pub hi: Span,
713}
714
715#[derive(Diagnostic)]
716#[diag(hir_analysis_return_type_notation_equality_bound)]
717pub(crate) struct ReturnTypeNotationEqualityBound {
718    #[primary_span]
719    pub span: Span,
720}
721
722#[derive(Diagnostic)]
723#[diag(hir_analysis_placeholder_not_allowed_item_signatures, code = E0121)]
724pub(crate) struct PlaceholderNotAllowedItemSignatures {
725    #[primary_span]
726    #[label]
727    pub spans: Vec<Span>,
728    pub kind: String,
729}
730
731#[derive(Diagnostic)]
732#[diag(hir_analysis_associated_type_trait_uninferred_generic_params, code = E0212)]
733pub(crate) struct AssociatedItemTraitUninferredGenericParams {
734    #[primary_span]
735    pub span: Span,
736    #[suggestion(style = "verbose", applicability = "maybe-incorrect", code = "{bound}")]
737    pub inferred_sugg: Option<Span>,
738    pub bound: String,
739    #[subdiagnostic]
740    pub mpart_sugg: Option<AssociatedItemTraitUninferredGenericParamsMultipartSuggestion>,
741    pub what: &'static str,
742}
743
744#[derive(Subdiagnostic)]
745#[multipart_suggestion(
746    hir_analysis_associated_type_trait_uninferred_generic_params_multipart_suggestion,
747    applicability = "maybe-incorrect"
748)]
749pub(crate) struct AssociatedItemTraitUninferredGenericParamsMultipartSuggestion {
750    #[suggestion_part(code = "{first}")]
751    pub fspan: Span,
752    pub first: String,
753    #[suggestion_part(code = "{second}")]
754    pub sspan: Span,
755    pub second: String,
756}
757
758#[derive(Diagnostic)]
759#[diag(hir_analysis_enum_discriminant_overflowed, code = E0370)]
760#[note]
761pub(crate) struct EnumDiscriminantOverflowed {
762    #[primary_span]
763    #[label]
764    pub span: Span,
765    pub discr: String,
766    pub item_name: Ident,
767    pub wrapped_discr: String,
768}
769
770#[derive(Diagnostic)]
771#[diag(hir_analysis_paren_sugar_attribute)]
772#[help]
773pub(crate) struct ParenSugarAttribute {
774    #[primary_span]
775    pub span: Span,
776}
777
778#[derive(Diagnostic)]
779#[diag(hir_analysis_must_implement_one_of_attribute)]
780pub(crate) struct MustImplementOneOfAttribute {
781    #[primary_span]
782    pub span: Span,
783}
784
785#[derive(Diagnostic)]
786#[diag(hir_analysis_must_be_name_of_associated_function)]
787pub(crate) struct MustBeNameOfAssociatedFunction {
788    #[primary_span]
789    pub span: Span,
790}
791
792#[derive(Diagnostic)]
793#[diag(hir_analysis_function_not_have_default_implementation)]
794pub(crate) struct FunctionNotHaveDefaultImplementation {
795    #[primary_span]
796    pub span: Span,
797    #[note]
798    pub note_span: Span,
799}
800
801#[derive(Diagnostic)]
802#[diag(hir_analysis_must_implement_not_function)]
803pub(crate) struct MustImplementNotFunction {
804    #[primary_span]
805    pub span: Span,
806    #[subdiagnostic]
807    pub span_note: MustImplementNotFunctionSpanNote,
808    #[subdiagnostic]
809    pub note: MustImplementNotFunctionNote,
810}
811
812#[derive(Subdiagnostic)]
813#[note(hir_analysis_must_implement_not_function_span_note)]
814pub(crate) struct MustImplementNotFunctionSpanNote {
815    #[primary_span]
816    pub span: Span,
817}
818
819#[derive(Subdiagnostic)]
820#[note(hir_analysis_must_implement_not_function_note)]
821pub(crate) struct MustImplementNotFunctionNote {}
822
823#[derive(Diagnostic)]
824#[diag(hir_analysis_function_not_found_in_trait)]
825pub(crate) struct FunctionNotFoundInTrait {
826    #[primary_span]
827    pub span: Span,
828}
829
830#[derive(Diagnostic)]
831#[diag(hir_analysis_functions_names_duplicated)]
832#[note]
833pub(crate) struct FunctionNamesDuplicated {
834    #[primary_span]
835    pub spans: Vec<Span>,
836}
837
838#[derive(Diagnostic)]
839#[diag(hir_analysis_simd_ffi_highly_experimental)]
840#[help]
841pub(crate) struct SIMDFFIHighlyExperimental {
842    #[primary_span]
843    pub span: Span,
844    pub snip: String,
845}
846
847#[derive(Diagnostic)]
848pub(crate) enum ImplNotMarkedDefault {
849    #[diag(hir_analysis_impl_not_marked_default, code = E0520)]
850    #[note]
851    Ok {
852        #[primary_span]
853        #[label]
854        span: Span,
855        #[label(hir_analysis_ok_label)]
856        ok_label: Span,
857        ident: Ident,
858    },
859    #[diag(hir_analysis_impl_not_marked_default_err, code = E0520)]
860    #[note]
861    Err {
862        #[primary_span]
863        span: Span,
864        cname: Symbol,
865        ident: Ident,
866    },
867}
868
869#[derive(LintDiagnostic)]
870#[diag(hir_analysis_useless_impl_item)]
871pub(crate) struct UselessImplItem;
872
873#[derive(Diagnostic)]
874#[diag(hir_analysis_missing_trait_item, code = E0046)]
875pub(crate) struct MissingTraitItem {
876    #[primary_span]
877    #[label]
878    pub span: Span,
879    #[subdiagnostic]
880    pub missing_trait_item_label: Vec<MissingTraitItemLabel>,
881    #[subdiagnostic]
882    pub missing_trait_item: Vec<MissingTraitItemSuggestion>,
883    #[subdiagnostic]
884    pub missing_trait_item_none: Vec<MissingTraitItemSuggestionNone>,
885    pub missing_items_msg: String,
886}
887
888#[derive(Subdiagnostic)]
889#[label(hir_analysis_missing_trait_item_label)]
890pub(crate) struct MissingTraitItemLabel {
891    #[primary_span]
892    pub span: Span,
893    pub item: Symbol,
894}
895
896#[derive(Subdiagnostic)]
897#[suggestion(
898    hir_analysis_missing_trait_item_suggestion,
899    style = "tool-only",
900    applicability = "has-placeholders",
901    code = "{code}"
902)]
903pub(crate) struct MissingTraitItemSuggestion {
904    #[primary_span]
905    pub span: Span,
906    pub code: String,
907    pub snippet: String,
908}
909
910#[derive(Subdiagnostic)]
911#[suggestion(
912    hir_analysis_missing_trait_item_suggestion,
913    style = "hidden",
914    applicability = "has-placeholders",
915    code = "{code}"
916)]
917pub(crate) struct MissingTraitItemSuggestionNone {
918    #[primary_span]
919    pub span: Span,
920    pub code: String,
921    pub snippet: String,
922}
923
924#[derive(Diagnostic)]
925#[diag(hir_analysis_missing_one_of_trait_item, code = E0046)]
926pub(crate) struct MissingOneOfTraitItem {
927    #[primary_span]
928    #[label]
929    pub span: Span,
930    #[note]
931    pub note: Option<Span>,
932    pub missing_items_msg: String,
933}
934
935#[derive(Diagnostic)]
936#[diag(hir_analysis_missing_trait_item_unstable, code = E0046)]
937#[note]
938pub(crate) struct MissingTraitItemUnstable {
939    #[primary_span]
940    pub span: Span,
941    #[note(hir_analysis_some_note)]
942    pub some_note: bool,
943    #[note(hir_analysis_none_note)]
944    pub none_note: bool,
945    pub missing_item_name: Ident,
946    pub feature: Symbol,
947    pub reason: String,
948}
949
950#[derive(Diagnostic)]
951#[diag(hir_analysis_transparent_enum_variant, code = E0731)]
952pub(crate) struct TransparentEnumVariant {
953    #[primary_span]
954    #[label]
955    pub span: Span,
956    #[label(hir_analysis_multi_label)]
957    pub spans: Vec<Span>,
958    #[label(hir_analysis_many_label)]
959    pub many: Option<Span>,
960    pub number: usize,
961    pub path: String,
962}
963
964#[derive(Diagnostic)]
965#[diag(hir_analysis_transparent_non_zero_sized_enum, code = E0690)]
966pub(crate) struct TransparentNonZeroSizedEnum<'a> {
967    #[primary_span]
968    #[label]
969    pub span: Span,
970    #[label(hir_analysis_labels)]
971    pub spans: Vec<Span>,
972    pub field_count: usize,
973    pub desc: &'a str,
974}
975
976#[derive(Diagnostic)]
977#[diag(hir_analysis_transparent_non_zero_sized, code = E0690)]
978pub(crate) struct TransparentNonZeroSized<'a> {
979    #[primary_span]
980    #[label]
981    pub span: Span,
982    #[label(hir_analysis_labels)]
983    pub spans: Vec<Span>,
984    pub field_count: usize,
985    pub desc: &'a str,
986}
987
988#[derive(Diagnostic)]
989#[diag(hir_analysis_too_large_static)]
990pub(crate) struct TooLargeStatic {
991    #[primary_span]
992    pub span: Span,
993}
994
995#[derive(Diagnostic)]
996#[diag(hir_analysis_specialization_trait)]
997#[help]
998pub(crate) struct SpecializationTrait {
999    #[primary_span]
1000    pub span: Span,
1001}
1002
1003#[derive(Diagnostic)]
1004#[diag(hir_analysis_closure_implicit_hrtb)]
1005pub(crate) struct ClosureImplicitHrtb {
1006    #[primary_span]
1007    pub spans: Vec<Span>,
1008    #[label]
1009    pub for_sp: Span,
1010}
1011
1012#[derive(Diagnostic)]
1013#[diag(hir_analysis_empty_specialization)]
1014pub(crate) struct EmptySpecialization {
1015    #[primary_span]
1016    pub span: Span,
1017    #[note]
1018    pub base_impl_span: Span,
1019}
1020
1021#[derive(Diagnostic)]
1022#[diag(hir_analysis_static_specialize)]
1023pub(crate) struct StaticSpecialize {
1024    #[primary_span]
1025    pub span: Span,
1026}
1027
1028#[derive(Diagnostic)]
1029pub(crate) enum DropImplPolarity {
1030    #[diag(hir_analysis_drop_impl_negative)]
1031    Negative {
1032        #[primary_span]
1033        span: Span,
1034    },
1035    #[diag(hir_analysis_drop_impl_reservation)]
1036    Reservation {
1037        #[primary_span]
1038        span: Span,
1039    },
1040}
1041
1042#[derive(Diagnostic)]
1043pub(crate) enum ReturnTypeNotationIllegalParam {
1044    #[diag(hir_analysis_return_type_notation_illegal_param_type)]
1045    Type {
1046        #[primary_span]
1047        span: Span,
1048        #[label]
1049        param_span: Span,
1050    },
1051    #[diag(hir_analysis_return_type_notation_illegal_param_const)]
1052    Const {
1053        #[primary_span]
1054        span: Span,
1055        #[label]
1056        param_span: Span,
1057    },
1058}
1059
1060#[derive(Diagnostic)]
1061pub(crate) enum LateBoundInApit {
1062    #[diag(hir_analysis_late_bound_type_in_apit)]
1063    Type {
1064        #[primary_span]
1065        span: Span,
1066        #[label]
1067        param_span: Span,
1068    },
1069    #[diag(hir_analysis_late_bound_const_in_apit)]
1070    Const {
1071        #[primary_span]
1072        span: Span,
1073        #[label]
1074        param_span: Span,
1075    },
1076    #[diag(hir_analysis_late_bound_lifetime_in_apit)]
1077    Lifetime {
1078        #[primary_span]
1079        span: Span,
1080        #[label]
1081        param_span: Span,
1082    },
1083}
1084
1085#[derive(LintDiagnostic)]
1086#[diag(hir_analysis_unused_associated_type_bounds)]
1087#[note]
1088pub(crate) struct UnusedAssociatedTypeBounds {
1089    #[suggestion(code = "")]
1090    pub span: Span,
1091}
1092
1093#[derive(LintDiagnostic)]
1094#[diag(hir_analysis_rpitit_refined)]
1095#[note]
1096#[note(hir_analysis_feedback_note)]
1097pub(crate) struct ReturnPositionImplTraitInTraitRefined<'tcx> {
1098    #[suggestion(applicability = "maybe-incorrect", code = "{pre}{return_ty}{post}")]
1099    pub impl_return_span: Span,
1100    #[label]
1101    pub trait_return_span: Option<Span>,
1102    #[label(hir_analysis_unmatched_bound_label)]
1103    pub unmatched_bound: Option<Span>,
1104
1105    pub pre: &'static str,
1106    pub post: &'static str,
1107    pub return_ty: Ty<'tcx>,
1108}
1109
1110#[derive(LintDiagnostic)]
1111#[diag(hir_analysis_rpitit_refined_lifetimes)]
1112#[note]
1113#[note(hir_analysis_feedback_note)]
1114pub(crate) struct ReturnPositionImplTraitInTraitRefinedLifetimes {
1115    #[suggestion(applicability = "maybe-incorrect", code = "{suggestion}")]
1116    pub suggestion_span: Span,
1117    pub suggestion: String,
1118}
1119
1120#[derive(Diagnostic)]
1121#[diag(hir_analysis_inherent_ty_outside, code = E0390)]
1122#[help]
1123pub(crate) struct InherentTyOutside {
1124    #[primary_span]
1125    #[help(hir_analysis_span_help)]
1126    pub span: Span,
1127}
1128
1129#[derive(Diagnostic)]
1130#[diag(hir_analysis_dispatch_from_dyn_repr, code = E0378)]
1131pub(crate) struct DispatchFromDynRepr {
1132    #[primary_span]
1133    pub span: Span,
1134}
1135
1136#[derive(Diagnostic)]
1137#[diag(hir_analysis_coerce_pointee_not_struct, code = E0802)]
1138pub(crate) struct CoercePointeeNotStruct {
1139    #[primary_span]
1140    pub span: Span,
1141    pub kind: String,
1142}
1143
1144#[derive(Diagnostic)]
1145#[diag(hir_analysis_coerce_pointee_not_concrete_ty, code = E0802)]
1146pub(crate) struct CoercePointeeNotConcreteType {
1147    #[primary_span]
1148    pub span: Span,
1149}
1150
1151#[derive(Diagnostic)]
1152#[diag(hir_analysis_coerce_pointee_no_user_validity_assertion, code = E0802)]
1153pub(crate) struct CoercePointeeNoUserValidityAssertion {
1154    #[primary_span]
1155    pub span: Span,
1156}
1157
1158#[derive(Diagnostic)]
1159#[diag(hir_analysis_coerce_pointee_not_transparent, code = E0802)]
1160pub(crate) struct CoercePointeeNotTransparent {
1161    #[primary_span]
1162    pub span: Span,
1163}
1164
1165#[derive(Diagnostic)]
1166#[diag(hir_analysis_coerce_pointee_no_field, code = E0802)]
1167pub(crate) struct CoercePointeeNoField {
1168    #[primary_span]
1169    pub span: Span,
1170}
1171
1172#[derive(Diagnostic)]
1173#[diag(hir_analysis_inherent_ty_outside_relevant, code = E0390)]
1174#[help]
1175pub(crate) struct InherentTyOutsideRelevant {
1176    #[primary_span]
1177    pub span: Span,
1178    #[help(hir_analysis_span_help)]
1179    pub help_span: Span,
1180}
1181
1182#[derive(Diagnostic)]
1183#[diag(hir_analysis_inherent_ty_outside_new, code = E0116)]
1184#[note]
1185pub(crate) struct InherentTyOutsideNew {
1186    #[primary_span]
1187    #[label]
1188    pub span: Span,
1189}
1190
1191#[derive(Diagnostic)]
1192#[diag(hir_analysis_inherent_ty_outside_primitive, code = E0390)]
1193#[help]
1194pub(crate) struct InherentTyOutsidePrimitive {
1195    #[primary_span]
1196    pub span: Span,
1197    #[help(hir_analysis_span_help)]
1198    pub help_span: Span,
1199}
1200
1201#[derive(Diagnostic)]
1202#[diag(hir_analysis_inherent_primitive_ty, code = E0390)]
1203#[help]
1204pub(crate) struct InherentPrimitiveTy<'a> {
1205    #[primary_span]
1206    pub span: Span,
1207    #[subdiagnostic]
1208    pub note: Option<InherentPrimitiveTyNote<'a>>,
1209}
1210
1211#[derive(Subdiagnostic)]
1212#[note(hir_analysis_inherent_primitive_ty_note)]
1213pub(crate) struct InherentPrimitiveTyNote<'a> {
1214    pub subty: Ty<'a>,
1215}
1216
1217#[derive(Diagnostic)]
1218#[diag(hir_analysis_inherent_dyn, code = E0785)]
1219#[note]
1220pub(crate) struct InherentDyn {
1221    #[primary_span]
1222    #[label]
1223    pub span: Span,
1224}
1225
1226#[derive(Diagnostic)]
1227#[diag(hir_analysis_inherent_nominal, code = E0118)]
1228#[note]
1229pub(crate) struct InherentNominal {
1230    #[primary_span]
1231    #[label]
1232    pub span: Span,
1233}
1234
1235#[derive(Diagnostic)]
1236#[diag(hir_analysis_dispatch_from_dyn_zst, code = E0378)]
1237#[note]
1238pub(crate) struct DispatchFromDynZST<'a> {
1239    #[primary_span]
1240    pub span: Span,
1241    pub name: Ident,
1242    pub ty: Ty<'a>,
1243}
1244
1245#[derive(Diagnostic)]
1246#[diag(hir_analysis_coerce_zero, code = E0374)]
1247pub(crate) struct CoerceNoField {
1248    #[primary_span]
1249    pub span: Span,
1250    pub trait_name: &'static str,
1251    #[note(hir_analysis_coercion_between_struct_single_note)]
1252    pub note: bool,
1253}
1254
1255#[derive(Diagnostic)]
1256#[diag(hir_analysis_coerce_multi, code = E0375)]
1257pub(crate) struct CoerceMulti {
1258    pub trait_name: &'static str,
1259    #[primary_span]
1260    pub span: Span,
1261    pub number: usize,
1262    #[note]
1263    pub fields: MultiSpan,
1264}
1265
1266#[derive(Diagnostic)]
1267#[diag(hir_analysis_coerce_unsized_may, code = E0377)]
1268pub(crate) struct CoerceUnsizedNonStruct {
1269    #[primary_span]
1270    pub span: Span,
1271    pub trait_name: &'static str,
1272}
1273
1274#[derive(Diagnostic)]
1275#[diag(hir_analysis_coerce_unsized_may, code = E0377)]
1276pub(crate) struct CoerceSameStruct {
1277    #[primary_span]
1278    pub span: Span,
1279    pub trait_name: &'static str,
1280    #[note(hir_analysis_coercion_between_struct_same_note)]
1281    pub note: bool,
1282    pub source_path: String,
1283    pub target_path: String,
1284}
1285
1286#[derive(Diagnostic)]
1287#[diag(hir_analysis_coerce_unsized_field_validity)]
1288pub(crate) struct CoerceFieldValidity<'tcx> {
1289    #[primary_span]
1290    pub span: Span,
1291    pub ty: Ty<'tcx>,
1292    pub trait_name: &'static str,
1293    #[label]
1294    pub field_span: Span,
1295    pub field_ty: Ty<'tcx>,
1296}
1297
1298#[derive(Diagnostic)]
1299#[diag(hir_analysis_trait_cannot_impl_for_ty, code = E0204)]
1300pub(crate) struct TraitCannotImplForTy {
1301    #[primary_span]
1302    pub span: Span,
1303    pub trait_name: String,
1304    #[label]
1305    pub label_spans: Vec<Span>,
1306    #[subdiagnostic]
1307    pub notes: Vec<ImplForTyRequires>,
1308}
1309
1310#[derive(Subdiagnostic)]
1311#[note(hir_analysis_requires_note)]
1312pub(crate) struct ImplForTyRequires {
1313    #[primary_span]
1314    pub span: MultiSpan,
1315    pub error_predicate: String,
1316    pub trait_name: String,
1317    pub ty: String,
1318}
1319
1320#[derive(Diagnostic)]
1321#[diag(hir_analysis_traits_with_default_impl, code = E0321)]
1322#[note]
1323pub(crate) struct TraitsWithDefaultImpl<'a> {
1324    #[primary_span]
1325    pub span: Span,
1326    pub traits: String,
1327    pub problematic_kind: &'a str,
1328    pub self_ty: Ty<'a>,
1329}
1330
1331#[derive(Diagnostic)]
1332#[diag(hir_analysis_cross_crate_traits, code = E0321)]
1333pub(crate) struct CrossCrateTraits<'a> {
1334    #[primary_span]
1335    #[label]
1336    pub span: Span,
1337    pub traits: String,
1338    pub self_ty: Ty<'a>,
1339}
1340
1341#[derive(Diagnostic)]
1342#[diag(hir_analysis_cross_crate_traits_defined, code = E0321)]
1343pub(crate) struct CrossCrateTraitsDefined {
1344    #[primary_span]
1345    #[label]
1346    pub span: Span,
1347    pub traits: String,
1348}
1349
1350#[derive(Diagnostic)]
1351#[diag(hir_analysis_no_variant_named, code = E0599)]
1352pub struct NoVariantNamed<'tcx> {
1353    #[primary_span]
1354    pub span: Span,
1355    pub ident: Ident,
1356    pub ty: Ty<'tcx>,
1357}
1358
1359// FIXME(fmease): Deduplicate:
1360
1361#[derive(Diagnostic)]
1362#[diag(hir_analysis_ty_param_first_local, code = E0210)]
1363#[note]
1364pub(crate) struct TyParamFirstLocal<'tcx> {
1365    #[primary_span]
1366    #[label]
1367    pub span: Span,
1368    #[note(hir_analysis_case_note)]
1369    pub note: (),
1370    pub param: Ident,
1371    pub local_type: Ty<'tcx>,
1372}
1373
1374#[derive(LintDiagnostic)]
1375#[diag(hir_analysis_ty_param_first_local, code = E0210)]
1376#[note]
1377pub(crate) struct TyParamFirstLocalLint<'tcx> {
1378    #[label]
1379    pub span: Span,
1380    #[note(hir_analysis_case_note)]
1381    pub note: (),
1382    pub param: Ident,
1383    pub local_type: Ty<'tcx>,
1384}
1385
1386#[derive(Diagnostic)]
1387#[diag(hir_analysis_ty_param_some, code = E0210)]
1388#[note]
1389pub(crate) struct TyParamSome {
1390    #[primary_span]
1391    #[label]
1392    pub span: Span,
1393    #[note(hir_analysis_only_note)]
1394    pub note: (),
1395    pub param: Ident,
1396}
1397
1398#[derive(LintDiagnostic)]
1399#[diag(hir_analysis_ty_param_some, code = E0210)]
1400#[note]
1401pub(crate) struct TyParamSomeLint {
1402    #[label]
1403    pub span: Span,
1404    #[note(hir_analysis_only_note)]
1405    pub note: (),
1406    pub param: Ident,
1407}
1408
1409#[derive(Diagnostic)]
1410pub(crate) enum OnlyCurrentTraits {
1411    #[diag(hir_analysis_only_current_traits_outside, code = E0117)]
1412    Outside {
1413        #[primary_span]
1414        span: Span,
1415        #[note(hir_analysis_only_current_traits_note_uncovered)]
1416        #[note(hir_analysis_only_current_traits_note_more_info)]
1417        #[note(hir_analysis_only_current_traits_note)]
1418        note: (),
1419    },
1420    #[diag(hir_analysis_only_current_traits_primitive, code = E0117)]
1421    Primitive {
1422        #[primary_span]
1423        span: Span,
1424        #[note(hir_analysis_only_current_traits_note_uncovered)]
1425        #[note(hir_analysis_only_current_traits_note_more_info)]
1426        #[note(hir_analysis_only_current_traits_note)]
1427        note: (),
1428    },
1429    #[diag(hir_analysis_only_current_traits_arbitrary, code = E0117)]
1430    Arbitrary {
1431        #[primary_span]
1432        span: Span,
1433        #[note(hir_analysis_only_current_traits_note_uncovered)]
1434        #[note(hir_analysis_only_current_traits_note_more_info)]
1435        #[note(hir_analysis_only_current_traits_note)]
1436        note: (),
1437    },
1438}
1439
1440#[derive(Subdiagnostic)]
1441#[label(hir_analysis_only_current_traits_opaque)]
1442pub(crate) struct OnlyCurrentTraitsOpaque {
1443    #[primary_span]
1444    pub span: Span,
1445}
1446#[derive(Subdiagnostic)]
1447#[label(hir_analysis_only_current_traits_foreign)]
1448pub(crate) struct OnlyCurrentTraitsForeign {
1449    #[primary_span]
1450    pub span: Span,
1451}
1452
1453#[derive(Subdiagnostic)]
1454#[label(hir_analysis_only_current_traits_name)]
1455pub(crate) struct OnlyCurrentTraitsName<'a> {
1456    #[primary_span]
1457    pub span: Span,
1458    pub name: &'a str,
1459}
1460
1461#[derive(Subdiagnostic)]
1462#[label(hir_analysis_only_current_traits_pointer)]
1463pub(crate) struct OnlyCurrentTraitsPointer<'a> {
1464    #[primary_span]
1465    pub span: Span,
1466    pub pointer: Ty<'a>,
1467}
1468
1469#[derive(Subdiagnostic)]
1470#[label(hir_analysis_only_current_traits_ty)]
1471pub(crate) struct OnlyCurrentTraitsTy<'a> {
1472    #[primary_span]
1473    pub span: Span,
1474    pub ty: Ty<'a>,
1475}
1476
1477#[derive(Subdiagnostic)]
1478#[label(hir_analysis_only_current_traits_adt)]
1479pub(crate) struct OnlyCurrentTraitsAdt {
1480    #[primary_span]
1481    pub span: Span,
1482    pub name: String,
1483}
1484
1485#[derive(Subdiagnostic)]
1486#[multipart_suggestion(
1487    hir_analysis_only_current_traits_pointer_sugg,
1488    applicability = "maybe-incorrect"
1489)]
1490pub(crate) struct OnlyCurrentTraitsPointerSugg<'a> {
1491    #[suggestion_part(code = "WrapperType")]
1492    pub wrapper_span: Span,
1493    #[suggestion_part(code = "struct WrapperType(*{mut_key}{ptr_ty});\n\n")]
1494    pub(crate) struct_span: Span,
1495    pub mut_key: &'a str,
1496    pub ptr_ty: Ty<'a>,
1497}
1498
1499#[derive(Diagnostic)]
1500#[diag(hir_analysis_not_supported_delegation)]
1501pub(crate) struct UnsupportedDelegation<'a> {
1502    #[primary_span]
1503    pub span: Span,
1504    pub descr: &'a str,
1505    #[label]
1506    pub callee_span: Span,
1507}
1508
1509#[derive(Diagnostic)]
1510#[diag(hir_analysis_method_should_return_future)]
1511pub(crate) struct MethodShouldReturnFuture {
1512    #[primary_span]
1513    pub span: Span,
1514    pub method_name: Ident,
1515    #[note]
1516    pub trait_item_span: Option<Span>,
1517}
1518
1519#[derive(Diagnostic)]
1520#[diag(hir_analysis_unused_generic_parameter)]
1521pub(crate) struct UnusedGenericParameter {
1522    #[primary_span]
1523    #[label]
1524    pub span: Span,
1525    pub param_name: Ident,
1526    pub param_def_kind: &'static str,
1527    #[label(hir_analysis_usage_spans)]
1528    pub usage_spans: Vec<Span>,
1529    #[subdiagnostic]
1530    pub help: UnusedGenericParameterHelp,
1531    #[help(hir_analysis_const_param_help)]
1532    pub const_param_help: bool,
1533}
1534
1535#[derive(Diagnostic)]
1536#[diag(hir_analysis_recursive_generic_parameter)]
1537pub(crate) struct RecursiveGenericParameter {
1538    #[primary_span]
1539    pub spans: Vec<Span>,
1540    #[label]
1541    pub param_span: Span,
1542    pub param_name: Ident,
1543    pub param_def_kind: &'static str,
1544    #[subdiagnostic]
1545    pub help: UnusedGenericParameterHelp,
1546    #[note]
1547    pub note: (),
1548}
1549
1550#[derive(Subdiagnostic)]
1551pub(crate) enum UnusedGenericParameterHelp {
1552    #[help(hir_analysis_unused_generic_parameter_adt_help)]
1553    Adt { param_name: Ident, phantom_data: String },
1554    #[help(hir_analysis_unused_generic_parameter_adt_no_phantom_data_help)]
1555    AdtNoPhantomData { param_name: Ident },
1556    #[help(hir_analysis_unused_generic_parameter_ty_alias_help)]
1557    TyAlias { param_name: Ident },
1558}
1559
1560#[derive(Diagnostic)]
1561#[diag(hir_analysis_unconstrained_generic_parameter)]
1562pub(crate) struct UnconstrainedGenericParameter {
1563    #[primary_span]
1564    #[label]
1565    pub span: Span,
1566    pub param_name: Ident,
1567    pub param_def_kind: &'static str,
1568    #[note(hir_analysis_const_param_note)]
1569    pub const_param_note: bool,
1570    #[note(hir_analysis_const_param_note2)]
1571    pub const_param_note2: bool,
1572}
1573
1574#[derive(Diagnostic)]
1575#[diag(hir_analysis_opaque_captures_higher_ranked_lifetime, code = E0657)]
1576pub(crate) struct OpaqueCapturesHigherRankedLifetime {
1577    #[primary_span]
1578    pub span: Span,
1579    #[label]
1580    pub label: Option<Span>,
1581    #[note]
1582    pub decl_span: Span,
1583    pub bad_place: &'static str,
1584}
1585
1586#[derive(Subdiagnostic)]
1587pub(crate) enum InvalidReceiverTyHint {
1588    #[note(hir_analysis_invalid_receiver_ty_help_weak_note)]
1589    Weak,
1590    #[note(hir_analysis_invalid_receiver_ty_help_nonnull_note)]
1591    NonNull,
1592}
1593
1594#[derive(Diagnostic)]
1595#[diag(hir_analysis_invalid_receiver_ty_no_arbitrary_self_types, code = E0307)]
1596#[note]
1597#[help(hir_analysis_invalid_receiver_ty_help_no_arbitrary_self_types)]
1598pub(crate) struct InvalidReceiverTyNoArbitrarySelfTypes<'tcx> {
1599    #[primary_span]
1600    pub span: Span,
1601    pub receiver_ty: Ty<'tcx>,
1602}
1603
1604#[derive(Diagnostic)]
1605#[diag(hir_analysis_invalid_receiver_ty, code = E0307)]
1606#[note]
1607#[help(hir_analysis_invalid_receiver_ty_help)]
1608pub(crate) struct InvalidReceiverTy<'tcx> {
1609    #[primary_span]
1610    pub span: Span,
1611    pub receiver_ty: Ty<'tcx>,
1612    #[subdiagnostic]
1613    pub hint: Option<InvalidReceiverTyHint>,
1614}
1615
1616#[derive(Diagnostic)]
1617#[diag(hir_analysis_invalid_generic_receiver_ty, code = E0801)]
1618#[note]
1619#[help(hir_analysis_invalid_generic_receiver_ty_help)]
1620pub(crate) struct InvalidGenericReceiverTy<'tcx> {
1621    #[primary_span]
1622    pub span: Span,
1623    pub receiver_ty: Ty<'tcx>,
1624}
1625
1626#[derive(Diagnostic)]
1627#[diag(hir_analysis_cmse_inputs_stack_spill, code = E0798)]
1628#[note]
1629pub(crate) struct CmseInputsStackSpill {
1630    #[primary_span]
1631    #[label]
1632    pub span: Span,
1633    pub plural: bool,
1634    pub abi: ExternAbi,
1635}
1636
1637#[derive(Diagnostic)]
1638#[diag(hir_analysis_cmse_output_stack_spill, code = E0798)]
1639#[note(hir_analysis_note1)]
1640#[note(hir_analysis_note2)]
1641pub(crate) struct CmseOutputStackSpill {
1642    #[primary_span]
1643    #[label]
1644    pub span: Span,
1645    pub abi: ExternAbi,
1646}
1647
1648#[derive(Diagnostic)]
1649#[diag(hir_analysis_cmse_call_generic, code = E0798)]
1650pub(crate) struct CmseCallGeneric {
1651    #[primary_span]
1652    pub span: Span,
1653}
1654
1655#[derive(Diagnostic)]
1656#[diag(hir_analysis_bad_return_type_notation_position)]
1657pub(crate) struct BadReturnTypeNotation {
1658    #[primary_span]
1659    pub span: Span,
1660}
1661
1662#[derive(Diagnostic)]
1663#[diag(hir_analysis_cmse_entry_generic, code = E0798)]
1664pub(crate) struct CmseEntryGeneric {
1665    #[primary_span]
1666    pub span: Span,
1667}
1668
1669#[derive(LintDiagnostic)]
1670#[diag(hir_analysis_supertrait_item_shadowing)]
1671pub(crate) struct SupertraitItemShadowing {
1672    pub item: Symbol,
1673    pub subtrait: Symbol,
1674    #[subdiagnostic]
1675    pub shadowee: SupertraitItemShadowee,
1676}
1677
1678#[derive(Subdiagnostic)]
1679pub(crate) enum SupertraitItemShadowee {
1680    #[note(hir_analysis_supertrait_item_shadowee)]
1681    Labeled {
1682        #[primary_span]
1683        span: Span,
1684        supertrait: Symbol,
1685    },
1686    #[note(hir_analysis_supertrait_item_multiple_shadowee)]
1687    Several {
1688        #[primary_span]
1689        spans: MultiSpan,
1690        traits: DiagSymbolList,
1691    },
1692}
1693
1694#[derive(Diagnostic)]
1695#[diag(hir_analysis_self_in_type_alias, code = E0411)]
1696pub(crate) struct SelfInTypeAlias {
1697    #[primary_span]
1698    #[label]
1699    pub span: Span,
1700}
1701
1702#[derive(Diagnostic)]
1703#[diag(hir_analysis_abi_custom_clothed_function)]
1704pub(crate) struct AbiCustomClothedFunction {
1705    #[primary_span]
1706    pub span: Span,
1707    #[suggestion(
1708        hir_analysis_suggestion,
1709        applicability = "maybe-incorrect",
1710        code = "#[unsafe(naked)]\n",
1711        style = "short"
1712    )]
1713    pub naked_span: Span,
1714}
1715
1716#[derive(Diagnostic)]
1717#[diag(hir_analysis_async_drop_without_sync_drop)]
1718#[help]
1719pub(crate) struct AsyncDropWithoutSyncDrop {
1720    #[primary_span]
1721    pub span: Span,
1722}