Skip to main content

rustc_hir_typeck/
errors.rs

1//! Errors emitted by `rustc_hir_typeck`.
2
3use std::borrow::Cow;
4
5use rustc_abi::ExternAbi;
6use rustc_ast::{AssignOpKind, Label};
7use rustc_errors::codes::*;
8use rustc_errors::{
9    Applicability, Diag, DiagArgValue, DiagCtxtHandle, DiagSymbolList, Diagnostic,
10    EmissionGuarantee, IntoDiagArg, Level, MultiSpan, Subdiagnostic, msg,
11};
12use rustc_hir as hir;
13use rustc_hir::ExprKind;
14use rustc_macros::{Diagnostic, Subdiagnostic};
15use rustc_middle::ty::{self, Ty};
16use rustc_span::edition::{Edition, LATEST_STABLE_EDITION};
17use rustc_span::{Ident, Span, Spanned, Symbol};
18
19use crate::FnCtxt;
20
21#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BaseExpressionDoubleDot where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    BaseExpressionDoubleDot {
                        span: __binding_0,
                        default_field_values_suggestion: __binding_1,
                        add_expr: __binding_2,
                        remove_dots: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("base expression required after `..`")));
                        let __code_0 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("#![feature(default_field_values)]\n"))
                                            })].into_iter();
                        diag.code(E0797);
                        ;
                        diag.span(__binding_0);
                        if let Some(__binding_1) = __binding_1 {
                            diag.span_suggestions_with_style(__binding_1,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#![feature(default_field_values)]` to the crate attributes to enable default values on `struct` fields")),
                                __code_0, rustc_errors::Applicability::MachineApplicable,
                                rustc_errors::SuggestionStyle::ShowAlways);
                        }
                        if let Some(__binding_2) = __binding_2 {
                            diag.subdiagnostic(__binding_2);
                        }
                        if let Some(__binding_3) = __binding_3 {
                            diag.subdiagnostic(__binding_3);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
22#[diag("base expression required after `..`", code = E0797)]
23pub(crate) struct BaseExpressionDoubleDot {
24    #[primary_span]
25    pub span: Span,
26    #[suggestion(
27        "add `#![feature(default_field_values)]` to the crate attributes to enable default values on `struct` fields",
28        code = "#![feature(default_field_values)]\n",
29        applicability = "machine-applicable",
30        style = "verbose"
31    )]
32    pub default_field_values_suggestion: Option<Span>,
33    #[subdiagnostic]
34    pub add_expr: Option<BaseExpressionDoubleDotAddExpr>,
35    #[subdiagnostic]
36    pub remove_dots: Option<BaseExpressionDoubleDotRemove>,
37}
38
39#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for BaseExpressionDoubleDotRemove {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    BaseExpressionDoubleDotRemove { span: __binding_0 } => {
                        let __code_1 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(""))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `..` as all the fields are already present")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_1, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
40#[suggestion(
41    "remove the `..` as all the fields are already present",
42    code = "",
43    applicability = "machine-applicable",
44    style = "verbose"
45)]
46pub(crate) struct BaseExpressionDoubleDotRemove {
47    #[primary_span]
48    pub span: Span,
49}
50
51#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for BaseExpressionDoubleDotAddExpr {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    BaseExpressionDoubleDotAddExpr { span: __binding_0 } => {
                        let __code_2 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("/* expr */"))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add a base expression here")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_2, rustc_errors::Applicability::HasPlaceholders,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
52#[suggestion(
53    "add a base expression here",
54    code = "/* expr */",
55    applicability = "has-placeholders",
56    style = "verbose"
57)]
58pub(crate) struct BaseExpressionDoubleDotAddExpr {
59    #[primary_span]
60    pub span: Span,
61}
62
63#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            FieldMultiplySpecifiedInInitializer where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    FieldMultiplySpecifiedInInitializer {
                        span: __binding_0,
                        prev_span: __binding_1,
                        ident: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("field `{$ident}` specified more than once")));
                        diag.code(E0062);
                        ;
                        diag.arg("ident", __binding_2);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("used more than once")));
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("first use of `{$ident}`")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
64#[diag("field `{$ident}` specified more than once", code = E0062)]
65pub(crate) struct FieldMultiplySpecifiedInInitializer {
66    #[primary_span]
67    #[label("used more than once")]
68    pub span: Span,
69    #[label("first use of `{$ident}`")]
70    pub prev_span: Span,
71    pub ident: Ident,
72}
73
74#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ReturnStmtOutsideOfFnBody where G: rustc_errors::EmissionGuarantee
            {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ReturnStmtOutsideOfFnBody {
                        span: __binding_0,
                        encl_body_span: __binding_1,
                        encl_fn_span: __binding_2,
                        statement_kind: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$statement_kind} statement outside of function body")));
                        diag.code(E0572);
                        ;
                        diag.arg("statement_kind", __binding_3);
                        diag.span(__binding_0);
                        if let Some(__binding_1) = __binding_1 {
                            diag.span_label(__binding_1,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$statement_kind} is part of this body...")));
                        }
                        if let Some(__binding_2) = __binding_2 {
                            diag.span_label(__binding_2,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...not the enclosing function body")));
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
75#[diag("{$statement_kind} statement outside of function body", code = E0572)]
76pub(crate) struct ReturnStmtOutsideOfFnBody {
77    #[primary_span]
78    pub span: Span,
79    #[label("the {$statement_kind} is part of this body...")]
80    pub encl_body_span: Option<Span>,
81    #[label("...not the enclosing function body")]
82    pub encl_fn_span: Option<Span>,
83    pub statement_kind: ReturnLikeStatementKind,
84}
85
86pub(crate) enum ReturnLikeStatementKind {
87    Return,
88    Become,
89}
90
91impl IntoDiagArg for ReturnLikeStatementKind {
92    fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
93        let kind = match self {
94            Self::Return => "return",
95            Self::Become => "become",
96        }
97        .into();
98
99        DiagArgValue::Str(kind)
100    }
101}
102
103#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            RustCallIncorrectArgs where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    RustCallIncorrectArgs { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions with the \"rust-call\" ABI must take a single non-self tuple argument")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
104#[diag("functions with the \"rust-call\" ABI must take a single non-self tuple argument")]
105pub(crate) struct RustCallIncorrectArgs {
106    #[primary_span]
107    pub span: Span,
108}
109
110#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            YieldExprOutsideOfCoroutine where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    YieldExprOutsideOfCoroutine { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("yield expression outside of coroutine literal")));
                        diag.code(E0627);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
111#[diag("yield expression outside of coroutine literal", code = E0627)]
112pub(crate) struct YieldExprOutsideOfCoroutine {
113    #[primary_span]
114    pub span: Span,
115}
116
117#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            StructExprNonExhaustive where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    StructExprNonExhaustive {
                        span: __binding_0, what: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot create non-exhaustive {$what} using struct expression")));
                        diag.code(E0639);
                        ;
                        diag.arg("what", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
118#[diag("cannot create non-exhaustive {$what} using struct expression", code = E0639)]
119pub(crate) struct StructExprNonExhaustive {
120    #[primary_span]
121    pub span: Span,
122    pub what: &'static str,
123}
124
125#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            FunctionalRecordUpdateOnNonStruct where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    FunctionalRecordUpdateOnNonStruct { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functional record update syntax requires a struct")));
                        diag.code(E0436);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
126#[diag("functional record update syntax requires a struct", code = E0436)]
127pub(crate) struct FunctionalRecordUpdateOnNonStruct {
128    #[primary_span]
129    pub span: Span,
130}
131
132#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            AddressOfTemporaryTaken where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    AddressOfTemporaryTaken { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot take address of a temporary")));
                        diag.code(E0745);
                        ;
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("temporary value")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
133#[diag("cannot take address of a temporary", code = E0745)]
134pub(crate) struct AddressOfTemporaryTaken {
135    #[primary_span]
136    #[label("temporary value")]
137    pub span: Span,
138}
139
140#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for AddReturnTypeSuggestion {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    AddReturnTypeSuggestion::Add {
                        span: __binding_0, found: __binding_1 } => {
                        let __code_3 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(" -> {0}", __binding_1))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try adding a return type")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_3, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    AddReturnTypeSuggestion::MissingHere { span: __binding_0 }
                        => {
                        let __code_4 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(" -> _"))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a return type might be missing here")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_4, rustc_errors::Applicability::HasPlaceholders,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
141pub(crate) enum AddReturnTypeSuggestion {
142    #[suggestion(
143        "try adding a return type",
144        code = " -> {found}",
145        applicability = "machine-applicable"
146    )]
147    Add {
148        #[primary_span]
149        span: Span,
150        found: String,
151    },
152    #[suggestion(
153        "a return type might be missing here",
154        code = " -> _",
155        applicability = "has-placeholders"
156    )]
157    MissingHere {
158        #[primary_span]
159        span: Span,
160    },
161}
162
163#[derive(const _: () =
    {
        impl<'tcx> rustc_errors::Subdiagnostic for
            ExpectedReturnTypeLabel<'tcx> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ExpectedReturnTypeLabel::Unit { span: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `()` because of default return type")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                    ExpectedReturnTypeLabel::Other {
                        span: __binding_0, expected: __binding_1 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("expected".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `{$expected}` because of return type")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                    ExpectedReturnTypeLabel::ImplTrait {
                        span: __binding_0, trait_name: __binding_1 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("trait_name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a single type implementing `{$trait_name}` because of return type")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                }
            }
        }
    };Subdiagnostic)]
