1 //! Errors emitted by `rustc_hir_analysis`.
2 use rustc_macros::{Diagnostic, Subdiagnostic};
3 use rustc_middle::ty::Ty;
4 use rustc_span::{symbol::Ident, Span};
7 #[diag(hir_analysis_field_multiply_specified_in_initializer, code = "E0062")]
8 pub struct FieldMultiplySpecifiedInInitializer {
12 #[label(previous_use_label)]
18 #[diag(hir_analysis_return_stmt_outside_of_fn_body, code = "E0572")]
19 pub struct ReturnStmtOutsideOfFnBody {
22 #[label(encl_body_label)]
23 pub encl_body_span: Option<Span>,
24 #[label(encl_fn_label)]
25 pub encl_fn_span: Option<Span>,
29 #[diag(hir_analysis_yield_expr_outside_of_generator, code = "E0627")]
30 pub struct YieldExprOutsideOfGenerator {
36 #[diag(hir_analysis_struct_expr_non_exhaustive, code = "E0639")]
37 pub struct StructExprNonExhaustive {
40 pub what: &'static str,
44 #[diag(hir_analysis_method_call_on_unknown_type, code = "E0699")]
45 pub struct MethodCallOnUnknownType {
51 #[diag(hir_analysis_functional_record_update_on_non_struct, code = "E0436")]
52 pub struct FunctionalRecordUpdateOnNonStruct {
58 #[diag(hir_analysis_address_of_temporary_taken, code = "E0745")]
59 pub struct AddressOfTemporaryTaken {
65 #[derive(Subdiagnostic)]
66 pub enum AddReturnTypeSuggestion {
68 hir_analysis_add_return_type_add,
70 applicability = "machine-applicable"
78 hir_analysis_add_return_type_missing_here,
80 applicability = "has-placeholders"
88 #[derive(Subdiagnostic)]
89 pub enum ExpectedReturnTypeLabel<'tcx> {
90 #[label(hir_analysis_expected_default_return_type)]
95 #[label(hir_analysis_expected_return_type)]
103 #[derive(Diagnostic)]
104 #[diag(hir_analysis_missing_parentheses_in_range, code = "E0689")]
105 pub struct MissingParentheseInRange {
107 #[label(hir_analysis_missing_parentheses_in_range)]
110 pub method_name: String,
112 pub add_missing_parentheses: Option<AddMissingParenthesesInRange>,
115 #[derive(Subdiagnostic)]
116 #[multipart_suggestion(
117 hir_analysis_add_missing_parentheses_in_range,
119 applicability = "maybe-incorrect"
121 pub struct AddMissingParenthesesInRange {
122 pub func_name: String,
123 #[suggestion_part(code = "(")]
125 #[suggestion_part(code = ")")]
129 #[derive(Diagnostic)]
130 #[diag(hir_analysis_op_trait_generic_params)]
131 pub struct OpMethodGenericParams {
134 pub method_name: String,