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