164pub(crate) enum ExpectedReturnTypeLabel<'tcx> {
165    #[label("expected `()` because of default return type")]
166    Unit {
167        #[primary_span]
168        span: Span,
169    },
170    #[label("expected `{$expected}` because of return type")]
171    Other {
172        #[primary_span]
173        span: Span,
174        expected: Ty<'tcx>,
175    },
176    #[label("expected a single type implementing `{$trait_name}` because of return type")]
177    ImplTrait {
178        #[primary_span]
179        span: Span,
180        trait_name: String,
181    },
182}
183
184#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ExplicitDestructorCall where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ExplicitDestructorCall {
                        span: __binding_0, sugg: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("explicit use of destructor method")));
                        diag.code(E0040);
                        ;
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("explicit destructor calls not allowed")));
                        diag.subdiagnostic(__binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
185#[diag("explicit use of destructor method", code = E0040)]
186pub(crate) struct ExplicitDestructorCall {
187    #[primary_span]
188    #[label("explicit destructor calls not allowed")]
189    pub span: Span,
190    #[subdiagnostic]
191    pub sugg: ExplicitDestructorCallSugg,
192}
193
194#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for ExplicitDestructorCallSugg {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ExplicitDestructorCallSugg::Empty(__binding_0) => {
                        let __code_5 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("drop"))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using `drop` function")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_5, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    ExplicitDestructorCallSugg::Snippet {
                        lo: __binding_0, hi: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_6 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("drop("))
                                });
                        let __code_7 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        suggestions.push((__binding_0, __code_6));
                        suggestions.push((__binding_1, __code_7));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using `drop` function")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::Unspecified,
                            rustc_errors::SuggestionStyle::HideCodeInline);
                    }
                }
            }
        }
    };Subdiagnostic)]
195pub(crate) enum ExplicitDestructorCallSugg {
196    #[suggestion(
197        "consider using `drop` function",
198        code = "drop",
199        applicability = "maybe-incorrect"
200    )]
201    Empty(#[primary_span] Span),
202    #[multipart_suggestion("consider using `drop` function", style = "short")]
203    Snippet {
204        #[suggestion_part(code = "drop(")]
205        lo: Span,
206        #[suggestion_part(code = ")")]
207        hi: Span,
208    },
209}
210
211#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            MissingParenthesesInRange<'tcx> where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    MissingParenthesesInRange {
                        span: __binding_0,
                        ty: __binding_1,
                        method_name: __binding_2,
                        add_missing_parentheses: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't call method `{$method_name}` on type `{$ty}`")));
                        diag.code(E0689);
                        ;
                        diag.arg("ty", __binding_1);
                        diag.arg("method_name", __binding_2);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't call method `{$method_name}` on type `{$ty}`")));
                        if let Some(__binding_3) = __binding_3 {
                            diag.subdiagnostic(__binding_3);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
212#[diag("can't call method `{$method_name}` on type `{$ty}`", code = E0689)]
213pub(crate) struct MissingParenthesesInRange<'tcx> {
214    #[primary_span]
215    #[label("can't call method `{$method_name}` on type `{$ty}`")]
216    pub span: Span,
217    pub ty: Ty<'tcx>,
218    pub method_name: String,
219    #[subdiagnostic]
220    pub add_missing_parentheses: Option<AddMissingParenthesesInRange>,
221}
222
223#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            NeverTypeFallbackFlowingIntoUnsafe where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    NeverTypeFallbackFlowingIntoUnsafe::Call { sugg: __binding_0
                        } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("never type fallback affects this call to an `unsafe` function")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("specify the type explicitly")));
                        ;
                        diag.subdiagnostic(__binding_0);
                        diag
                    }
                    NeverTypeFallbackFlowingIntoUnsafe::Method {
                        sugg: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("never type fallback affects this call to an `unsafe` method")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("specify the type explicitly")));
                        ;
                        diag.subdiagnostic(__binding_0);
                        diag
                    }
                    NeverTypeFallbackFlowingIntoUnsafe::Path { sugg: __binding_0
                        } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("never type fallback affects this `unsafe` function")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("specify the type explicitly")));
                        ;
                        diag.subdiagnostic(__binding_0);
                        diag
                    }
                    NeverTypeFallbackFlowingIntoUnsafe::UnionField {
                        sugg: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("never type fallback affects this union access")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("specify the type explicitly")));
                        ;
                        diag.subdiagnostic(__binding_0);
                        diag
                    }
                    NeverTypeFallbackFlowingIntoUnsafe::Deref {
                        sugg: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("never type fallback affects this raw pointer dereference")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("specify the type explicitly")));
                        ;
                        diag.subdiagnostic(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
224pub(crate) enum NeverTypeFallbackFlowingIntoUnsafe {
225    #[help("specify the type explicitly")]
226    #[diag("never type fallback affects this call to an `unsafe` function")]
227    Call {
228        #[subdiagnostic]
229        sugg: SuggestAnnotations,
230    },
231    #[help("specify the type explicitly")]
232    #[diag("never type fallback affects this call to an `unsafe` method")]
233    Method {
234        #[subdiagnostic]
235        sugg: SuggestAnnotations,
236    },
237    #[help("specify the type explicitly")]
238    #[diag("never type fallback affects this `unsafe` function")]
239    Path {
240        #[subdiagnostic]
241        sugg: SuggestAnnotations,
242    },
243    #[help("specify the type explicitly")]
244    #[diag("never type fallback affects this union access")]
245    UnionField {
246        #[subdiagnostic]
247        sugg: SuggestAnnotations,
248    },
249    #[help("specify the type explicitly")]
250    #[diag("never type fallback affects this raw pointer dereference")]
251    Deref {
252        #[subdiagnostic]
253        sugg: SuggestAnnotations,
254    },
255}
256
257#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            DependencyOnUnitNeverTypeFallback<'tcx> where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    DependencyOnUnitNeverTypeFallback {
                        obligation_span: __binding_0,
                        obligation: __binding_1,
                        sugg: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this function depends on never type fallback being `()`")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("specify the types explicitly")));
                        ;
                        diag.arg("obligation", __binding_1);
                        diag.span_note(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("in edition 2024, the requirement `{$obligation}` will fail")));
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
258#[help("specify the types explicitly")]
259#[diag("this function depends on never type fallback being `()`")]
260pub(crate) struct DependencyOnUnitNeverTypeFallback<'tcx> {
261    #[note("in edition 2024, the requirement `{$obligation}` will fail")]
262    pub obligation_span: Span,
263    pub obligation: ty::Predicate<'tcx>,
264    #[subdiagnostic]
265    pub sugg: SuggestAnnotations,
266}
267
268#[derive(#[automatically_derived]
impl ::core::clone::Clone for SuggestAnnotation {
    #[inline]
    fn clone(&self) -> SuggestAnnotation {
        match self {
            SuggestAnnotation::Unit(__self_0) =>
                SuggestAnnotation::Unit(::core::clone::Clone::clone(__self_0)),
            SuggestAnnotation::Path(__self_0) =>
                SuggestAnnotation::Path(::core::clone::Clone::clone(__self_0)),
            SuggestAnnotation::Local(__self_0) =>
                SuggestAnnotation::Local(::core::clone::Clone::clone(__self_0)),
            SuggestAnnotation::Turbo(__self_0, __self_1, __self_2) =>
                SuggestAnnotation::Turbo(::core::clone::Clone::clone(__self_0),
                    ::core::clone::Clone::clone(__self_1),
                    ::core::clone::Clone::clone(__self_2)),
        }
    }
}Clone)]
269pub(crate) enum SuggestAnnotation {
270    Unit(Span),
271    Path(Span),
272    Local(Span),
273    Turbo(Span, usize, usize),
274}
275
276#[derive(#[automatically_derived]
impl ::core::clone::Clone for SuggestAnnotations {
    #[inline]
    fn clone(&self) -> SuggestAnnotations {
        SuggestAnnotations {
            suggestions: ::core::clone::Clone::clone(&self.suggestions),
        }
    }
}Clone)]
277pub(crate) struct SuggestAnnotations {
278    pub suggestions: Vec<SuggestAnnotation>,
279}
280impl Subdiagnostic for SuggestAnnotations {
281    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
282        if self.suggestions.is_empty() {
283            return;
284        }
285
286        let mut suggestions = ::alloc::vec::Vec::new()vec![];
287        for suggestion in self.suggestions {
288            match suggestion {
289                SuggestAnnotation::Unit(span) => {
290                    suggestions.push((span, "()".to_string()));
291                }
292                SuggestAnnotation::Path(span) => {
293                    suggestions.push((span.shrink_to_lo(), "<() as ".to_string()));
294                    suggestions.push((span.shrink_to_hi(), ">".to_string()));
295                }
296                SuggestAnnotation::Local(span) => {
297                    suggestions.push((span, ": ()".to_string()));
298                }
299                SuggestAnnotation::Turbo(span, n_args, idx) => suggestions.push((
300                    span,
301                    ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("::<{0}>",
                (0..n_args).map(|i|
                                if i == idx {
                                    "()"
                                } else { "_" }).collect::<Vec<_>>().join(", ")))
    })format!(
302                        "::<{}>",
303                        (0..n_args)
304                            .map(|i| if i == idx { "()" } else { "_" })
305                            .collect::<Vec<_>>()
306                            .join(", "),
307                    ),
308                )),
309            }
310        }
311
312        diag.multipart_suggestion(
313            "use `()` annotations to avoid fallback changes",
314            suggestions,
315            Applicability::MachineApplicable,
316        );
317    }
318}
319
320#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for AddMissingParenthesesInRange {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    AddMissingParenthesesInRange {
                        func_name: __binding_0,
                        left: __binding_1,
                        right: __binding_2 } => {
                        let mut suggestions = Vec::new();
                        let __code_8 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("("))
                                });
                        let __code_9 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        suggestions.push((__binding_1, __code_8));
                        suggestions.push((__binding_2, __code_9));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("func_name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you must surround the range in parentheses to call its `{$func_name}` function")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
