1 //! Errors emitted by `rustc_hir_analysis`. 2 3 use crate::fluent_generated as fluent; 4 use rustc_errors::{ 5 error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic, 6 MultiSpan, 7 }; 8 use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; 9 use rustc_middle::ty::{self, print::TraitRefPrintOnlyTraitPath, Ty}; 10 use rustc_span::{symbol::Ident, Span, Symbol}; 11 12 #[derive(Diagnostic)] 13 #[diag(hir_analysis_unrecognized_atomic_operation, code = "E0092")] 14 pub struct UnrecognizedAtomicOperation<'a> { 15 #[primary_span] 16 #[label] 17 pub span: Span, 18 pub op: &'a str, 19 } 20 21 #[derive(Diagnostic)] 22 #[diag(hir_analysis_wrong_number_of_generic_arguments_to_intrinsic, code = "E0094")] 23 pub struct WrongNumberOfGenericArgumentsToIntrinsic<'a> { 24 #[primary_span] 25 #[label] 26 pub span: Span, 27 pub found: usize, 28 pub expected: usize, 29 pub descr: &'a str, 30 } 31 32 #[derive(Diagnostic)] 33 #[diag(hir_analysis_unrecognized_intrinsic_function, code = "E0093")] 34 pub struct UnrecognizedIntrinsicFunction { 35 #[primary_span] 36 #[label] 37 pub span: Span, 38 pub name: Symbol, 39 } 40 41 #[derive(Diagnostic)] 42 #[diag(hir_analysis_lifetimes_or_bounds_mismatch_on_trait, code = "E0195")] 43 pub struct LifetimesOrBoundsMismatchOnTrait { 44 #[primary_span] 45 #[label] 46 pub span: Span, 47 #[label(hir_analysis_generics_label)] 48 pub generics_span: Option<Span>, 49 #[label(hir_analysis_where_label)] 50 pub where_span: Option<Span>, 51 #[label(hir_analysis_bounds_label)] 52 pub bounds_span: Vec<Span>, 53 pub item_kind: &'static str, 54 pub ident: Ident, 55 } 56 57 #[derive(Diagnostic)] 58 #[diag(hir_analysis_async_trait_impl_should_be_async)] 59 pub struct AsyncTraitImplShouldBeAsync { 60 #[primary_span] 61 // #[label] 62 pub span: Span, 63 #[label(hir_analysis_trait_item_label)] 64 pub trait_item_span: Option<Span>, 65 pub method_name: Symbol, 66 } 67 68 #[derive(Diagnostic)] 69 #[diag(hir_analysis_drop_impl_on_wrong_item, code = "E0120")] 70 pub struct DropImplOnWrongItem { 71 #[primary_span] 72 #[label] 73 pub span: Span, 74 } 75 76 #[derive(Diagnostic)] 77 #[diag(hir_analysis_field_already_declared, code = "E0124")] 78 pub struct FieldAlreadyDeclared { 79 pub field_name: Ident, 80 #[primary_span] 81 #[label] 82 pub span: Span, 83 #[label(hir_analysis_previous_decl_label)] 84 pub prev_span: Span, 85 } 86 87 #[derive(Diagnostic)] 88 #[diag(hir_analysis_copy_impl_on_type_with_dtor, code = "E0184")] 89 pub struct CopyImplOnTypeWithDtor { 90 #[primary_span] 91 #[label] 92 pub span: Span, 93 } 94 95 #[derive(Diagnostic)] 96 #[diag(hir_analysis_multiple_relaxed_default_bounds, code = "E0203")] 97 pub struct MultipleRelaxedDefaultBounds { 98 #[primary_span] 99 pub span: Span, 100 } 101 102 #[derive(Diagnostic)] 103 #[diag(hir_analysis_copy_impl_on_non_adt, code = "E0206")] 104 pub struct CopyImplOnNonAdt { 105 #[primary_span] 106 #[label] 107 pub span: Span, 108 } 109 110 #[derive(Diagnostic)] 111 #[diag(hir_analysis_const_param_ty_impl_on_non_adt)] 112 pub struct ConstParamTyImplOnNonAdt { 113 #[primary_span] 114 #[label] 115 pub span: Span, 116 } 117 118 #[derive(Diagnostic)] 119 #[diag(hir_analysis_trait_object_declared_with_no_traits, code = "E0224")] 120 pub struct TraitObjectDeclaredWithNoTraits { 121 #[primary_span] 122 pub span: Span, 123 #[label(hir_analysis_alias_span)] 124 pub trait_alias_span: Option<Span>, 125 } 126 127 #[derive(Diagnostic)] 128 #[diag(hir_analysis_ambiguous_lifetime_bound, code = "E0227")] 129 pub struct AmbiguousLifetimeBound { 130 #[primary_span] 131 pub span: Span, 132 } 133 134 #[derive(Diagnostic)] 135 #[diag(hir_analysis_assoc_type_binding_not_allowed, code = "E0229")] 136 pub struct AssocTypeBindingNotAllowed { 137 #[primary_span] 138 #[label] 139 pub span: Span, 140 141 #[subdiagnostic] 142 pub fn_trait_expansion: Option<ParenthesizedFnTraitExpansion>, 143 } 144 145 #[derive(Subdiagnostic)] 146 #[help(hir_analysis_parenthesized_fn_trait_expansion)] 147 pub struct ParenthesizedFnTraitExpansion { 148 #[primary_span] 149 pub span: Span, 150 151 pub expanded_type: String, 152 } 153 154 #[derive(Diagnostic)] 155 #[diag(hir_analysis_typeof_reserved_keyword_used, code = "E0516")] 156 pub struct TypeofReservedKeywordUsed<'tcx> { 157 pub ty: Ty<'tcx>, 158 #[primary_span] 159 #[label] 160 pub span: Span, 161 #[suggestion(style = "verbose", code = "{ty}")] 162 pub opt_sugg: Option<(Span, Applicability)>, 163 } 164 165 #[derive(Diagnostic)] 166 #[diag(hir_analysis_value_of_associated_struct_already_specified, code = "E0719")] 167 pub struct ValueOfAssociatedStructAlreadySpecified { 168 #[primary_span] 169 #[label] 170 pub span: Span, 171 #[label(hir_analysis_previous_bound_label)] 172 pub prev_span: Span, 173 pub item_name: Ident, 174 pub def_path: String, 175 } 176 177 #[derive(Diagnostic)] 178 #[diag(hir_analysis_unconstrained_opaque_type)] 179 #[note] 180 pub struct UnconstrainedOpaqueType { 181 #[primary_span] 182 pub span: Span, 183 pub name: Symbol, 184 pub what: &'static str, 185 } 186 187 #[derive(Diagnostic)] 188 #[diag(hir_analysis_tait_forward_compat)] 189 #[note] 190 pub struct TaitForwardCompat { 191 #[primary_span] 192 pub span: Span, 193 #[note] 194 pub item_span: Span, 195 } 196 197 pub struct MissingTypeParams { 198 pub span: Span, 199 pub def_span: Span, 200 pub span_snippet: Option<String>, 201 pub missing_type_params: Vec<Symbol>, 202 pub empty_generic_args: bool, 203 } 204 205 // Manual implementation of `IntoDiagnostic` to be able to call `span_to_snippet`. 206 impl<'a> IntoDiagnostic<'a> for MissingTypeParams { 207 #[track_caller] into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed>208 fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> { 209 let mut err = handler.struct_span_err_with_code( 210 self.span, 211 fluent::hir_analysis_missing_type_params, 212 error_code!(E0393), 213 ); 214 err.set_arg("parameterCount", self.missing_type_params.len()); 215 err.set_arg( 216 "parameters", 217 self.missing_type_params 218 .iter() 219 .map(|n| format!("`{}`", n)) 220 .collect::<Vec<_>>() 221 .join(", "), 222 ); 223 224 err.span_label(self.def_span, fluent::hir_analysis_label); 225 226 let mut suggested = false; 227 // Don't suggest setting the type params if there are some already: the order is 228 // tricky to get right and the user will already know what the syntax is. 229 if let Some(snippet) = self.span_snippet && self.empty_generic_args { 230 if snippet.ends_with('>') { 231 // The user wrote `Trait<'a, T>` or similar. To provide an accurate suggestion 232 // we would have to preserve the right order. For now, as clearly the user is 233 // aware of the syntax, we do nothing. 234 } else { 235 // The user wrote `Iterator`, so we don't have a type we can suggest, but at 236 // least we can clue them to the correct syntax `Iterator<Type>`. 237 err.span_suggestion( 238 self.span, 239 fluent::hir_analysis_suggestion, 240 format!( 241 "{}<{}>", 242 snippet, 243 self.missing_type_params 244 .iter() 245 .map(|n| n.to_string()) 246 .collect::<Vec<_>>() 247 .join(", ") 248 ), 249 Applicability::HasPlaceholders, 250 ); 251 suggested = true; 252 } 253 } 254 if !suggested { 255 err.span_label(self.span, fluent::hir_analysis_no_suggestion_label); 256 } 257 258 err.note(fluent::hir_analysis_note); 259 err 260 } 261 } 262 263 #[derive(Diagnostic)] 264 #[diag(hir_analysis_manual_implementation, code = "E0183")] 265 #[help] 266 pub struct ManualImplementation { 267 #[primary_span] 268 #[label] 269 pub span: Span, 270 pub trait_name: String, 271 } 272 273 #[derive(Diagnostic)] 274 #[diag(hir_analysis_substs_on_overridden_impl)] 275 pub struct SubstsOnOverriddenImpl { 276 #[primary_span] 277 pub span: Span, 278 } 279 280 #[derive(Diagnostic)] 281 #[diag(hir_analysis_const_impl_for_non_const_trait)] 282 pub struct ConstImplForNonConstTrait { 283 #[primary_span] 284 pub trait_ref_span: Span, 285 pub trait_name: String, 286 #[suggestion(applicability = "machine-applicable", code = "#[const_trait]")] 287 pub local_trait_span: Option<Span>, 288 #[note] 289 pub marking: (), 290 #[note(hir_analysis_adding)] 291 pub adding: (), 292 } 293 294 #[derive(Diagnostic)] 295 #[diag(hir_analysis_const_bound_for_non_const_trait)] 296 pub struct ConstBoundForNonConstTrait { 297 #[primary_span] 298 pub span: Span, 299 } 300 301 #[derive(Diagnostic)] 302 #[diag(hir_analysis_self_in_impl_self)] 303 pub struct SelfInImplSelf { 304 #[primary_span] 305 pub span: MultiSpan, 306 #[note] 307 pub note: (), 308 } 309 310 #[derive(Diagnostic)] 311 #[diag(hir_analysis_linkage_type, code = "E0791")] 312 pub(crate) struct LinkageType { 313 #[primary_span] 314 pub span: Span, 315 } 316 317 #[derive(Diagnostic)] 318 #[help] 319 #[diag(hir_analysis_auto_deref_reached_recursion_limit, code = "E0055")] 320 pub struct AutoDerefReachedRecursionLimit<'a> { 321 #[primary_span] 322 #[label] 323 pub span: Span, 324 pub ty: Ty<'a>, 325 pub suggested_limit: rustc_session::Limit, 326 pub crate_name: Symbol, 327 } 328 329 #[derive(Diagnostic)] 330 #[diag(hir_analysis_where_clause_on_main, code = "E0646")] 331 pub(crate) struct WhereClauseOnMain { 332 #[primary_span] 333 pub span: Span, 334 #[label] 335 pub generics_span: Option<Span>, 336 } 337 338 #[derive(Diagnostic)] 339 #[diag(hir_analysis_track_caller_on_main)] 340 pub(crate) struct TrackCallerOnMain { 341 #[primary_span] 342 #[suggestion(applicability = "maybe-incorrect", code = "")] 343 pub span: Span, 344 #[label(hir_analysis_track_caller_on_main)] 345 pub annotated: Span, 346 } 347 348 #[derive(Diagnostic)] 349 #[diag(hir_analysis_target_feature_on_main)] 350 pub(crate) struct TargetFeatureOnMain { 351 #[primary_span] 352 #[label(hir_analysis_target_feature_on_main)] 353 pub main: Span, 354 } 355 356 #[derive(Diagnostic)] 357 #[diag(hir_analysis_start_not_track_caller)] 358 pub(crate) struct StartTrackCaller { 359 #[primary_span] 360 pub span: Span, 361 #[label] 362 pub start: Span, 363 } 364 365 #[derive(Diagnostic)] 366 #[diag(hir_analysis_start_not_target_feature)] 367 pub(crate) struct StartTargetFeature { 368 #[primary_span] 369 pub span: Span, 370 #[label] 371 pub start: Span, 372 } 373 374 #[derive(Diagnostic)] 375 #[diag(hir_analysis_start_not_async, code = "E0752")] 376 pub(crate) struct StartAsync { 377 #[primary_span] 378 #[label] 379 pub span: Span, 380 } 381 382 #[derive(Diagnostic)] 383 #[diag(hir_analysis_start_function_where, code = "E0647")] 384 pub(crate) struct StartFunctionWhere { 385 #[primary_span] 386 #[label] 387 pub span: Span, 388 } 389 390 #[derive(Diagnostic)] 391 #[diag(hir_analysis_start_function_parameters, code = "E0132")] 392 pub(crate) struct StartFunctionParameters { 393 #[primary_span] 394 #[label] 395 pub span: Span, 396 } 397 398 #[derive(Diagnostic)] 399 #[diag(hir_analysis_main_function_return_type_generic, code = "E0131")] 400 pub(crate) struct MainFunctionReturnTypeGeneric { 401 #[primary_span] 402 pub span: Span, 403 } 404 405 #[derive(Diagnostic)] 406 #[diag(hir_analysis_main_function_async, code = "E0752")] 407 pub(crate) struct MainFunctionAsync { 408 #[primary_span] 409 pub span: Span, 410 #[label] 411 pub asyncness: Option<Span>, 412 } 413 414 #[derive(Diagnostic)] 415 #[diag(hir_analysis_main_function_generic_parameters, code = "E0131")] 416 pub(crate) struct MainFunctionGenericParameters { 417 #[primary_span] 418 pub span: Span, 419 #[label] 420 pub label_span: Option<Span>, 421 } 422 423 #[derive(Diagnostic)] 424 #[diag(hir_analysis_variadic_function_compatible_convention, code = "E0045")] 425 pub(crate) struct VariadicFunctionCompatibleConvention<'a> { 426 #[primary_span] 427 #[label] 428 pub span: Span, 429 pub conventions: &'a str, 430 } 431 432 #[derive(Diagnostic)] 433 pub(crate) enum CannotCaptureLateBoundInAnonConst { 434 #[diag(hir_analysis_cannot_capture_late_bound_ty_in_anon_const)] 435 Type { 436 #[primary_span] 437 use_span: Span, 438 #[label] 439 def_span: Span, 440 }, 441 #[diag(hir_analysis_cannot_capture_late_bound_const_in_anon_const)] 442 Const { 443 #[primary_span] 444 use_span: Span, 445 #[label] 446 def_span: Span, 447 }, 448 } 449 450 #[derive(Diagnostic)] 451 #[diag(hir_analysis_variances_of)] 452 pub(crate) struct VariancesOf { 453 #[primary_span] 454 pub span: Span, 455 pub variances_of: String, 456 } 457 458 #[derive(Diagnostic)] 459 #[diag(hir_analysis_pass_to_variadic_function, code = "E0617")] 460 pub(crate) struct PassToVariadicFunction<'tcx, 'a> { 461 #[primary_span] 462 pub span: Span, 463 pub ty: Ty<'tcx>, 464 pub cast_ty: &'a str, 465 #[suggestion(code = "{replace}", applicability = "machine-applicable")] 466 pub sugg_span: Option<Span>, 467 pub replace: String, 468 #[help] 469 pub help: Option<()>, 470 } 471 472 #[derive(Diagnostic)] 473 #[diag(hir_analysis_cast_thin_pointer_to_fat_pointer, code = "E0607")] 474 pub(crate) struct CastThinPointerToFatPointer<'tcx> { 475 #[primary_span] 476 pub span: Span, 477 pub expr_ty: Ty<'tcx>, 478 pub cast_ty: String, 479 } 480 481 #[derive(Diagnostic)] 482 #[diag(hir_analysis_invalid_union_field, code = "E0740")] 483 pub(crate) struct InvalidUnionField { 484 #[primary_span] 485 pub field_span: Span, 486 #[subdiagnostic] 487 pub sugg: InvalidUnionFieldSuggestion, 488 #[note] 489 pub note: (), 490 } 491 492 #[derive(Diagnostic)] 493 #[diag(hir_analysis_return_type_notation_on_non_rpitit)] 494 pub(crate) struct ReturnTypeNotationOnNonRpitit<'tcx> { 495 #[primary_span] 496 pub span: Span, 497 pub ty: Ty<'tcx>, 498 #[label] 499 pub fn_span: Option<Span>, 500 #[note] 501 pub note: (), 502 } 503 504 #[derive(Subdiagnostic)] 505 #[multipart_suggestion(hir_analysis_invalid_union_field_sugg, applicability = "machine-applicable")] 506 pub(crate) struct InvalidUnionFieldSuggestion { 507 #[suggestion_part(code = "std::mem::ManuallyDrop<")] 508 pub lo: Span, 509 #[suggestion_part(code = ">")] 510 pub hi: Span, 511 } 512 513 #[derive(Diagnostic)] 514 #[diag(hir_analysis_return_type_notation_equality_bound)] 515 pub(crate) struct ReturnTypeNotationEqualityBound { 516 #[primary_span] 517 pub span: Span, 518 } 519 520 #[derive(Diagnostic)] 521 #[diag(hir_analysis_return_type_notation_missing_method)] 522 pub(crate) struct ReturnTypeNotationMissingMethod { 523 #[primary_span] 524 pub span: Span, 525 pub ty_name: String, 526 pub assoc_name: Symbol, 527 } 528 529 #[derive(Diagnostic)] 530 #[diag(hir_analysis_return_type_notation_conflicting_bound)] 531 #[note] 532 pub(crate) struct ReturnTypeNotationConflictingBound<'tcx> { 533 #[primary_span] 534 pub span: Span, 535 pub ty_name: String, 536 pub assoc_name: Symbol, 537 pub first_bound: ty::Binder<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>, 538 pub second_bound: ty::Binder<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>, 539 } 540 541 #[derive(Diagnostic)] 542 #[diag(hir_analysis_placeholder_not_allowed_item_signatures, code = "E0121")] 543 pub(crate) struct PlaceholderNotAllowedItemSignatures { 544 #[primary_span] 545 #[label] 546 pub spans: Vec<Span>, 547 pub kind: String, 548 } 549 550 #[derive(Diagnostic)] 551 #[diag(hir_analysis_associated_type_trait_uninferred_generic_params, code = "E0212")] 552 pub(crate) struct AssociatedTypeTraitUninferredGenericParams { 553 #[primary_span] 554 pub span: Span, 555 #[suggestion(style = "verbose", applicability = "maybe-incorrect", code = "{bound}")] 556 pub inferred_sugg: Option<Span>, 557 pub bound: String, 558 #[subdiagnostic] 559 pub mpart_sugg: Option<AssociatedTypeTraitUninferredGenericParamsMultipartSuggestion>, 560 } 561 562 #[derive(Subdiagnostic)] 563 #[multipart_suggestion( 564 hir_analysis_associated_type_trait_uninferred_generic_params_multipart_suggestion, 565 applicability = "maybe-incorrect" 566 )] 567 pub(crate) struct AssociatedTypeTraitUninferredGenericParamsMultipartSuggestion { 568 #[suggestion_part(code = "{first}")] 569 pub fspan: Span, 570 pub first: String, 571 #[suggestion_part(code = "{second}")] 572 pub sspan: Span, 573 pub second: String, 574 } 575 576 #[derive(Diagnostic)] 577 #[diag(hir_analysis_enum_discriminant_overflowed, code = "E0370")] 578 #[note] 579 pub(crate) struct EnumDiscriminantOverflowed { 580 #[primary_span] 581 #[label] 582 pub span: Span, 583 pub discr: String, 584 pub item_name: Symbol, 585 pub wrapped_discr: String, 586 } 587 588 #[derive(Diagnostic)] 589 #[diag(hir_analysis_paren_sugar_attribute)] 590 #[help] 591 pub(crate) struct ParenSugarAttribute { 592 #[primary_span] 593 pub span: Span, 594 } 595 596 #[derive(Diagnostic)] 597 #[diag(hir_analysis_must_implement_one_of_attribute)] 598 pub(crate) struct MustImplementOneOfAttribute { 599 #[primary_span] 600 pub span: Span, 601 } 602 603 #[derive(Diagnostic)] 604 #[diag(hir_analysis_must_be_name_of_associated_function)] 605 pub(crate) struct MustBeNameOfAssociatedFunction { 606 #[primary_span] 607 pub span: Span, 608 } 609 610 #[derive(Diagnostic)] 611 #[diag(hir_analysis_function_not_have_default_implementation)] 612 pub(crate) struct FunctionNotHaveDefaultImplementation { 613 #[primary_span] 614 pub span: Span, 615 #[note] 616 pub note_span: Span, 617 } 618 619 #[derive(Diagnostic)] 620 #[diag(hir_analysis_must_implement_not_function)] 621 pub(crate) struct MustImplementNotFunction { 622 #[primary_span] 623 pub span: Span, 624 #[subdiagnostic] 625 pub span_note: MustImplementNotFunctionSpanNote, 626 #[subdiagnostic] 627 pub note: MustImplementNotFunctionNote, 628 } 629 630 #[derive(Subdiagnostic)] 631 #[note(hir_analysis_must_implement_not_function_span_note)] 632 pub(crate) struct MustImplementNotFunctionSpanNote { 633 #[primary_span] 634 pub span: Span, 635 } 636 637 #[derive(Subdiagnostic)] 638 #[note(hir_analysis_must_implement_not_function_note)] 639 pub(crate) struct MustImplementNotFunctionNote {} 640 641 #[derive(Diagnostic)] 642 #[diag(hir_analysis_function_not_found_in_trait)] 643 pub(crate) struct FunctionNotFoundInTrait { 644 #[primary_span] 645 pub span: Span, 646 } 647 648 #[derive(Diagnostic)] 649 #[diag(hir_analysis_functions_names_duplicated)] 650 #[note] 651 pub(crate) struct FunctionNamesDuplicated { 652 #[primary_span] 653 pub spans: Vec<Span>, 654 } 655 656 #[derive(Diagnostic)] 657 #[diag(hir_analysis_simd_ffi_highly_experimental)] 658 #[help] 659 pub(crate) struct SIMDFFIHighlyExperimental { 660 #[primary_span] 661 pub span: Span, 662 pub snip: String, 663 } 664 665 #[derive(Diagnostic)] 666 667 pub enum ImplNotMarkedDefault { 668 #[diag(hir_analysis_impl_not_marked_default, code = "E0520")] 669 #[note] 670 Ok { 671 #[primary_span] 672 #[label] 673 span: Span, 674 #[label(hir_analysis_ok_label)] 675 ok_label: Span, 676 ident: Symbol, 677 }, 678 #[diag(hir_analysis_impl_not_marked_default_err, code = "E0520")] 679 #[note] 680 Err { 681 #[primary_span] 682 span: Span, 683 cname: Symbol, 684 ident: Symbol, 685 }, 686 } 687 688 #[derive(Diagnostic)] 689 #[diag(hir_analysis_missing_trait_item, code = "E0046")] 690 pub(crate) struct MissingTraitItem { 691 #[primary_span] 692 #[label] 693 pub span: Span, 694 #[subdiagnostic] 695 pub missing_trait_item_label: Vec<MissingTraitItemLabel>, 696 #[subdiagnostic] 697 pub missing_trait_item: Vec<MissingTraitItemSuggestion>, 698 #[subdiagnostic] 699 pub missing_trait_item_none: Vec<MissingTraitItemSuggestionNone>, 700 pub missing_items_msg: String, 701 } 702 703 #[derive(Subdiagnostic)] 704 #[label(hir_analysis_missing_trait_item_label)] 705 pub(crate) struct MissingTraitItemLabel { 706 #[primary_span] 707 pub span: Span, 708 pub item: Symbol, 709 } 710 711 #[derive(Subdiagnostic)] 712 #[suggestion( 713 hir_analysis_missing_trait_item_suggestion, 714 style = "tool-only", 715 applicability = "has-placeholders", 716 code = "{code}" 717 )] 718 pub(crate) struct MissingTraitItemSuggestion { 719 #[primary_span] 720 pub span: Span, 721 pub code: String, 722 pub snippet: String, 723 } 724 725 #[derive(Subdiagnostic)] 726 #[suggestion( 727 hir_analysis_missing_trait_item_suggestion, 728 style = "hidden", 729 applicability = "has-placeholders", 730 code = "{code}" 731 )] 732 pub(crate) struct MissingTraitItemSuggestionNone { 733 #[primary_span] 734 pub span: Span, 735 pub code: String, 736 pub snippet: String, 737 } 738 739 #[derive(Diagnostic)] 740 #[diag(hir_analysis_missing_one_of_trait_item, code = "E0046")] 741 pub(crate) struct MissingOneOfTraitItem { 742 #[primary_span] 743 #[label] 744 pub span: Span, 745 #[note] 746 pub note: Option<Span>, 747 pub missing_items_msg: String, 748 } 749 750 #[derive(Diagnostic)] 751 #[diag(hir_analysis_missing_trait_item_unstable, code = "E0046")] 752 #[note] 753 pub(crate) struct MissingTraitItemUnstable { 754 #[primary_span] 755 pub span: Span, 756 #[note(hir_analysis_some_note)] 757 pub some_note: bool, 758 #[note(hir_analysis_none_note)] 759 pub none_note: bool, 760 pub missing_item_name: Symbol, 761 pub feature: Symbol, 762 pub reason: String, 763 } 764 765 #[derive(Diagnostic)] 766 #[diag(hir_analysis_transparent_enum_variant, code = "E0731")] 767 pub(crate) struct TransparentEnumVariant { 768 #[primary_span] 769 #[label] 770 pub span: Span, 771 #[label(hir_analysis_multi_label)] 772 pub spans: Vec<Span>, 773 #[label(hir_analysis_many_label)] 774 pub many: Option<Span>, 775 pub number: usize, 776 pub path: String, 777 } 778 779 #[derive(Diagnostic)] 780 #[diag(hir_analysis_transparent_non_zero_sized_enum, code = "E0690")] 781 pub(crate) struct TransparentNonZeroSizedEnum<'a> { 782 #[primary_span] 783 #[label] 784 pub span: Span, 785 #[label(hir_analysis_labels)] 786 pub spans: Vec<Span>, 787 pub field_count: usize, 788 pub desc: &'a str, 789 } 790 791 #[derive(Diagnostic)] 792 #[diag(hir_analysis_transparent_non_zero_sized, code = "E0690")] 793 pub(crate) struct TransparentNonZeroSized<'a> { 794 #[primary_span] 795 #[label] 796 pub span: Span, 797 #[label(hir_analysis_labels)] 798 pub spans: Vec<Span>, 799 pub field_count: usize, 800 pub desc: &'a str, 801 } 802 803 #[derive(Diagnostic)] 804 #[diag(hir_analysis_too_large_static)] 805 pub(crate) struct TooLargeStatic { 806 #[primary_span] 807 pub span: Span, 808 } 809 810 #[derive(Diagnostic)] 811 #[diag(hir_analysis_specialization_trait)] 812 #[help] 813 pub(crate) struct SpecializationTrait { 814 #[primary_span] 815 pub span: Span, 816 } 817 818 #[derive(Diagnostic)] 819 #[diag(hir_analysis_closure_implicit_hrtb)] 820 pub(crate) struct ClosureImplicitHrtb { 821 #[primary_span] 822 pub spans: Vec<Span>, 823 #[label] 824 pub for_sp: Span, 825 } 826 827 #[derive(Diagnostic)] 828 #[diag(hir_analysis_empty_specialization)] 829 pub(crate) struct EmptySpecialization { 830 #[primary_span] 831 pub span: Span, 832 #[note] 833 pub base_impl_span: Span, 834 } 835 836 #[derive(Diagnostic)] 837 #[diag(hir_analysis_const_specialize)] 838 pub(crate) struct ConstSpecialize { 839 #[primary_span] 840 pub span: Span, 841 } 842 843 #[derive(Diagnostic)] 844 #[diag(hir_analysis_static_specialize)] 845 pub(crate) struct StaticSpecialize { 846 #[primary_span] 847 pub span: Span, 848 } 849 850 #[derive(Diagnostic)] 851 #[diag(hir_analysis_missing_tilde_const)] 852 pub(crate) struct MissingTildeConst { 853 #[primary_span] 854 pub span: Span, 855 } 856 857 #[derive(Diagnostic)] 858 pub(crate) enum DropImplPolarity { 859 #[diag(hir_analysis_drop_impl_negative)] 860 Negative { 861 #[primary_span] 862 span: Span, 863 }, 864 #[diag(hir_analysis_drop_impl_reservation)] 865 Reservation { 866 #[primary_span] 867 span: Span, 868 }, 869 } 870 871 #[derive(Diagnostic)] 872 pub(crate) enum ReturnTypeNotationIllegalParam { 873 #[diag(hir_analysis_return_type_notation_illegal_param_type)] 874 Type { 875 #[primary_span] 876 span: Span, 877 #[label] 878 param_span: Span, 879 }, 880 #[diag(hir_analysis_return_type_notation_illegal_param_const)] 881 Const { 882 #[primary_span] 883 span: Span, 884 #[label] 885 param_span: Span, 886 }, 887 } 888 889 #[derive(Diagnostic)] 890 pub(crate) enum LateBoundInApit { 891 #[diag(hir_analysis_late_bound_type_in_apit)] 892 Type { 893 #[primary_span] 894 span: Span, 895 #[label] 896 param_span: Span, 897 }, 898 #[diag(hir_analysis_late_bound_const_in_apit)] 899 Const { 900 #[primary_span] 901 span: Span, 902 #[label] 903 param_span: Span, 904 }, 905 #[diag(hir_analysis_late_bound_lifetime_in_apit)] 906 Lifetime { 907 #[primary_span] 908 span: Span, 909 #[label] 910 param_span: Span, 911 }, 912 } 913 914 #[derive(LintDiagnostic)] 915 #[diag(hir_analysis_unused_associated_type_bounds)] 916 #[note] 917 pub struct UnusedAssociatedTypeBounds { 918 #[suggestion(code = "")] 919 pub span: Span, 920 } 921