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: Option<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(
504 applicability = "machine-applicable",
505 code = "#[const_trait] ",
507 style = "verbose"
508 )]
509 pub local_trait_span: Option<Span>,
510 pub suggestion_pre: &'static str,
511 #[note]
512 pub marking: (),
513 #[note(hir_analysis_adding)]
514 pub adding: (),
515}
516
517#[derive(Diagnostic)]
518#[diag(hir_analysis_const_bound_for_non_const_trait)]
519pub(crate) struct ConstBoundForNonConstTrait {
520 #[primary_span]
521 #[label]
522 pub span: Span,
523 pub modifier: &'static str,
524 #[note]
525 pub def_span: Option<Span>,
526 pub suggestion_pre: &'static str,
527 #[suggestion(
528 applicability = "machine-applicable",
529 code = "#[const_trait] ",
531 style = "verbose"
532 )]
533 pub suggestion: Option<Span>,
534 pub trait_name: String,
535}
536
537#[derive(Diagnostic)]
538#[diag(hir_analysis_self_in_impl_self)]
539pub(crate) struct SelfInImplSelf {
540 #[primary_span]
541 pub span: MultiSpan,
542 #[note]
543 pub note: (),
544}
545
546#[derive(Diagnostic)]
547#[diag(hir_analysis_linkage_type, code = E0791)]
548pub(crate) struct LinkageType {
549 #[primary_span]
550 pub span: Span,
551}
552
553#[derive(Diagnostic)]
554#[help]
555#[diag(hir_analysis_auto_deref_reached_recursion_limit, code = E0055)]
556pub(crate) struct AutoDerefReachedRecursionLimit<'a> {
557 #[primary_span]
558 #[label]
559 pub span: Span,
560 pub ty: Ty<'a>,
561 pub suggested_limit: Limit,
562 pub crate_name: Symbol,
563}
564
565#[derive(Diagnostic)]
566#[diag(hir_analysis_where_clause_on_main, code = E0646)]
567pub(crate) struct WhereClauseOnMain {
568 #[primary_span]
569 pub span: Span,
570 #[label]
571 pub generics_span: Option<Span>,
572}
573
574#[derive(Diagnostic)]
575#[diag(hir_analysis_track_caller_on_main)]
576pub(crate) struct TrackCallerOnMain {
577 #[primary_span]
578 #[suggestion(applicability = "maybe-incorrect", code = "")]
579 pub span: Span,
580 #[label(hir_analysis_track_caller_on_main)]
581 pub annotated: Span,
582}
583
584#[derive(Diagnostic)]
585#[diag(hir_analysis_target_feature_on_main)]
586pub(crate) struct TargetFeatureOnMain {
587 #[primary_span]
588 #[label(hir_analysis_target_feature_on_main)]
589 pub main: Span,
590}
591
592#[derive(Diagnostic)]
593#[diag(hir_analysis_main_function_return_type_generic, code = E0131)]
594pub(crate) struct MainFunctionReturnTypeGeneric {
595 #[primary_span]
596 pub span: Span,
597}
598
599#[derive(Diagnostic)]
600#[diag(hir_analysis_main_function_async, code = E0752)]
601pub(crate) struct MainFunctionAsync {
602 #[primary_span]
603 pub span: Span,
604 #[label]
605 pub asyncness: Option<Span>,
606}
607
608#[derive(Diagnostic)]
609#[diag(hir_analysis_main_function_generic_parameters, code = E0131)]
610pub(crate) struct MainFunctionGenericParameters {
611 #[primary_span]
612 pub span: Span,
613 #[label]
614 pub label_span: Option<Span>,
615}
616
617#[derive(Diagnostic)]
618#[diag(hir_analysis_variadic_function_compatible_convention, code = E0045)]
619pub(crate) struct VariadicFunctionCompatibleConvention<'a> {
620 #[primary_span]
621 #[label]
622 pub span: Span,
623 pub convention: &'a str,
624}
625
626#[derive(Diagnostic)]
627pub(crate) enum CannotCaptureLateBound {
628 #[diag(hir_analysis_cannot_capture_late_bound_ty)]
629 Type {
630 #[primary_span]
631 use_span: Span,
632 #[label]
633 def_span: Span,
634 what: &'static str,
635 },
636 #[diag(hir_analysis_cannot_capture_late_bound_const)]
637 Const {
638 #[primary_span]
639 use_span: Span,
640 #[label]
641 def_span: Span,
642 what: &'static str,
643 },
644 #[diag(hir_analysis_cannot_capture_late_bound_lifetime)]
645 Lifetime {
646 #[primary_span]
647 use_span: Span,
648 #[label]
649 def_span: Span,
650 what: &'static str,
651 },
652}
653
654#[derive(Diagnostic)]
655#[diag(hir_analysis_variances_of)]
656pub(crate) struct VariancesOf {
657 #[primary_span]
658 pub span: Span,
659 pub variances: String,
660}
661
662#[derive(Diagnostic)]
663#[diag(hir_analysis_type_of)]
664pub(crate) struct TypeOf<'tcx> {
665 #[primary_span]
666 pub span: Span,
667 pub ty: Ty<'tcx>,
668}
669
670#[derive(Diagnostic)]
671#[diag(hir_analysis_invalid_union_field, code = E0740)]
672pub(crate) struct InvalidUnionField {
673 #[primary_span]
674 pub field_span: Span,
675 #[subdiagnostic]
676 pub sugg: InvalidUnionFieldSuggestion,
677 #[note]
678 pub note: (),
679}
680
681#[derive(Diagnostic)]
682#[diag(hir_analysis_return_type_notation_on_non_rpitit)]
683pub(crate) struct ReturnTypeNotationOnNonRpitit<'tcx> {
684 #[primary_span]
685 pub span: Span,
686 pub ty: Ty<'tcx>,
687 #[label]
688 pub fn_span: Option<Span>,
689 #[note]
690 pub note: (),
691}
692
693#[derive(Subdiagnostic)]
694#[multipart_suggestion(hir_analysis_invalid_union_field_sugg, applicability = "machine-applicable")]
695pub(crate) struct InvalidUnionFieldSuggestion {
696 #[suggestion_part(code = "std::mem::ManuallyDrop<")]
697 pub lo: Span,
698 #[suggestion_part(code = ">")]
699 pub hi: Span,
700}
701
702#[derive(Diagnostic)]
703#[diag(hir_analysis_return_type_notation_equality_bound)]
704pub(crate) struct ReturnTypeNotationEqualityBound {
705 #[primary_span]
706 pub span: Span,
707}
708
709#[derive(Diagnostic)]
710#[diag(hir_analysis_placeholder_not_allowed_item_signatures, code = E0121)]
711pub(crate) struct PlaceholderNotAllowedItemSignatures {
712 #[primary_span]
713 #[label]
714 pub spans: Vec<Span>,
715 pub kind: String,
716}
717
718#[derive(Diagnostic)]
719#[diag(hir_analysis_associated_type_trait_uninferred_generic_params, code = E0212)]
720pub(crate) struct AssociatedItemTraitUninferredGenericParams {
721 #[primary_span]
722 pub span: Span,
723 #[suggestion(style = "verbose", applicability = "maybe-incorrect", code = "{bound}")]
724 pub inferred_sugg: Option<Span>,
725 pub bound: String,
726 #[subdiagnostic]
727 pub mpart_sugg: Option<AssociatedItemTraitUninferredGenericParamsMultipartSuggestion>,
728 pub what: &'static str,
729}
730
731#[derive(Subdiagnostic)]
732#[multipart_suggestion(
733 hir_analysis_associated_type_trait_uninferred_generic_params_multipart_suggestion,
734 applicability = "maybe-incorrect"
735)]
736pub(crate) struct AssociatedItemTraitUninferredGenericParamsMultipartSuggestion {
737 #[suggestion_part(code = "{first}")]
738 pub fspan: Span,
739 pub first: String,
740 #[suggestion_part(code = "{second}")]
741 pub sspan: Span,
742 pub second: String,
743}
744
745#[derive(Diagnostic)]
746#[diag(hir_analysis_enum_discriminant_overflowed, code = E0370)]
747#[note]
748pub(crate) struct EnumDiscriminantOverflowed {
749 #[primary_span]
750 #[label]
751 pub span: Span,
752 pub discr: String,
753 pub item_name: Ident,
754 pub wrapped_discr: String,
755}
756
757#[derive(Diagnostic)]
758#[diag(hir_analysis_paren_sugar_attribute)]
759#[help]
760pub(crate) struct ParenSugarAttribute {
761 #[primary_span]
762 pub span: Span,
763}
764
765#[derive(Diagnostic)]
766#[diag(hir_analysis_must_implement_one_of_attribute)]
767pub(crate) struct MustImplementOneOfAttribute {
768 #[primary_span]
769 pub span: Span,
770}
771
772#[derive(Diagnostic)]
773#[diag(hir_analysis_must_be_name_of_associated_function)]
774pub(crate) struct MustBeNameOfAssociatedFunction {
775 #[primary_span]
776 pub span: Span,
777}
778
779#[derive(Diagnostic)]
780#[diag(hir_analysis_function_not_have_default_implementation)]
781pub(crate) struct FunctionNotHaveDefaultImplementation {
782 #[primary_span]
783 pub span: Span,
784 #[note]
785 pub note_span: Span,
786}
787
788#[derive(Diagnostic)]
789#[diag(hir_analysis_must_implement_not_function)]
790pub(crate) struct MustImplementNotFunction {
791 #[primary_span]
792 pub span: Span,
793 #[subdiagnostic]
794 pub span_note: MustImplementNotFunctionSpanNote,
795 #[subdiagnostic]
796 pub note: MustImplementNotFunctionNote,
797}
798
799#[derive(Subdiagnostic)]
800#[note(hir_analysis_must_implement_not_function_span_note)]
801pub(crate) struct MustImplementNotFunctionSpanNote {
802 #[primary_span]
803 pub span: Span,
804}
805
806#[derive(Subdiagnostic)]
807#[note(hir_analysis_must_implement_not_function_note)]
808pub(crate) struct MustImplementNotFunctionNote {}
809
810#[derive(Diagnostic)]
811#[diag(hir_analysis_function_not_found_in_trait)]
812pub(crate) struct FunctionNotFoundInTrait {
813 #[primary_span]
814 pub span: Span,
815}
816
817#[derive(Diagnostic)]
818#[diag(hir_analysis_functions_names_duplicated)]
819#[note]
820pub(crate) struct FunctionNamesDuplicated {
821 #[primary_span]
822 pub spans: Vec<Span>,
823}
824
825#[derive(Diagnostic)]
826#[diag(hir_analysis_simd_ffi_highly_experimental)]
827#[help]
828pub(crate) struct SIMDFFIHighlyExperimental {
829 #[primary_span]
830 pub span: Span,
831 pub snip: String,
832}
833
834#[derive(Diagnostic)]
835pub(crate) enum ImplNotMarkedDefault {
836 #[diag(hir_analysis_impl_not_marked_default, code = E0520)]
837 #[note]
838 Ok {
839 #[primary_span]
840 #[label]
841 span: Span,
842 #[label(hir_analysis_ok_label)]
843 ok_label: Span,
844 ident: Ident,
845 },
846 #[diag(hir_analysis_impl_not_marked_default_err, code = E0520)]
847 #[note]
848 Err {
849 #[primary_span]
850 span: Span,
851 cname: Symbol,
852 ident: Ident,
853 },
854}
855
856#[derive(LintDiagnostic)]
857#[diag(hir_analysis_useless_impl_item)]
858pub(crate) struct UselessImplItem;
859
860#[derive(Diagnostic)]
861#[diag(hir_analysis_missing_trait_item, code = E0046)]
862pub(crate) struct MissingTraitItem {
863 #[primary_span]
864 #[label]
865 pub span: Span,
866 #[subdiagnostic]
867 pub missing_trait_item_label: Vec<MissingTraitItemLabel>,
868 #[subdiagnostic]
869 pub missing_trait_item: Vec<MissingTraitItemSuggestion>,
870 #[subdiagnostic]
871 pub missing_trait_item_none: Vec<MissingTraitItemSuggestionNone>,
872 pub missing_items_msg: String,
873}
874
875#[derive(Subdiagnostic)]
876#[label(hir_analysis_missing_trait_item_label)]
877pub(crate) struct MissingTraitItemLabel {
878 #[primary_span]
879 pub span: Span,
880 pub item: Symbol,
881}
882
883#[derive(Subdiagnostic)]
884#[suggestion(
885 hir_analysis_missing_trait_item_suggestion,
886 style = "tool-only",
887 applicability = "has-placeholders",
888 code = "{code}"
889)]
890pub(crate) struct MissingTraitItemSuggestion {
891 #[primary_span]
892 pub span: Span,
893 pub code: String,
894 pub snippet: String,
895}
896
897#[derive(Subdiagnostic)]
898#[suggestion(
899 hir_analysis_missing_trait_item_suggestion,
900 style = "hidden",
901 applicability = "has-placeholders",
902 code = "{code}"
903)]
904pub(crate) struct MissingTraitItemSuggestionNone {
905 #[primary_span]
906 pub span: Span,
907 pub code: String,
908 pub snippet: String,
909}
910
911#[derive(Diagnostic)]
912#[diag(hir_analysis_missing_one_of_trait_item, code = E0046)]
913pub(crate) struct MissingOneOfTraitItem {
914 #[primary_span]
915 #[label]
916 pub span: Span,
917 #[note]
918 pub note: Option<Span>,
919 pub missing_items_msg: String,
920}
921
922#[derive(Diagnostic)]
923#[diag(hir_analysis_missing_trait_item_unstable, code = E0046)]
924#[note]
925pub(crate) struct MissingTraitItemUnstable {
926 #[primary_span]
927 pub span: Span,
928 #[note(hir_analysis_some_note)]
929 pub some_note: bool,
930 #[note(hir_analysis_none_note)]
931 pub none_note: bool,
932 pub missing_item_name: Ident,
933 pub feature: Symbol,
934 pub reason: String,
935}
936
937#[derive(Diagnostic)]
938#[diag(hir_analysis_transparent_enum_variant, code = E0731)]
939pub(crate) struct TransparentEnumVariant {
940 #[primary_span]
941 #[label]
942 pub span: Span,
943 #[label(hir_analysis_multi_label)]
944 pub spans: Vec<Span>,
945 #[label(hir_analysis_many_label)]
946 pub many: Option<Span>,
947 pub number: usize,
948 pub path: String,
949}
950
951#[derive(Diagnostic)]
952#[diag(hir_analysis_transparent_non_zero_sized_enum, code = E0690)]
953pub(crate) struct TransparentNonZeroSizedEnum<'a> {
954 #[primary_span]
955 #[label]
956 pub span: Span,
957 #[label(hir_analysis_labels)]
958 pub spans: Vec<Span>,
959 pub field_count: usize,
960 pub desc: &'a str,
961}
962
963#[derive(Diagnostic)]
964#[diag(hir_analysis_transparent_non_zero_sized, code = E0690)]
965pub(crate) struct TransparentNonZeroSized<'a> {
966 #[primary_span]
967 #[label]
968 pub span: Span,
969 #[label(hir_analysis_labels)]
970 pub spans: Vec<Span>,
971 pub field_count: usize,
972 pub desc: &'a str,
973}
974
975#[derive(Diagnostic)]
976#[diag(hir_analysis_too_large_static)]
977pub(crate) struct TooLargeStatic {
978 #[primary_span]
979 pub span: Span,
980}
981
982#[derive(Diagnostic)]
983#[diag(hir_analysis_specialization_trait)]
984#[help]
985pub(crate) struct SpecializationTrait {
986 #[primary_span]
987 pub span: Span,
988}
989
990#[derive(Diagnostic)]
991#[diag(hir_analysis_closure_implicit_hrtb)]
992pub(crate) struct ClosureImplicitHrtb {
993 #[primary_span]
994 pub spans: Vec<Span>,
995 #[label]
996 pub for_sp: Span,
997}
998
999#[derive(Diagnostic)]
1000#[diag(hir_analysis_empty_specialization)]
1001pub(crate) struct EmptySpecialization {
1002 #[primary_span]
1003 pub span: Span,
1004 #[note]
1005 pub base_impl_span: Span,
1006}
1007
1008#[derive(Diagnostic)]
1009#[diag(hir_analysis_static_specialize)]
1010pub(crate) struct StaticSpecialize {
1011 #[primary_span]
1012 pub span: Span,
1013}
1014
1015#[derive(Diagnostic)]
1016pub(crate) enum DropImplPolarity {
1017 #[diag(hir_analysis_drop_impl_negative)]
1018 Negative {
1019 #[primary_span]
1020 span: Span,
1021 },
1022 #[diag(hir_analysis_drop_impl_reservation)]
1023 Reservation {
1024 #[primary_span]
1025 span: Span,
1026 },
1027}
1028
1029#[derive(Diagnostic)]
1030pub(crate) enum ReturnTypeNotationIllegalParam {
1031 #[diag(hir_analysis_return_type_notation_illegal_param_type)]
1032 Type {
1033 #[primary_span]
1034 span: Span,
1035 #[label]
1036 param_span: Span,
1037 },
1038 #[diag(hir_analysis_return_type_notation_illegal_param_const)]
1039 Const {
1040 #[primary_span]
1041 span: Span,
1042 #[label]
1043 param_span: Span,
1044 },
1045}
1046
1047#[derive(Diagnostic)]
1048pub(crate) enum LateBoundInApit {
1049 #[diag(hir_analysis_late_bound_type_in_apit)]
1050 Type {
1051 #[primary_span]
1052 span: Span,
1053 #[label]
1054 param_span: Span,
1055 },
1056 #[diag(hir_analysis_late_bound_const_in_apit)]
1057 Const {
1058 #[primary_span]
1059 span: Span,
1060 #[label]
1061 param_span: Span,
1062 },
1063 #[diag(hir_analysis_late_bound_lifetime_in_apit)]
1064 Lifetime {
1065 #[primary_span]
1066 span: Span,
1067 #[label]
1068 param_span: Span,
1069 },
1070}
1071
1072#[derive(LintDiagnostic)]
1073#[diag(hir_analysis_unused_associated_type_bounds)]
1074#[note]
1075pub(crate) struct UnusedAssociatedTypeBounds {
1076 #[suggestion(code = "")]
1077 pub span: Span,
1078}
1079
1080#[derive(LintDiagnostic)]
1081#[diag(hir_analysis_rpitit_refined)]
1082#[note]
1083#[note(hir_analysis_feedback_note)]
1084pub(crate) struct ReturnPositionImplTraitInTraitRefined<'tcx> {
1085 #[suggestion(applicability = "maybe-incorrect", code = "{pre}{return_ty}{post}")]
1086 pub impl_return_span: Span,
1087 #[label]
1088 pub trait_return_span: Option<Span>,
1089 #[label(hir_analysis_unmatched_bound_label)]
1090 pub unmatched_bound: Option<Span>,
1091
1092 pub pre: &'static str,
1093 pub post: &'static str,
1094 pub return_ty: Ty<'tcx>,
1095}
1096
1097#[derive(LintDiagnostic)]
1098#[diag(hir_analysis_rpitit_refined_lifetimes)]
1099#[note]
1100#[note(hir_analysis_feedback_note)]
1101pub(crate) struct ReturnPositionImplTraitInTraitRefinedLifetimes {
1102 #[suggestion(applicability = "maybe-incorrect", code = "{suggestion}")]
1103 pub suggestion_span: Span,
1104 pub suggestion: String,
1105}
1106
1107#[derive(Diagnostic)]
1108#[diag(hir_analysis_inherent_ty_outside, code = E0390)]
1109#[help]
1110pub(crate) struct InherentTyOutside {
1111 #[primary_span]
1112 #[help(hir_analysis_span_help)]
1113 pub span: Span,
1114}
1115
1116#[derive(Diagnostic)]
1117#[diag(hir_analysis_dispatch_from_dyn_repr, code = E0378)]
1118pub(crate) struct DispatchFromDynRepr {
1119 #[primary_span]
1120 pub span: Span,
1121}
1122
1123#[derive(Diagnostic)]
1124#[diag(hir_analysis_coerce_pointee_not_struct, code = E0802)]
1125pub(crate) struct CoercePointeeNotStruct {
1126 #[primary_span]
1127 pub span: Span,
1128 pub kind: String,
1129}
1130
1131#[derive(Diagnostic)]
1132#[diag(hir_analysis_coerce_pointee_not_concrete_ty, code = E0802)]
1133pub(crate) struct CoercePointeeNotConcreteType {
1134 #[primary_span]
1135 pub span: Span,
1136}
1137
1138#[derive(Diagnostic)]
1139#[diag(hir_analysis_coerce_pointee_no_user_validity_assertion, code = E0802)]
1140pub(crate) struct CoercePointeeNoUserValidityAssertion {
1141 #[primary_span]
1142 pub span: Span,
1143}
1144
1145#[derive(Diagnostic)]
1146#[diag(hir_analysis_coerce_pointee_not_transparent, code = E0802)]
1147pub(crate) struct CoercePointeeNotTransparent {
1148 #[primary_span]
1149 pub span: Span,
1150}
1151
1152#[derive(Diagnostic)]
1153#[diag(hir_analysis_coerce_pointee_no_field, code = E0802)]
1154pub(crate) struct CoercePointeeNoField {
1155 #[primary_span]
1156 pub span: Span,
1157}
1158
1159#[derive(Diagnostic)]
1160#[diag(hir_analysis_inherent_ty_outside_relevant, code = E0390)]
1161#[help]
1162pub(crate) struct InherentTyOutsideRelevant {
1163 #[primary_span]
1164 pub span: Span,
1165 #[help(hir_analysis_span_help)]
1166 pub help_span: Span,
1167}
1168
1169#[derive(Diagnostic)]
1170#[diag(hir_analysis_inherent_ty_outside_new, code = E0116)]
1171#[note]
1172pub(crate) struct InherentTyOutsideNew {
1173 #[primary_span]
1174 #[label]
1175 pub span: Span,
1176}
1177
1178#[derive(Diagnostic)]
1179#[diag(hir_analysis_inherent_ty_outside_primitive, code = E0390)]
1180#[help]
1181pub(crate) struct InherentTyOutsidePrimitive {
1182 #[primary_span]
1183 pub span: Span,
1184 #[help(hir_analysis_span_help)]
1185 pub help_span: Span,
1186}
1187
1188#[derive(Diagnostic)]
1189#[diag(hir_analysis_inherent_primitive_ty, code = E0390)]
1190#[help]
1191pub(crate) struct InherentPrimitiveTy<'a> {
1192 #[primary_span]
1193 pub span: Span,
1194 #[subdiagnostic]
1195 pub note: Option<InherentPrimitiveTyNote<'a>>,
1196}
1197
1198#[derive(Subdiagnostic)]
1199#[note(hir_analysis_inherent_primitive_ty_note)]
1200pub(crate) struct InherentPrimitiveTyNote<'a> {
1201 pub subty: Ty<'a>,
1202}
1203
1204#[derive(Diagnostic)]
1205#[diag(hir_analysis_inherent_dyn, code = E0785)]
1206#[note]
1207pub(crate) struct InherentDyn {
1208 #[primary_span]
1209 #[label]
1210 pub span: Span,
1211}
1212
1213#[derive(Diagnostic)]
1214#[diag(hir_analysis_inherent_nominal, code = E0118)]
1215#[note]
1216pub(crate) struct InherentNominal {
1217 #[primary_span]
1218 #[label]
1219 pub span: Span,
1220}
1221
1222#[derive(Diagnostic)]
1223#[diag(hir_analysis_dispatch_from_dyn_zst, code = E0378)]
1224#[note]
1225pub(crate) struct DispatchFromDynZST<'a> {
1226 #[primary_span]
1227 pub span: Span,
1228 pub name: Ident,
1229 pub ty: Ty<'a>,
1230}
1231
1232#[derive(Diagnostic)]
1233#[diag(hir_analysis_coerce_zero, code = E0374)]
1234pub(crate) struct CoerceNoField {
1235 #[primary_span]
1236 pub span: Span,
1237 pub trait_name: &'static str,
1238 #[note(hir_analysis_coercion_between_struct_single_note)]
1239 pub note: bool,
1240}
1241
1242#[derive(Diagnostic)]
1243#[diag(hir_analysis_coerce_multi, code = E0375)]
1244pub(crate) struct CoerceMulti {
1245 pub trait_name: &'static str,
1246 #[primary_span]
1247 pub span: Span,
1248 pub number: usize,
1249 #[note]
1250 pub fields: MultiSpan,
1251}
1252
1253#[derive(Diagnostic)]
1254#[diag(hir_analysis_coerce_unsized_may, code = E0377)]
1255pub(crate) struct CoerceUnsizedNonStruct {
1256 #[primary_span]
1257 pub span: Span,
1258 pub trait_name: &'static str,
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 span: Span,
1620 pub plural: bool,
1621 pub abi: ExternAbi,
1622}
1623
1624#[derive(Diagnostic)]
1625#[diag(hir_analysis_cmse_output_stack_spill, code = E0798)]
1626#[note(hir_analysis_note1)]
1627#[note(hir_analysis_note2)]
1628pub(crate) struct CmseOutputStackSpill {
1629 #[primary_span]
1630 #[label]
1631 pub span: Span,
1632 pub abi: ExternAbi,
1633}
1634
1635#[derive(Diagnostic)]
1636#[diag(hir_analysis_cmse_call_generic, code = E0798)]
1637pub(crate) struct CmseCallGeneric {
1638 #[primary_span]
1639 pub span: Span,
1640}
1641
1642#[derive(Diagnostic)]
1643#[diag(hir_analysis_bad_return_type_notation_position)]
1644pub(crate) struct BadReturnTypeNotation {
1645 #[primary_span]
1646 pub span: Span,
1647}
1648
1649#[derive(Diagnostic)]
1650#[diag(hir_analysis_cmse_entry_generic, code = E0798)]
1651pub(crate) struct CmseEntryGeneric {
1652 #[primary_span]
1653 pub span: Span,
1654}
1655
1656#[derive(LintDiagnostic)]
1657#[diag(hir_analysis_supertrait_item_shadowing)]
1658pub(crate) struct SupertraitItemShadowing {
1659 pub item: Symbol,
1660 pub subtrait: Symbol,
1661 #[subdiagnostic]
1662 pub shadowee: SupertraitItemShadowee,
1663}
1664
1665#[derive(Subdiagnostic)]
1666pub(crate) enum SupertraitItemShadowee {
1667 #[note(hir_analysis_supertrait_item_shadowee)]
1668 Labeled {
1669 #[primary_span]
1670 span: Span,
1671 supertrait: Symbol,
1672 },
1673 #[note(hir_analysis_supertrait_item_multiple_shadowee)]
1674 Several {
1675 #[primary_span]
1676 spans: MultiSpan,
1677 traits: DiagSymbolList,
1678 },
1679}
1680
1681#[derive(Diagnostic)]
1682#[diag(hir_analysis_self_in_type_alias, code = E0411)]
1683pub(crate) struct SelfInTypeAlias {
1684 #[primary_span]
1685 #[label]
1686 pub span: Span,
1687}
1688
1689#[derive(Diagnostic)]
1690#[diag(hir_analysis_abi_custom_clothed_function)]
1691pub(crate) struct AbiCustomClothedFunction {
1692 #[primary_span]
1693 pub span: Span,
1694 #[suggestion(
1695 hir_analysis_suggestion,
1696 applicability = "maybe-incorrect",
1697 code = "#[unsafe(naked)]\n",
1698 style = "short"
1699 )]
1700 pub naked_span: Span,
1701}
1702
1703#[derive(Diagnostic)]
1704#[diag(hir_analysis_async_drop_without_sync_drop)]
1705#[help]
1706pub(crate) struct AsyncDropWithoutSyncDrop {
1707 #[primary_span]
1708 pub span: Span,
1709}