321#[multipart_suggestion(
322    "you must surround the range in parentheses to call its `{$func_name}` function",
323    style = "verbose",
324    applicability = "maybe-incorrect"
325)]
326pub(crate) struct AddMissingParenthesesInRange {
327    pub func_name: String,
328    #[suggestion_part(code = "(")]
329    pub left: Span,
330    #[suggestion_part(code = ")")]
331    pub right: Span,
332}
333
334pub(crate) struct TypeMismatchFruTypo {
335    /// Span of the LHS of the range
336    pub expr_span: Span,
337    /// Span of the `..RHS` part of the range
338    pub fru_span: Span,
339    /// Rendered expression of the RHS of the range
340    pub expr: Option<String>,
341}
342
343impl Subdiagnostic for TypeMismatchFruTypo {
344    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
345        diag.arg("expr", self.expr.as_deref().unwrap_or("NONE"));
346
347        // Only explain that `a ..b` is a range if it's split up
348        if self.expr_span.between(self.fru_span).is_empty() {
349            diag.span_note(
350                self.expr_span.to(self.fru_span),
351                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this expression may have been misinterpreted as a `..` range expression"))msg!("this expression may have been misinterpreted as a `..` range expression"),
352            );
353        } else {
354            let mut multispan: MultiSpan = ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
        [self.expr_span, self.fru_span]))vec![self.expr_span, self.fru_span].into();
355            multispan.push_span_label(
356                self.expr_span,
357                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this expression does not end in a comma..."))msg!("this expression does not end in a comma..."),
358            );
359            multispan.push_span_label(self.fru_span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("... so this is interpreted as a `..` range expression, instead of functional record update syntax"))msg!("... so this is interpreted as a `..` range expression, instead of functional record update syntax"));
360            diag.span_note(
361                multispan,
362                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this expression may have been misinterpreted as a `..` range expression"))msg!("this expression may have been misinterpreted as a `..` range expression"),
363            );
364        }
365
366        diag.span_suggestion(
367            self.expr_span.shrink_to_hi(),
368            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to set the remaining fields{$expr ->\n                    [NONE]{\"\"}\n                    *[other] {\" \"}from `{$expr}`\n                }, separate the last named field with a comma"))msg!(
369                "to set the remaining fields{$expr ->
370                    [NONE]{\"\"}
371                    *[other] {\" \"}from `{$expr}`
372                }, separate the last named field with a comma"
373            ),
374            ", ",
375            Applicability::MaybeIncorrect,
376        );
377    }
378}
379
380#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            PtrCastAddAutoToObject where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    PtrCastAddAutoToObject {
                        span: __binding_0,
                        traits_len: __binding_1,
                        traits: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot add {$traits_len ->\n    [1] auto trait {$traits}\n    *[other] auto traits {$traits}\n} to dyn bound via pointer cast")));
                        diag.code(E0804);
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this could allow UB elsewhere")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `transmute` if you're sure this is sound")));
                        ;
                        diag.arg("traits_len", __binding_1);
                        diag.arg("traits", __binding_2);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsupported cast")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
381#[diag("cannot add {$traits_len ->
382    [1] auto trait {$traits}
383    *[other] auto traits {$traits}
384} to dyn bound via pointer cast", code = E0804)]
385#[note("this could allow UB elsewhere")]
386#[help("use `transmute` if you're sure this is sound")]
387pub(crate) struct PtrCastAddAutoToObject {
388    #[primary_span]
389    #[label("unsupported cast")]
390    pub span: Span,
391    pub traits_len: usize,
392    pub traits: DiagSymbolList<String>,
393}
394
395#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for HelpUseLatestEdition {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    HelpUseLatestEdition::Cargo { edition: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("edition".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("set `edition = \"{$edition}\"` in `Cargo.toml`")),
                                &sub_args);
                        diag.help(__message);
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more on editions, read https://doc.rust-lang.org/edition-guide")),
                                &sub_args);
                        diag.note(__message);
                    }
                    HelpUseLatestEdition::Standalone { edition: __binding_0 } =>
                        {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("edition".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("pass `--edition {$edition}` to `rustc`")),
                                &sub_args);
                        diag.help(__message);
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more on editions, read https://doc.rust-lang.org/edition-guide")),
                                &sub_args);
                        diag.note(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
396pub(crate) enum HelpUseLatestEdition {
397    #[help("set `edition = \"{$edition}\"` in `Cargo.toml`")]
398    #[note("for more on editions, read https://doc.rust-lang.org/edition-guide")]
399    Cargo { edition: Edition },
400    #[help("pass `--edition {$edition}` to `rustc`")]
401    #[note("for more on editions, read https://doc.rust-lang.org/edition-guide")]
402    Standalone { edition: Edition },
403}
404
405impl HelpUseLatestEdition {
406    pub(crate) fn new() -> Self {
407        let edition = LATEST_STABLE_EDITION;
408        if rustc_session::utils::was_invoked_from_cargo() {
409            Self::Cargo { edition }
410        } else {
411            Self::Standalone { edition }
412        }
413    }
414}
415
416#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            NoFieldOnVariant<'tcx> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    NoFieldOnVariant {
                        span: __binding_0,
                        container: __binding_1,
                        ident: __binding_2,
                        field: __binding_3,
                        enum_span: __binding_4,
                        field_span: __binding_5 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("no field named `{$field}` on enum variant `{$container}::{$ident}`")));
                        diag.code(E0609);
                        ;
                        diag.arg("container", __binding_1);
                        diag.arg("ident", __binding_2);
                        diag.arg("field", __binding_3);
                        diag.span(__binding_0);
                        diag.span_label(__binding_4,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this enum variant...")));
                        diag.span_label(__binding_5,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...does not have this field")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
417#[diag("no field named `{$field}` on enum variant `{$container}::{$ident}`", code = E0609)]
418pub(crate) struct NoFieldOnVariant<'tcx> {
419    #[primary_span]
420    pub(crate) span: Span,
421    pub(crate) container: Ty<'tcx>,
422    pub(crate) ident: Ident,
423    pub(crate) field: Ident,
424    #[label("this enum variant...")]
425    pub(crate) enum_span: Span,
426    #[label("...does not have this field")]
427    pub(crate) field_span: Span,
428}
429
430#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            CantDereference<'tcx> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    CantDereference { span: __binding_0, ty: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type `{$ty}` cannot be dereferenced")));
                        diag.code(E0614);
                        ;
                        diag.arg("ty", __binding_1);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't be dereferenced")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
431#[diag("type `{$ty}` cannot be dereferenced", code = E0614)]
432pub(crate) struct CantDereference<'tcx> {
433    #[primary_span]
434    #[label("can't be dereferenced")]
435    pub(crate) span: Span,
436    pub(crate) ty: Ty<'tcx>,
437}
438
439#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            ExpectedArrayOrSlice<'tcx> where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ExpectedArrayOrSlice {
                        span: __binding_0,
                        ty: __binding_1,
                        slice_pat_semantics: __binding_2,
                        as_deref: __binding_3,
                        slicing: __binding_4 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected an array or slice, found `{$ty}`")));
                        diag.code(E0529);
                        ;
                        diag.arg("ty", __binding_1);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("pattern cannot match with input type `{$ty}`")));
                        if let Some(__binding_3) = __binding_3 {
                            diag.subdiagnostic(__binding_3);
                        }
                        if let Some(__binding_4) = __binding_4 {
                            diag.subdiagnostic(__binding_4);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
440#[diag("expected an array or slice, found `{$ty}`", code = E0529)]
441pub(crate) struct ExpectedArrayOrSlice<'tcx> {
442    #[primary_span]
443    #[label("pattern cannot match with input type `{$ty}`")]
444    pub(crate) span: Span,
445    pub(crate) ty: Ty<'tcx>,
446    pub(crate) slice_pat_semantics: bool,
447    #[subdiagnostic]
448    pub(crate) as_deref: Option<AsDerefSuggestion>,
449    #[subdiagnostic]
450    pub(crate) slicing: Option<SlicingSuggestion>,
451}
452
453#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for AsDerefSuggestion {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    AsDerefSuggestion { span: __binding_0 } => {
                        let __code_10 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(".as_deref()"))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using `as_deref` here")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_10, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
454#[suggestion(
455    "consider using `as_deref` here",
456    code = ".as_deref()",
457    style = "verbose",
458    applicability = "maybe-incorrect"
459)]
460pub(crate) struct AsDerefSuggestion {
461    #[primary_span]
462    pub(crate) span: Span,
463}
464
465#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for SlicingSuggestion {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    SlicingSuggestion { span: __binding_0 } => {
                        let __code_11 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("[..]"))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider slicing here")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_11, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
