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