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