466#[suggestion(
467    "consider slicing here",
468    code = "[..]",
469    style = "verbose",
470    applicability = "maybe-incorrect"
471)]
472pub(crate) struct SlicingSuggestion {
473    #[primary_span]
474    pub(crate) span: Span,
475}
476
477#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for InvalidCallee
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    InvalidCallee { span: __binding_0, found: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected function, found {$found}")));
                        diag.code(E0618);
                        ;
                        diag.arg("found", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
478#[diag("expected function, found {$found}", code = E0618)]
479pub(crate) struct InvalidCallee {
480    #[primary_span]
481    pub span: Span,
482    pub found: String,
483}
484
485#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            ScalableVectorCtor<'tcx> where G: rustc_errors::EmissionGuarantee
            {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ScalableVectorCtor { span: __binding_0, ty: __binding_1 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("scalable vector types cannot be initialised using their constructor")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
486#[diag("scalable vector types cannot be initialised using their constructor")]
487pub(crate) struct ScalableVectorCtor<'tcx> {
488    #[primary_span]
489    pub span: Span,
490    pub ty: Ty<'tcx>,
491}
492
493#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            IntToWide<'tcx> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    IntToWide {
                        span: __binding_0,
                        metadata: __binding_1,
                        expr_ty: __binding_2,
                        cast_ty: __binding_3,
                        expr_if_nightly: __binding_4,
                        known_wide: __binding_5,
                        param_note: __binding_6 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot cast `{$expr_ty}` to a pointer that {$known_wide ->\n    [true] is\n    *[false] may be\n} wide")));
                        diag.code(E0606);
                        ;
                        diag.arg("metadata", __binding_1);
                        diag.arg("expr_ty", __binding_2);
                        diag.arg("cast_ty", __binding_3);
                        diag.arg("known_wide", __binding_5);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("creating a `{$cast_ty}` requires both an address and {$metadata}")));
                        if let Some(__binding_4) = __binding_4 {
                            diag.span_label(__binding_4,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts`")));
                        }
                        if let Some(__binding_6) = __binding_6 {
                            diag.subdiagnostic(__binding_6);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
494#[diag("cannot cast `{$expr_ty}` to a pointer that {$known_wide ->
495    [true] is
496    *[false] may be
497} wide", code = E0606)]
498pub(crate) struct IntToWide<'tcx> {
499    #[primary_span]
500    #[label("creating a `{$cast_ty}` requires both an address and {$metadata}")]
501    pub span: Span,
502    pub metadata: &'tcx str,
503    pub expr_ty: Ty<'tcx>,
504    pub cast_ty: Ty<'tcx>,
505    #[label(
506        "consider casting this expression to `*const ()`, then using `core::ptr::from_raw_parts`"
507    )]
508    pub expr_if_nightly: Option<Span>,
509    pub known_wide: bool,
510    #[subdiagnostic]
511    pub param_note: Option<IntToWideParamNote>,
512}
513
514#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for IntToWideParamNote {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    IntToWideParamNote { param: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("param".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type parameter `{$param}` is not known to be `Sized`, so this pointer may be wide")),
                                &sub_args);
                        diag.note(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
515#[note("the type parameter `{$param}` is not known to be `Sized`, so this pointer may be wide")]
516pub(crate) struct IntToWideParamNote {
517    pub param: Symbol,
518}
519
520#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for OptionResultRefMismatch {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    OptionResultRefMismatch::Copied {
                        span: __binding_0, def_path: __binding_1 } => {
                        let __code_12 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(".copied()"))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("def_path".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `{$def_path}::copied` to copy the value inside the `{$def_path}`")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_12, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    OptionResultRefMismatch::Cloned {
                        span: __binding_0, def_path: __binding_1 } => {
                        let __code_13 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(".cloned()"))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("def_path".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `{$def_path}::cloned` to clone the value inside the `{$def_path}`")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_13, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
521pub(crate) enum OptionResultRefMismatch {
522    #[suggestion(
523        "use `{$def_path}::copied` to copy the value inside the `{$def_path}`",
524        code = ".copied()",
525        style = "verbose",
526        applicability = "machine-applicable"
527    )]
528    Copied {
529        #[primary_span]
530        span: Span,
531        def_path: String,
532    },
533    #[suggestion(
534        "use `{$def_path}::cloned` to clone the value inside the `{$def_path}`",
535        code = ".cloned()",
536        style = "verbose",
537        applicability = "machine-applicable"
538    )]
539    Cloned {
540        #[primary_span]
541        span: Span,
542        def_path: String,
543    },
544    // FIXME: #114050
545    // #[suggestion(
546    //     "use `{$def_path}::as_ref` to convert `{$expected_ty}` to `{$expr_ty}`",
547    //     code = ".as_ref()",
548    //     style = "verbose",
549    //     applicability = "machine-applicable"
550    // )]
551    // AsRef {
552    //     #[primary_span]
553    //     span: Span,
554    //     def_path: String,
555    //     expected_ty: Ty<'tcx>,
556    //     expr_ty: Ty<'tcx>,
557    // },
558}
559
560pub(crate) struct RemoveSemiForCoerce {
561    pub expr: Span,
562    pub ret: Span,
563    pub semi: Span,
564}
565
566impl Subdiagnostic for RemoveSemiForCoerce {
567    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
568        let mut multispan: MultiSpan = self.semi.into();
569        multispan.push_span_label(
570            self.expr,
571            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this could be implicitly returned but it is a statement, not a tail expression"))msg!("this could be implicitly returned but it is a statement, not a tail expression"),
572        );
573        multispan
574            .push_span_label(self.ret, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `match` arms can conform to this return type"))msg!("the `match` arms can conform to this return type"));
575        multispan.push_span_label(
576            self.semi,
577            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `match` is a statement because of this semicolon, consider removing it"))msg!("the `match` is a statement because of this semicolon, consider removing it"),
578        );
579        diag.span_note(multispan, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to return the `match` expression"))msg!("you might have meant to return the `match` expression"));
580
581        diag.tool_only_span_suggestion(
582            self.semi,
583            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this semicolon"))msg!("remove this semicolon"),
584            "",
585            Applicability::MaybeIncorrect,
586        );
587    }
588}
589
590#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnionPatMultipleFields where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnionPatMultipleFields { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("union patterns should have exactly one field")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
591#[diag("union patterns should have exactly one field")]
592pub(crate) struct UnionPatMultipleFields {
593    #[primary_span]
594    pub span: Span,
595}
596
597#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for UnionPatDotDot
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnionPatDotDot { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`..` cannot be used in union patterns")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
598#[diag("`..` cannot be used in union patterns")]
599pub(crate) struct UnionPatDotDot {
600    #[primary_span]
601    pub span: Span,
602}
603
604#[derive(const _: () =
    {
        impl<'tcx> rustc_errors::Subdiagnostic for UseIsEmpty<'tcx> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    UseIsEmpty {
                        lo: __binding_0, hi: __binding_1, expr_ty: __binding_2 } =>
                        {
                        let mut suggestions = Vec::new();
                        let __code_14 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("!"))
                                });
                        let __code_15 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(".is_empty()"))
                                });
                        suggestions.push((__binding_0, __code_14));
                        suggestions.push((__binding_1, __code_15));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("expr_ty".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using the `is_empty` method on `{$expr_ty}` to determine if it contains anything")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
605#[multipart_suggestion(
606    "consider using the `is_empty` method on `{$expr_ty}` to determine if it contains anything",
607    applicability = "maybe-incorrect",
608    style = "verbose"
609)]
610pub(crate) struct UseIsEmpty<'tcx> {
611    #[suggestion_part(code = "!")]
612    pub lo: Span,
613    #[suggestion_part(code = ".is_empty()")]
614    pub hi: Span,
615    pub expr_ty: Ty<'tcx>,
616}
617
618#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ArgMismatchIndeterminate where G: rustc_errors::EmissionGuarantee
            {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ArgMismatchIndeterminate { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("argument type mismatch was detected, but rustc had trouble determining where")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
619#[diag("argument type mismatch was detected, but rustc had trouble determining where")]
620pub(crate) struct ArgMismatchIndeterminate {
621    #[primary_span]
622    pub span: Span,
623}
624
625#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for SuggestBoxing {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    SuggestBoxing::Unit { start: __binding_0, end: __binding_1 }
                        => {
                        let mut suggestions = Vec::new();
                        let __code_16 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("Box::new(())"))
                                });
                        let __code_17 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(""))
                                });
                        suggestions.push((__binding_0, __code_16));
                        suggestions.push((__binding_1, __code_17));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html")),
                                &sub_args);
                        diag.note(__message);
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("store this in the heap by calling `Box::new`")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    SuggestBoxing::AsyncBody => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html")),
                                &sub_args);
                        diag.note(__message);
                    }
                    SuggestBoxing::ExprFieldShorthand {
                        start: __binding_0, end: __binding_1, ident: __binding_2 }
                        => {
                        let mut suggestions = Vec::new();
                        let __code_18 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{0}: Box::new(",
                                            __binding_2))
                                });
                        let __code_19 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        suggestions.push((__binding_0, __code_18));
                        suggestions.push((__binding_1, __code_19));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html")),
                                &sub_args);
                        diag.note(__message);
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("store this in the heap by calling `Box::new`")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    SuggestBoxing::Other { start: __binding_0, end: __binding_1
                        } => {
                        let mut suggestions = Vec::new();
                        let __code_20 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("Box::new("))
                                });
                        let __code_21 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        suggestions.push((__binding_0, __code_20));
                        suggestions.push((__binding_1, __code_21));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html")),
                                &sub_args);
                        diag.note(__message);
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("store this in the heap by calling `Box::new`")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
626pub(crate) enum SuggestBoxing {
627    #[note(
628        "for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html"
629    )]
630    #[multipart_suggestion(
631        "store this in the heap by calling `Box::new`",
632        applicability = "machine-applicable"
633    )]
634    Unit {
635        #[suggestion_part(code = "Box::new(())")]
636        start: Span,
637        #[suggestion_part(code = "")]
638        end: Span,
639    },
640    #[note(
641        "for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html"
642    )]
643    AsyncBody,
644    #[note(
645        "for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html"
646    )]
647    #[multipart_suggestion(
648        "store this in the heap by calling `Box::new`",
649        applicability = "machine-applicable"
650    )]
651    ExprFieldShorthand {
652        #[suggestion_part(code = "{ident}: Box::new(")]
653        start: Span,
654        #[suggestion_part(code = ")")]
655        end: Span,
656        ident: Ident,
657    },
658    #[note(
659        "for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html"
660    )]
661    #[multipart_suggestion(
662        "store this in the heap by calling `Box::new`",
663        applicability = "machine-applicable"
664    )]
665    Other {
666        #[suggestion_part(code = "Box::new(")]
667        start: Span,
668        #[suggestion_part(code = ")")]
669        end: Span,
670    },
671}
672
673#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for SuggestPtrNullMut {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    SuggestPtrNullMut { span: __binding_0 } => {
                        let __code_22 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("core::ptr::null_mut()"))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using `core::ptr::null_mut` instead")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_22, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
674#[suggestion(
675    "consider using `core::ptr::null_mut` instead",
676    applicability = "maybe-incorrect",
677    style = "verbose",
678    code = "core::ptr::null_mut()"
679)]
680pub(crate) struct SuggestPtrNullMut {
681    #[primary_span]
682    pub span: Span,
683}
684
685#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            TrivialCast<'tcx> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    TrivialCast {
                        numeric: __binding_0,
                        expr_ty: __binding_1,
                        cast_ty: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trivial {$numeric ->\n        [true] numeric cast\n        *[false] cast\n    }: `{$expr_ty}` as `{$cast_ty}`")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cast can be replaced by coercion; this might require a temporary variable")));
                        ;
                        diag.arg("numeric", __binding_0);
                        diag.arg("expr_ty", __binding_1);
                        diag.arg("cast_ty", __binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
686#[diag(
687    "trivial {$numeric ->
688        [true] numeric cast
689        *[false] cast
690    }: `{$expr_ty}` as `{$cast_ty}`"
691)]
692#[help("cast can be replaced by coercion; this might require a temporary variable")]
693pub(crate) struct TrivialCast<'tcx> {
694    pub numeric: bool,
695    pub expr_ty: Ty<'tcx>,
696    pub cast_ty: Ty<'tcx>,
697}
698
699pub(crate) struct BreakNonLoop<'a> {
700    pub span: Span,
701    pub head: Option<Span>,
702    pub kind: &'a str,
703    pub suggestion: String,
704    pub loop_label: Option<Label>,
705    pub break_label: Option<Label>,
706    pub break_expr_kind: &'a ExprKind<'a>,
707    pub break_expr_span: Span,
708}
709
710impl<'a, G: EmissionGuarantee> Diagnostic<'_, G> for BreakNonLoop<'a> {
711    #[track_caller]
712    fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
713        let mut diag = Diag::new(dcx, level, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`break` with value from a `{$kind}` loop"))msg!("`break` with value from a `{$kind}` loop"));
714        diag.span(self.span);
715        diag.code(E0571);
716        diag.arg("kind", self.kind);
717        diag.span_label(
718            self.span,
719            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can only break with a value inside `loop` or breakable block"))msg!("can only break with a value inside `loop` or breakable block"),
720        );
721        if let Some(head) = self.head {
722            diag.span_label(head, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you can't `break` with a value in a `{$kind}` loop"))msg!("you can't `break` with a value in a `{$kind}` loop"));
723        }
724        diag.span_suggestion(
725            self.span,
726            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `break` on its own without a value inside this `{$kind}` loop"))msg!("use `break` on its own without a value inside this `{$kind}` loop"),
727            self.suggestion,
728            Applicability::MaybeIncorrect,
729        );
730        if let (Some(label), None) = (self.loop_label, self.break_label) {
731            match self.break_expr_kind {
732                ExprKind::Path(hir::QPath::Resolved(
733                    None,
734                    hir::Path { segments: [segment], res: hir::def::Res::Err, .. },
735                )) if label.ident.to_string() == ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("\'{0}", segment.ident))
    })format!("'{}", segment.ident) => {
736                    // This error is redundant, we will have already emitted a
737                    // suggestion to use the label when `segment` wasn't found
738                    // (hence the `Res::Err` check).
739                    diag.downgrade_to_delayed_bug();
740                }
741                _ => {
742                    diag.span_suggestion(
743                        self.break_expr_span,
744                        rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("alternatively, you might have meant to use the available loop label"))msg!("alternatively, you might have meant to use the available loop label"),
745                        label.ident,
746                        Applicability::MaybeIncorrect,
747                    );
748                }
749            }
750        }
751        diag
752    }
753}
754
755#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ContinueLabeledBlock where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ContinueLabeledBlock {
                        span: __binding_0, block_span: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`continue` pointing to a labeled block")));
                        diag.code(E0696);
                        ;
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("labeled blocks cannot be `continue`'d")));
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("labeled block the `continue` points to")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
756#[diag("`continue` pointing to a labeled block", code = E0696)]
757pub(crate) struct ContinueLabeledBlock {
758    #[primary_span]
759    #[label("labeled blocks cannot be `continue`'d")]
760    pub span: Span,
761    #[label("labeled block the `continue` points to")]
762    pub block_span: Span,
763}
764
765#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            BreakInsideClosure<'a> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    BreakInsideClosure {
                        span: __binding_0,
                        closure_span: __binding_1,
                        name: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` inside of a closure")));
                        diag.code(E0267);
                        ;
                        diag.arg("name", __binding_2);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot `{$name}` inside of a closure")));
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("enclosing closure")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
766#[diag("`{$name}` inside of a closure", code = E0267)]
767pub(crate) struct BreakInsideClosure<'a> {
768    #[primary_span]
769    #[label("cannot `{$name}` inside of a closure")]
770    pub span: Span,
771    #[label("enclosing closure")]
772    pub closure_span: Span,
773    pub name: &'a str,
774}
775
776#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            BreakInsideCoroutine<'a> where G: rustc_errors::EmissionGuarantee
            {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    BreakInsideCoroutine {
                        span: __binding_0,
                        coroutine_span: __binding_1,
                        name: __binding_2,
                        kind: __binding_3,
                        source: __binding_4 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` inside `{$kind}` {$source}")));
                        diag.code(E0267);
                        ;
                        diag.arg("name", __binding_2);
                        diag.arg("kind", __binding_3);
                        diag.arg("source", __binding_4);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot `{$name}` inside `{$kind}` {$source}")));
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("enclosing `{$kind}` {$source}")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
777#[diag("`{$name}` inside `{$kind}` {$source}", code = E0267)]
778pub(crate) struct BreakInsideCoroutine<'a> {
779    #[primary_span]
780    #[label("cannot `{$name}` inside `{$kind}` {$source}")]
781    pub span: Span,
782    #[label("enclosing `{$kind}` {$source}")]
783    pub coroutine_span: Span,
784    pub name: &'a str,
785    pub kind: &'a str,
786    pub source: &'a str,
787}
788
789#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            OutsideLoop<'a> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    OutsideLoop {
                        spans: __binding_0,
                        name: __binding_1,
                        is_break: __binding_2,
                        suggestion: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$name}` outside of a loop{$is_break ->\n        [true] {\" or labeled block\"}\n        *[false] {\"\"}\n    }")));
                        diag.code(E0268);
                        ;
                        diag.arg("name", __binding_1);
                        diag.arg("is_break", __binding_2);
                        diag.span(__binding_0.clone());
                        for __binding_0 in __binding_0 {
                            diag.span_label(__binding_0,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot `{$name}` outside of a loop{$is_break ->\n        [true] {\" or labeled block\"}\n        *[false] {\"\"}\n    }")));
                        }
                        if let Some(__binding_3) = __binding_3 {
                            diag.subdiagnostic(__binding_3);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
790#[diag("`{$name}` outside of a loop{$is_break ->
791        [true] {\" or labeled block\"}
792        *[false] {\"\"}
793    }", code = E0268)]
794pub(crate) struct OutsideLoop<'a> {
795    #[primary_span]
796    #[label(
797        "cannot `{$name}` outside of a loop{$is_break ->
798        [true] {\" or labeled block\"}
799        *[false] {\"\"}
800    }"
801    )]
802    pub spans: Vec<Span>,
803    pub name: &'a str,
804    pub is_break: bool,
805    #[subdiagnostic]
806    pub suggestion: Option<OutsideLoopSuggestion>,
807}
808#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for OutsideLoopSuggestion {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    OutsideLoopSuggestion {
                        block_span: __binding_0, break_spans: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_23 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("\'block: "))
                                });
                        let __code_24 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(" \'block"))
                                });
                        suggestions.push((__binding_0, __code_23));
                        for __binding_1 in __binding_1 {
                            suggestions.push((__binding_1, __code_24.clone()));
                        }
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider labeling this block to be able to break within it")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
809#[multipart_suggestion(
810    "consider labeling this block to be able to break within it",
811    applicability = "maybe-incorrect"
812)]
813pub(crate) struct OutsideLoopSuggestion {
814    #[suggestion_part(code = "'block: ")]
815    pub block_span: Span,
816    #[suggestion_part(code = " 'block")]
817    pub break_spans: Vec<Span>,
818}
819
820#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            UnlabeledInLabeledBlock<'a> where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnlabeledInLabeledBlock {
                        span: __binding_0, cf_type: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unlabeled `{$cf_type}` inside of a labeled block")));
                        diag.code(E0695);
                        ;
                        diag.arg("cf_type", __binding_1);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$cf_type}` statements that would diverge to or through a labeled block need to bear a label")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
821#[diag("unlabeled `{$cf_type}` inside of a labeled block", code = E0695)]
822pub(crate) struct UnlabeledInLabeledBlock<'a> {
823    #[primary_span]
824    #[label(
825        "`{$cf_type}` statements that would diverge to or through a labeled block need to bear a label"
826    )]
827    pub span: Span,
828    pub cf_type: &'a str,
829}
830
831#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            UnlabeledCfInWhileCondition<'a> where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnlabeledCfInWhileCondition {
                        span: __binding_0, cf_type: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`break` or `continue` with no label in the condition of a `while` loop")));
                        diag.code(E0590);
                        ;
                        diag.arg("cf_type", __binding_1);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unlabeled `{$cf_type}` in the condition of a `while` loop")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
832#[diag("`break` or `continue` with no label in the condition of a `while` loop", code = E0590)]
833pub(crate) struct UnlabeledCfInWhileCondition<'a> {
834    #[primary_span]
835    #[label("unlabeled `{$cf_type}` in the condition of a `while` loop")]
836    pub span: Span,
837    pub cf_type: &'a str,
838}
839
840#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            NoAssociatedItem<'tcx> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    NoAssociatedItem {
                        span: __binding_0,
                        item_kind: __binding_1,
                        item_ident: __binding_2,
                        ty_prefix: __binding_3,
                        ty: __binding_4,
                        trait_missing_method: __binding_5 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("no {$item_kind} named `{$item_ident}` found for {$ty_prefix} `{$ty}`{$trait_missing_method ->\n    [true] {\"\"}\n    *[other] {\" \"}in the current scope\n}")));
                        diag.code(E0599);
                        ;
                        diag.arg("item_kind", __binding_1);
                        diag.arg("item_ident", __binding_2);
                        diag.arg("ty_prefix", __binding_3);
                        diag.arg("ty", __binding_4);
                        diag.arg("trait_missing_method", __binding_5);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
841#[diag("no {$item_kind} named `{$item_ident}` found for {$ty_prefix} `{$ty}`{$trait_missing_method ->
842    [true] {\"\"}
843    *[other] {\" \"}in the current scope
844}", code = E0599)]
845pub(crate) struct NoAssociatedItem<'tcx> {
846    #[primary_span]
847    pub span: Span,
848    pub item_kind: &'static str,
849    pub item_ident: Ident,
850    pub ty_prefix: Cow<'static, str>,
851    pub ty: Ty<'tcx>,
852    pub trait_missing_method: bool,
853}
854
855#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for CandidateTraitNote {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    CandidateTraitNote {
                        span: __binding_0,
                        trait_name: __binding_1,
                        item_name: __binding_2,
                        action_or_ty: __binding_3 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("trait_name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("item_name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("action_or_ty".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$trait_name}` defines an item `{$item_name}`{$action_or_ty ->\n        [NONE] {\"\"}\n        [implement] , perhaps you need to implement it\n        *[other] , perhaps you need to restrict type parameter `{$action_or_ty}` with it\n    }")),
                                &sub_args);
                        diag.span_note(__binding_0, __message);
                    }
                }
            }
        }
    };Subdiagnostic)]
