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