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