856#[note(
857    "`{$trait_name}` defines an item `{$item_name}`{$action_or_ty ->
858        [NONE] {\"\"}
859        [implement] , perhaps you need to implement it
860        *[other] , perhaps you need to restrict type parameter `{$action_or_ty}` with it
861    }"
862)]
863pub(crate) struct CandidateTraitNote {
864    #[primary_span]
865    pub span: Span,
866    pub trait_name: String,
867    pub item_name: Ident,
868    pub action_or_ty: String,
869}
870
871#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            CannotCastToBool<'tcx> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    CannotCastToBool {
                        span: __binding_0, expr_ty: __binding_1, help: __binding_2 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot cast `{$expr_ty}` as `bool`")));
                        diag.code(E0054);
                        ;
                        diag.arg("expr_ty", __binding_1);
                        diag.span(__binding_0);
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
872#[diag("cannot cast `{$expr_ty}` as `bool`", code = E0054)]
873pub(crate) struct CannotCastToBool<'tcx> {
874    #[primary_span]
875    pub span: Span,
876    pub expr_ty: Ty<'tcx>,
877    #[subdiagnostic]
878    pub help: CannotCastToBoolHelp,
879}
880
881#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            CastEnumDrop<'tcx> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    CastEnumDrop {
                        span: __binding_0,
                        expr_ty: __binding_1,
                        cast_ty: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot cast enum `{$expr_ty}` into integer `{$cast_ty}` because it implements `Drop`")));
                        ;
                        diag.arg("expr_ty", __binding_1);
                        diag.arg("cast_ty", __binding_2);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
