Skip to main content

rustc_hir_typeck/
errors.rs

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