Skip to main content

rustc_hir_typeck/
diagnostics.rs

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