882#[diag("cannot cast enum `{$expr_ty}` into integer `{$cast_ty}` because it implements `Drop`")]
883pub(crate) struct CastEnumDrop<'tcx> {
884    #[primary_span]
885    pub span: Span,
886    pub expr_ty: Ty<'tcx>,
887    pub cast_ty: Ty<'tcx>,
888}
889
890#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            CastUnknownPointer where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    CastUnknownPointer {
                        span: __binding_0, to: __binding_1, sub: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot cast {$to ->\n    [true] to\n    *[false] from\n} a pointer of an unknown kind")));
                        diag.code(E0641);
                        ;
                        diag.arg("to", __binding_1);
                        diag.span(__binding_0);
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
891#[diag("cannot cast {$to ->
892    [true] to
893    *[false] from
894} a pointer of an unknown kind", code = E0641)]
895pub(crate) struct CastUnknownPointer {
896    #[primary_span]
897    pub span: Span,
898    pub to: bool,
899    #[subdiagnostic]
900    pub sub: CastUnknownPointerSub,
901}
902
903pub(crate) enum CastUnknownPointerSub {
904    To(Span),
905    From(Span),
906}
907
908impl rustc_errors::Subdiagnostic for CastUnknownPointerSub {
909    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
910        match self {
911            CastUnknownPointerSub::To(span) => {
912                let msg = rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("needs more type information"))msg!("needs more type information");
913                diag.span_label(span, msg);
914                let msg = rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type information given here is insufficient to check whether the pointer cast is valid"))msg!(
915                    "the type information given here is insufficient to check whether the pointer cast is valid"
916                );
917                diag.note(msg);
918            }
919            CastUnknownPointerSub::From(span) => {
920                let msg = rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type information given here is insufficient to check whether the pointer cast is valid"))msg!(
921                    "the type information given here is insufficient to check whether the pointer cast is valid"
922                );
923                diag.span_label(span, msg);
924            }
925        }
926    }
927}
928
929#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for CannotCastToBoolHelp {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    CannotCastToBoolHelp::Numeric(__binding_0) => {
                        let __code_25 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(" != 0"))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("compare with zero instead")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_25, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    CannotCastToBoolHelp::Unsupported(__binding_0) => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unsupported cast")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                }
            }
        }
    };Subdiagnostic)]
930pub(crate) enum CannotCastToBoolHelp {
931    #[suggestion(
932        "compare with zero instead",
933        applicability = "machine-applicable",
934        code = " != 0",
935        style = "verbose"
936    )]
937    Numeric(#[primary_span] Span),
938    #[label("unsupported cast")]
939    Unsupported(#[primary_span] Span),
940}
941
942#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for CtorIsPrivate
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    CtorIsPrivate { span: __binding_0, def: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("tuple struct constructor `{$def}` is private")));
                        diag.code(E0603);
                        ;
                        diag.arg("def", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
943#[diag("tuple struct constructor `{$def}` is private", code = E0603)]
944pub(crate) struct CtorIsPrivate {
945    #[primary_span]
946    pub span: Span,
947    pub def: String,
948}
949
950#[derive(const _: () =
    {
        impl<'tcx> rustc_errors::Subdiagnostic for DerefImplsIsEmpty<'tcx> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    DerefImplsIsEmpty { span: __binding_0, deref_ty: __binding_1
                        } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("deref_ty".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this expression `Deref`s to `{$deref_ty}` which implements `is_empty`")),
                                &sub_args);
                        diag.span_note(__binding_0, __message);
                    }
                }
            }
        }
    };Subdiagnostic)]
951#[note("this expression `Deref`s to `{$deref_ty}` which implements `is_empty`")]
952pub(crate) struct DerefImplsIsEmpty<'tcx> {
953    #[primary_span]
954    pub span: Span,
955    pub deref_ty: Ty<'tcx>,
956}
957
958#[derive(const _: () =
    {
        impl<'tcx> rustc_errors::Subdiagnostic for
            SuggestConvertViaMethod<'tcx> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    SuggestConvertViaMethod {
                        span: __binding_0,
                        borrow_removal_span: __binding_1,
                        sugg: __binding_2,
                        expected: __binding_3,
                        found: __binding_4 } => {
                        let mut suggestions = Vec::new();
                        let __code_26 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{0}", __binding_2))
                                });
                        let __code_27 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(""))
                                });
                        suggestions.push((__binding_0, __code_26));
                        if let Some(__binding_1) = __binding_1 {
                            suggestions.push((__binding_1, __code_27));
                        }
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("sugg".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("expected".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        sub_args.insert("found".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using `{$sugg}` to convert `{$found}` to `{$expected}`")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
959#[multipart_suggestion(
960    "try using `{$sugg}` to convert `{$found}` to `{$expected}`",
961    applicability = "machine-applicable",
962    style = "verbose"
963)]
964pub(crate) struct SuggestConvertViaMethod<'tcx> {
965    #[suggestion_part(code = "{sugg}")]
966    pub span: Span,
967    #[suggestion_part(code = "")]
968    pub borrow_removal_span: Option<Span>,
969    pub sugg: String,
970    pub expected: Ty<'tcx>,
971    pub found: Ty<'tcx>,
972}
973
974#[derive(const _: () =
    {
        impl<'tcx> rustc_errors::Subdiagnostic for
            NoteCallerChoosesTyForTyParam<'tcx> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    NoteCallerChoosesTyForTyParam {
                        ty_param_name: __binding_0, found_ty: __binding_1 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("ty_param_name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("found_ty".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the caller chooses a type for `{$ty_param_name}` which can be different from `{$found_ty}`")),
                                &sub_args);
                        diag.note(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
975#[note(
976    "the caller chooses a type for `{$ty_param_name}` which can be different from `{$found_ty}`"
977)]
978pub(crate) struct NoteCallerChoosesTyForTyParam<'tcx> {
979    pub ty_param_name: Symbol,
980    pub found_ty: Ty<'tcx>,
981}
982
983#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for SuggestBoxingForReturnImplTrait {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    SuggestBoxingForReturnImplTrait::ChangeReturnType {
                        start_sp: __binding_0, end_sp: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_28 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("Box<dyn"))
                                });
                        let __code_29 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(">"))
                                });
                        suggestions.push((__binding_0, __code_28));
                        suggestions.push((__binding_1, __code_29));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you could change the return type to be a boxed trait object")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    SuggestBoxingForReturnImplTrait::BoxReturnExpr {
                        starts: __binding_0, ends: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_30 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("Box::new("))
                                });
                        let __code_31 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        for __binding_0 in __binding_0 {
                            suggestions.push((__binding_0, __code_30.clone()));
                        }
                        for __binding_1 in __binding_1 {
                            suggestions.push((__binding_1, __code_31.clone()));
                        }
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you change the return type to expect trait objects, box the returned expressions")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
984pub(crate) enum SuggestBoxingForReturnImplTrait {
985    #[multipart_suggestion(
986        "you could change the return type to be a boxed trait object",
987        applicability = "maybe-incorrect"
988    )]
989    ChangeReturnType {
990        #[suggestion_part(code = "Box<dyn")]
991        start_sp: Span,
992        #[suggestion_part(code = ">")]
993        end_sp: Span,
994    },
995    #[multipart_suggestion(
996        "if you change the return type to expect trait objects, box the returned expressions",
997        applicability = "maybe-incorrect"
998    )]
999    BoxReturnExpr {
1000        #[suggestion_part(code = "Box::new(")]
1001        starts: Vec<Span>,
1002        #[suggestion_part(code = ")")]
1003        ends: Vec<Span>,
1004    },
1005}
1006
1007#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SelfCtorFromOuterItem where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SelfCtorFromOuterItem {
                        span: __binding_0,
                        impl_span: __binding_1,
                        sugg: __binding_2,
                        item: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't reference `Self` constructor from outer item")));
                        diag.code(E0401);
                        ;
                        diag.span(__binding_0);
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference")));
                        if let Some(__binding_2) = __binding_2 {
                            diag.subdiagnostic(__binding_2);
                        }
                        if let Some(__binding_3) = __binding_3 {
                            diag.subdiagnostic(__binding_3);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1008#[diag("can't reference `Self` constructor from outer item", code = E0401)]
1009pub(crate) struct SelfCtorFromOuterItem {
1010    #[primary_span]
1011    pub span: Span,
1012    #[label(
1013        "the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference"
1014    )]
1015    pub impl_span: Span,
1016    #[subdiagnostic]
1017    pub sugg: Option<ReplaceWithName>,
1018    #[subdiagnostic]
1019    pub item: Option<InnerItem>,
1020}
1021
1022#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for InnerItem {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    InnerItem { span: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Self` used in this inner item")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                }
            }
        }
    };Subdiagnostic)]
1023#[label("`Self` used in this inner item")]
1024pub(crate) struct InnerItem {
1025    #[primary_span]
1026    pub span: Span,
1027}
1028
1029#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SelfCtorFromOuterItemLint where G: rustc_errors::EmissionGuarantee
            {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SelfCtorFromOuterItemLint {
                        impl_span: __binding_0, sugg: __binding_1, item: __binding_2
                        } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't reference `Self` constructor from outer item")));
                        ;
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference")));
                        if let Some(__binding_1) = __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        if let Some(__binding_2) = __binding_2 {
                            diag.subdiagnostic(__binding_2);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1030#[diag("can't reference `Self` constructor from outer item")]
1031pub(crate) struct SelfCtorFromOuterItemLint {
1032    #[label(
1033        "the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference"
1034    )]
1035    pub impl_span: Span,
1036    #[subdiagnostic]
1037    pub sugg: Option<ReplaceWithName>,
1038    #[subdiagnostic]
1039    pub item: Option<InnerItem>,
1040}
1041
1042#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for ReplaceWithName {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ReplaceWithName { span: __binding_0, name: __binding_1 } =>
                        {
                        let __code_32 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_1))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("replace `Self` with the actual type")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_32, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
1043#[suggestion(
1044    "replace `Self` with the actual type",
1045    code = "{name}",
1046    applicability = "machine-applicable"
1047)]
1048pub(crate) struct ReplaceWithName {
1049    #[primary_span]
1050    pub span: Span,
1051    pub name: String,
1052}
1053
1054#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            CastThinPointerToWidePointer<'tcx> where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    CastThinPointerToWidePointer {
                        span: __binding_0,
                        expr_ty: __binding_1,
                        cast_ty: __binding_2,
                        teach: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot cast thin pointer `{$expr_ty}` to wide pointer `{$cast_ty}`")));
                        diag.code(E0607);
                        ;
                        diag.arg("expr_ty", __binding_1);
                        diag.arg("cast_ty", __binding_2);
                        diag.span(__binding_0);
                        if __binding_3 {
                            diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("thin pointers are \"simple\" pointers: they are purely a reference to a\n        memory address.\n\n        Wide pointers are pointers referencing \"Dynamically Sized Types\" (also\n        called DST). DST don't have a statically known size, therefore they can\n        only exist behind some kind of pointers that contain additional\n        information. Slices and trait objects are DSTs. In the case of slices,\n        the additional information the wide pointer holds is their size.\n\n        To fix this error, don't try to cast directly between thin and wide\n        pointers.\n\n        For more information about casts, take a look at The Book:\n        https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions")));
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1055#[diag("cannot cast thin pointer `{$expr_ty}` to wide pointer `{$cast_ty}`", code = E0607)]
1056pub(crate) struct CastThinPointerToWidePointer<'tcx> {
1057    #[primary_span]
1058    pub span: Span,
1059    pub expr_ty: Ty<'tcx>,
1060    pub cast_ty: Ty<'tcx>,
1061    #[note(
1062        "thin pointers are \"simple\" pointers: they are purely a reference to a
1063        memory address.
1064
1065        Wide pointers are pointers referencing \"Dynamically Sized Types\" (also
1066        called DST). DST don't have a statically known size, therefore they can
1067        only exist behind some kind of pointers that contain additional
1068        information. Slices and trait objects are DSTs. In the case of slices,
1069        the additional information the wide pointer holds is their size.
1070
1071        To fix this error, don't try to cast directly between thin and wide
1072        pointers.
1073
1074        For more information about casts, take a look at The Book:
1075        https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions"
1076    )]
1077    pub(crate) teach: bool,
1078}
1079
1080#[derive(const _: () =
    {
        impl<'_sess, 'a, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            PassToVariadicFunction<'a, 'tcx> where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    PassToVariadicFunction {
                        span: __binding_0,
                        ty: __binding_1,
                        cast_ty: __binding_2,
                        sugg_span: __binding_3,
                        teach: __binding_4 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't pass `{$ty}` to variadic function")));
                        let __code_33 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(" as {0}", __binding_2))
                                            })].into_iter();
                        diag.code(E0617);
                        ;
                        diag.arg("ty", __binding_1);
                        diag.arg("cast_ty", __binding_2);
                        diag.span(__binding_0);
                        diag.span_suggestions_with_style(__binding_3,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cast the value to `{$cast_ty}`")),
                            __code_33, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                        if __binding_4 {
                            diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("certain types, like `{$ty}`, must be cast before passing them to a variadic function to match the implicit cast that a C compiler would perform as part of C's numeric promotion rules")));
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1081#[diag("can't pass `{$ty}` to variadic function", code = E0617)]
1082pub(crate) struct PassToVariadicFunction<'a, 'tcx> {
1083    #[primary_span]
1084    pub span: Span,
1085    pub ty: Ty<'tcx>,
1086    pub cast_ty: &'a str,
1087    #[suggestion(
1088        "cast the value to `{$cast_ty}`",
1089        code = " as {cast_ty}",
1090        applicability = "machine-applicable",
1091        style = "verbose"
1092    )]
1093    pub sugg_span: Span,
1094    #[note(
1095        "certain types, like `{$ty}`, must be cast before passing them to a variadic function to match the implicit cast that a C compiler would perform as part of C's numeric promotion rules"
1096    )]
1097    pub(crate) teach: bool,
1098}
1099
1100#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            PassFnItemToVariadicFunction where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    PassFnItemToVariadicFunction {
                        span: __binding_0,
                        sugg_span: __binding_1,
                        replace: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("can't pass a function item to a variadic function")));
                        let __code_34 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(" as {0}", __binding_2))
                                            })].into_iter();
                        diag.code(E0617);
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a function item is zero-sized and needs to be cast into a function pointer to be used in FFI")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information on function items, visit https://doc.rust-lang.org/reference/types/function-item.html")));
                        ;
                        diag.span(__binding_0);
                        diag.span_suggestions_with_style(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use a function pointer instead")),
                            __code_34, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1101#[diag("can't pass a function item to a variadic function", code = E0617)]
1102#[help(
1103    "a function item is zero-sized and needs to be cast into a function pointer to be used in FFI"
1104)]
1105#[note(
1106    "for more information on function items, visit https://doc.rust-lang.org/reference/types/function-item.html"
1107)]
1108pub(crate) struct PassFnItemToVariadicFunction {
1109    #[primary_span]
1110    pub span: Span,
1111    #[suggestion(
1112        "use a function pointer instead",
1113        code = " as {replace}",
1114        applicability = "machine-applicable",
1115        style = "verbose"
1116    )]
1117    pub sugg_span: Span,
1118    pub replace: String,
1119}
1120
1121#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for ReplaceCommaWithSemicolon {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ReplaceCommaWithSemicolon {
                        comma_span: __binding_0, descr: __binding_1 } => {
                        let __code_35 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("; "))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("descr".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("replace the comma with a semicolon to create {$descr}")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_35, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
1122#[suggestion(
1123    "replace the comma with a semicolon to create {$descr}",
1124    applicability = "machine-applicable",
1125    style = "verbose",
1126    code = "; "
1127)]
1128pub(crate) struct ReplaceCommaWithSemicolon {
1129    #[primary_span]
1130    pub comma_span: Span,
1131    pub descr: &'static str,
1132}
1133
1134#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SupertraitItemShadowing where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SupertraitItemShadowing {
                        item: __binding_0,
                        subtrait: __binding_1,
                        shadower: __binding_2,
                        shadowee: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("trait item `{$item}` from `{$subtrait}` shadows identically named item from supertrait")));
                        ;
                        diag.arg("item", __binding_0);
                        diag.arg("subtrait", __binding_1);
                        diag.subdiagnostic(__binding_2);
                        diag.subdiagnostic(__binding_3);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1135#[diag("trait item `{$item}` from `{$subtrait}` shadows identically named item from supertrait")]
1136pub(crate) struct SupertraitItemShadowing {
1137    pub item: Symbol,
1138    pub subtrait: Symbol,
1139    #[subdiagnostic]
1140    pub shadower: SupertraitItemShadower,
1141    #[subdiagnostic]
1142    pub shadowee: SupertraitItemShadowee,
1143}
1144
1145#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for SupertraitItemShadower {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    SupertraitItemShadower {
                        subtrait: __binding_0, span: __binding_1 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("subtrait".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("item from `{$subtrait}` shadows a supertrait item")),
                                &sub_args);
                        diag.span_note(__binding_1, __message);
                    }
                }
            }
        }
    };Subdiagnostic)]
1146#[note("item from `{$subtrait}` shadows a supertrait item")]
1147pub(crate) struct SupertraitItemShadower {
1148    pub subtrait: Symbol,
1149    #[primary_span]
1150    pub span: Span,
1151}
1152
1153#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for SupertraitItemShadowee {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    SupertraitItemShadowee::Labeled {
                        span: __binding_0, supertrait: __binding_1 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("supertrait".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("item from `{$supertrait}` is shadowed by a subtrait item")),
                                &sub_args);
                        diag.span_note(__binding_0, __message);
                    }
                    SupertraitItemShadowee::Several {
                        spans: __binding_0, traits: __binding_1 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("traits".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("items from several supertraits are shadowed: {$traits}")),
                                &sub_args);
                        diag.span_note(__binding_0, __message);
                    }
                }
            }
        }
    };Subdiagnostic)]
1154pub(crate) enum SupertraitItemShadowee {
1155    #[note("item from `{$supertrait}` is shadowed by a subtrait item")]
1156    Labeled {
1157        #[primary_span]
1158        span: Span,
1159        supertrait: Symbol,
1160    },
1161    #[note("items from several supertraits are shadowed: {$traits}")]
1162    Several {
1163        #[primary_span]
1164        spans: MultiSpan,
1165        traits: DiagSymbolList,
1166    },
1167}
1168
1169#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            RegisterTypeUnstable<'a> where G: rustc_errors::EmissionGuarantee
            {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    RegisterTypeUnstable { span: __binding_0, ty: __binding_1 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type `{$ty}` cannot be used with this register class in stable")));
                        ;
                        diag.arg("ty", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1170#[diag("type `{$ty}` cannot be used with this register class in stable")]
1171pub(crate) struct RegisterTypeUnstable<'a> {
1172    #[primary_span]
1173    pub span: Span,
1174    pub ty: Ty<'a>,
1175}
1176
1177#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            NakedAsmOutsideNakedFn where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    NakedAsmOutsideNakedFn { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]`")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1178#[diag("the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]`")]
1179pub(crate) struct NakedAsmOutsideNakedFn {
1180    #[primary_span]
1181    pub span: Span,
1182}
1183
1184#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for NoPatterns
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    NoPatterns { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("patterns not allowed in naked function parameters")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1185#[diag("patterns not allowed in naked function parameters")]
1186pub(crate) struct NoPatterns {
1187    #[primary_span]
1188    pub span: Span,
1189}
1190
1191#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ParamsNotAllowed where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ParamsNotAllowed { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("referencing function parameters is not allowed in naked functions")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("follow the calling convention in asm block to use parameters")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1192#[diag("referencing function parameters is not allowed in naked functions")]
1193#[help("follow the calling convention in asm block to use parameters")]
1194pub(crate) struct ParamsNotAllowed {
1195    #[primary_span]
1196    pub span: Span,
1197}
1198
1199pub(crate) struct NakedFunctionsAsmBlock {
1200    pub span: Span,
1201    pub multiple_asms: Vec<Span>,
1202    pub non_asms: Vec<Span>,
1203}
1204
1205impl<G: EmissionGuarantee> Diagnostic<'_, G> for NakedFunctionsAsmBlock {
1206    #[track_caller]
1207    fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
1208        let mut diag = Diag::new(
1209            dcx,
1210            level,
1211            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("naked functions must contain a single `naked_asm!` invocation"))msg!("naked functions must contain a single `naked_asm!` invocation"),
1212        );
1213        diag.span(self.span);
1214        diag.code(E0787);
1215        for span in self.multiple_asms.iter() {
1216            diag.span_label(
1217                *span,
1218                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("multiple `naked_asm!` invocations are not allowed in naked functions"))msg!("multiple `naked_asm!` invocations are not allowed in naked functions"),
1219            );
1220        }
1221        for span in self.non_asms.iter() {
1222            diag.span_label(*span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not allowed in naked functions"))msg!("not allowed in naked functions"));
1223        }
1224        diag
1225    }
1226}
1227
1228pub(crate) fn maybe_emit_plus_equals_diagnostic<'a>(
1229    fnctxt: &FnCtxt<'a, '_>,
1230    assign_op: Spanned<AssignOpKind>,
1231    lhs_expr: &hir::Expr<'_>,
1232) -> Result<(), Diag<'a>> {
1233    if assign_op.node == hir::AssignOpKind::AddAssign
1234        && let hir::ExprKind::Binary(bin_op, left, right) = &lhs_expr.kind
1235        && bin_op.node == hir::BinOpKind::And
1236        && crate::op::contains_let_in_chain(left)
1237        && let hir::ExprKind::Path(hir::QPath::Resolved(_, path)) = &right.kind
1238        && #[allow(non_exhaustive_omitted_patterns)] match path.res {
    hir::def::Res::Local(_) => true,
    _ => false,
}matches!(path.res, hir::def::Res::Local(_))
1239    {
1240        let mut err = fnctxt.dcx().struct_span_err(
1241            assign_op.span,
1242            "binary assignment operation `+=` cannot be used in a let chain",
1243        );
1244
1245        err.span_label(
1246            lhs_expr.span,
1247            "you are add-assigning the right-hand side expression to the result of this let-chain",
1248        );
1249
1250        err.span_label(assign_op.span, "cannot use `+=` in a let chain");
1251
1252        err.span_suggestion(
1253            assign_op.span,
1254            "you might have meant to compare with `==` instead of assigning with `+=`",
1255            "==",
1256            Applicability::MaybeIncorrect,
1257        );
1258
1259        return Err(err);
1260    }
1261    Ok(())
1262}
1263
1264#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            NakedFunctionsMustNakedAsm where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    NakedFunctionsMustNakedAsm { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `asm!` macro is not allowed in naked functions")));
                        diag.code(E0787);
                        ;
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using the `naked_asm!` macro instead")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1265#[diag("the `asm!` macro is not allowed in naked functions", code = E0787)]
1266pub(crate) struct NakedFunctionsMustNakedAsm {
1267    #[primary_span]
1268    #[label("consider using the `naked_asm!` macro instead")]
1269    pub span: Span,
1270}
1271
1272#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            AbiCannotBeCalled where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    AbiCannotBeCalled { span: __binding_0, abi: __binding_1 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions with the {$abi} ABI cannot be called")));
                        ;
                        diag.arg("abi", __binding_1);
                        diag.span(__binding_0);
                        diag.span_note(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an `extern {$abi}` function can only be called using inline assembly")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1273#[diag("functions with the {$abi} ABI cannot be called")]
1274pub(crate) struct AbiCannotBeCalled {
1275    #[primary_span]
1276    #[note("an `extern {$abi}` function can only be called using inline assembly")]
1277    pub span: Span,
1278    pub abi: ExternAbi,
1279}
1280
1281#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            GpuKernelAbiCannotBeCalled where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    GpuKernelAbiCannotBeCalled { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions with the \"gpu-kernel\" ABI cannot be called")));
                        ;
                        diag.span(__binding_0);
                        diag.span_note(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an `extern \"gpu-kernel\"` function must be launched on the GPU by the runtime")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1282#[diag("functions with the \"gpu-kernel\" ABI cannot be called")]
1283pub(crate) struct GpuKernelAbiCannotBeCalled {
1284    #[primary_span]
1285    #[note("an `extern \"gpu-kernel\"` function must be launched on the GPU by the runtime")]
1286    pub span: Span,
1287}
1288
1289#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ConstContinueBadLabel where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ConstContinueBadLabel { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`#[const_continue]` must break to a labeled block that participates in a `#[loop_match]`")));
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1290#[diag("`#[const_continue]` must break to a labeled block that participates in a `#[loop_match]`")]
1291pub(crate) struct ConstContinueBadLabel {
1292    #[primary_span]
1293    pub span: Span,
1294}
1295
1296#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ProjectOnNonPinProjectType where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ProjectOnNonPinProjectType {
                        span: __binding_0,
                        def_span: __binding_1,
                        sugg_span: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot project on type that is not `#[pin_v2]`")));
                        let __code_36 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("#[pin_v2]\n"))
                                            })].into_iter();
                        ;
                        diag.span(__binding_0);
                        if let Some(__binding_1) = __binding_1 {
                            diag.span_note(__binding_1,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type defined here")));
                        }
                        if let Some(__binding_2) = __binding_2 {
                            diag.span_suggestions_with_style(__binding_2,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#[pin_v2]` here")),
                                __code_36, rustc_errors::Applicability::MachineApplicable,
                                rustc_errors::SuggestionStyle::ShowCode);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1297#[diag("cannot project on type that is not `#[pin_v2]`")]
1298pub(crate) struct ProjectOnNonPinProjectType {
1299    #[primary_span]
1300    pub span: Span,
1301    #[note("type defined here")]
1302    pub def_span: Option<Span>,
1303    #[suggestion(
1304        "add `#[pin_v2]` here",
1305        code = "#[pin_v2]\n",
1306        applicability = "machine-applicable"
1307    )]
1308    pub sugg_span: Option<Span>,
1309}
1310
1311#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            FloatLiteralF32Fallback where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    FloatLiteralF32Fallback {
                        literal: __binding_0, span: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("falling back to `f32` as the trait bound `f32: From<f64>` is not satisfied")));
                        let __code_37 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}_f32", __binding_0))
                                            })].into_iter();
                        ;
                        if let Some(__binding_1) = __binding_1 {
                            diag.span_suggestions_with_style(__binding_1,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("explicitly specify the type as `f32`")),
                                __code_37, rustc_errors::Applicability::MachineApplicable,
                                rustc_errors::SuggestionStyle::ShowCode);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1312#[diag("falling back to `f32` as the trait bound `f32: From<f64>` is not satisfied")]
1313pub(crate) struct FloatLiteralF32Fallback {
1314    pub literal: String,
1315    #[suggestion(
1316        "explicitly specify the type as `f32`",
1317        code = "{literal}_f32",
1318        applicability = "machine-applicable"
1319    )]
1320    pub span: Option<Span>,
1321}