Skip to main content

rustc_lint/
diagnostics.rs

1// ignore-tidy-file-filelength
2use std::num::NonZero;
3
4use rustc_data_structures::fx::FxIndexMap;
5use rustc_errors::codes::*;
6use rustc_errors::formatting::DiagMessageAddArg;
7use rustc_errors::{
8    Applicability, Diag, DiagCtxtHandle, DiagMessage, DiagStyledString, Diagnostic,
9    EmissionGuarantee, Level, Subdiagnostic, SuggestionStyle, msg,
10};
11use rustc_hir as hir;
12use rustc_hir::def_id::DefId;
13use rustc_hir::intravisit::Visitor;
14use rustc_macros::{Diagnostic, Subdiagnostic};
15use rustc_middle::ty::inhabitedness::InhabitedPredicate;
16use rustc_middle::ty::{Clause, PolyExistentialTraitRef, Ty, TyCtxt};
17use rustc_session::Session;
18use rustc_span::edition::Edition;
19use rustc_span::{Ident, Span, Symbol, sym};
20
21use crate::LateContext;
22use crate::builtin::{InitError, ShorthandAssocTyCollector, TypeAliasBounds};
23use crate::lifetime_syntax::LifetimeSyntaxCategories;
24
25#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            OverruledAttribute<'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 {
                    OverruledAttribute {
                        span: __binding_0,
                        overruled: __binding_1,
                        lint_level: __binding_2,
                        lint_source: __binding_3,
                        sub: __binding_4 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$lint_level}({$lint_source}) incompatible with previous forbid")));
                        diag.code(E0453);
                        ;
                        diag.arg("lint_level", __binding_2);
                        diag.arg("lint_source", __binding_3);
                        diag.span(__binding_0);
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("overruled by previous forbid")));
                        diag.subdiagnostic(__binding_4);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
26#[diag("{$lint_level}({$lint_source}) incompatible with previous forbid", code = E0453)]
27pub(crate) struct OverruledAttribute<'a> {
28    #[primary_span]
29    pub span: Span,
30    #[label("overruled by previous forbid")]
31    pub overruled: Span,
32    pub lint_level: &'a str,
33    pub lint_source: Symbol,
34    #[subdiagnostic]
35    pub sub: OverruledAttributeSub,
36}
37
38pub(crate) enum OverruledAttributeSub {
39    DefaultSource { id: String },
40    NodeSource { span: Span, reason: Option<Symbol> },
41    CommandLineSource { id: Symbol },
42}
43
44impl Subdiagnostic for OverruledAttributeSub {
45    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
46        match self {
47            OverruledAttributeSub::DefaultSource { id } => {
48                diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`forbid` lint level is the default for {$id}"))msg!("`forbid` lint level is the default for {$id}"));
49                diag.arg("id", id);
50            }
51            OverruledAttributeSub::NodeSource { span, reason } => {
52                diag.span_label(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`forbid` level set here"))msg!("`forbid` level set here"));
53                if let Some(rationale) = reason {
54                    diag.note(rationale.to_string());
55                }
56            }
57            OverruledAttributeSub::CommandLineSource { id } => {
58                diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`forbid` lint level was set on command line (`-F {$id}`)"))msg!("`forbid` lint level was set on command line (`-F {$id}`)"));
59                diag.arg("id", id);
60            }
61        }
62    }
63}
64
65#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            MalformedAttribute 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 {
                    MalformedAttribute { span: __binding_0, sub: __binding_1 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("malformed lint attribute input")));
                        diag.code(E0452);
                        ;
                        diag.span(__binding_0);
                        diag.subdiagnostic(__binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
66#[diag("malformed lint attribute input", code = E0452)]
67pub(crate) struct MalformedAttribute {
68    #[primary_span]
69    pub span: Span,
70    #[subdiagnostic]
71    pub sub: MalformedAttributeSub,
72}
73
74#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for MalformedAttributeSub {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    MalformedAttributeSub::BadAttributeArgument(__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("bad attribute argument")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                    MalformedAttributeSub::ReasonMustBeStringLiteral(__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("reason must be a string literal")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                    MalformedAttributeSub::ReasonMustComeLast(__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("reason in lint attribute must come last")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                }
            }
        }
    };Subdiagnostic)]
75pub(crate) enum MalformedAttributeSub {
76    #[label("bad attribute argument")]
77    BadAttributeArgument(#[primary_span] Span),
78    #[label("reason must be a string literal")]
79    ReasonMustBeStringLiteral(#[primary_span] Span),
80    #[label("reason in lint attribute must come last")]
81    ReasonMustComeLast(#[primary_span] Span),
82}
83
84#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnknownToolInScopedLint 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 {
                    UnknownToolInScopedLint {
                        span: __binding_0,
                        tool_name: __binding_1,
                        lint_name: __binding_2,
                        is_nightly_build: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown tool name `{$tool_name}` found in scoped lint: `{$tool_name}::{$lint_name}`")));
                        diag.code(E0710);
                        ;
                        diag.arg("tool_name", __binding_1);
                        diag.arg("lint_name", __binding_2);
                        if let Some(__binding_0) = __binding_0 {
                            diag.span(__binding_0);
                        }
                        if __binding_3 {
                            diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#![register_tool({$tool_name})]` to the crate root")));
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
85#[diag("unknown tool name `{$tool_name}` found in scoped lint: `{$tool_name}::{$lint_name}`", code = E0710)]
86pub(crate) struct UnknownToolInScopedLint {
87    #[primary_span]
88    pub span: Option<Span>,
89    pub tool_name: Symbol,
90    pub lint_name: String,
91    #[help("add `#![register_tool({$tool_name})]` to the crate root")]
92    pub is_nightly_build: bool,
93}
94
95#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinNoMangleGeneric 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 {
                    BuiltinNoMangleGeneric {
                        span: __binding_0, suggestion: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("functions generic over types or consts must be mangled")));
                        let __code_2 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(""))
                                            })].into_iter();
                        ;
                        diag.span(__binding_0);
                        diag.span_suggestions_with_style(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this attribute")),
                            __code_2, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::HideCodeInline);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
96#[diag("functions generic over types or consts must be mangled")]
97pub(crate) struct BuiltinNoMangleGeneric {
98    #[primary_span]
99    pub span: Span,
100    // Use of `#[no_mangle]` suggests FFI intent; correct
101    // fix may be to monomorphize source by hand
102    #[suggestion(
103        "remove this attribute",
104        style = "short",
105        code = "",
106        applicability = "maybe-incorrect"
107    )]
108    pub suggestion: Span,
109}
110
111#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinEllipsisInclusiveRangePatterns 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 {
                    BuiltinEllipsisInclusiveRangePatterns {
                        span: __binding_0,
                        suggestion: __binding_1,
                        replace: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`...` range patterns are deprecated")));
                        let __code_3 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_2))
                                            })].into_iter();
                        diag.code(E0783);
                        ;
                        diag.span(__binding_0);
                        diag.span_suggestions_with_style(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `..=` for an inclusive range")),
                            __code_3, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::HideCodeInline);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
112#[diag("`...` range patterns are deprecated", code = E0783)]
113pub(crate) struct BuiltinEllipsisInclusiveRangePatterns {
114    #[primary_span]
115    pub span: Span,
116    #[suggestion(
117        "use `..=` for an inclusive range",
118        style = "short",
119        code = "{replace}",
120        applicability = "machine-applicable"
121    )]
122    pub suggestion: Span,
123    pub replace: String,
124}
125
126#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for RequestedLevel<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    RequestedLevel { level: __binding_0, lint_name: __binding_1
                        } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("level".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("lint_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("requested on the command line with `{$level} {$lint_name}`")),
                                &sub_args);
                        diag.note(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
127#[note("requested on the command line with `{$level} {$lint_name}`")]
128pub(crate) struct RequestedLevel<'a> {
129    pub level: rustc_lint_defs::Level,
130    pub lint_name: &'a str,
131}
132
133#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnsupportedGroup 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 {
                    UnsupportedGroup { lint_group: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$lint_group}` lint group is not supported with ´--force-warn´")));
                        diag.code(E0602);
                        ;
                        diag.arg("lint_group", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
134#[diag("`{$lint_group}` lint group is not supported with ´--force-warn´", code = E0602)]
135pub(crate) struct UnsupportedGroup {
136    pub lint_group: String,
137}
138
139#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            CheckNameUnknownTool<'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 {
                    CheckNameUnknownTool {
                        tool_name: __binding_0, sub: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown lint tool: `{$tool_name}`")));
                        diag.code(E0602);
                        ;
                        diag.arg("tool_name", __binding_0);
                        diag.subdiagnostic(__binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
140#[diag("unknown lint tool: `{$tool_name}`", code = E0602)]
141pub(crate) struct CheckNameUnknownTool<'a> {
142    pub tool_name: Symbol,
143    #[subdiagnostic]
144    pub sub: RequestedLevel<'a>,
145}
146
147// array_into_iter.rs
148#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ShadowedIntoIterDiag 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 {
                    ShadowedIntoIterDiag {
                        target: __binding_0,
                        edition: __binding_1,
                        suggestion: __binding_2,
                        sub: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this method call resolves to `<&{$target} as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to `<{$target} as IntoIterator>::into_iter` in Rust {$edition}")));
                        let __code_4 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("iter"))
                                            })].into_iter();
                        ;
                        diag.arg("target", __binding_0);
                        diag.arg("edition", __binding_1);
                        diag.span_suggestions_with_style(__binding_2,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `.iter()` instead of `.into_iter()` to avoid ambiguity")),
                            __code_4, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                        if let Some(__binding_3) = __binding_3 {
                            diag.subdiagnostic(__binding_3);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
149#[diag(
150    "this method call resolves to `<&{$target} as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to `<{$target} as IntoIterator>::into_iter` in Rust {$edition}"
151)]
152pub(crate) struct ShadowedIntoIterDiag {
153    pub target: &'static str,
154    pub edition: &'static str,
155    #[suggestion(
156        "use `.iter()` instead of `.into_iter()` to avoid ambiguity",
157        code = "iter",
158        applicability = "machine-applicable"
159    )]
160    pub suggestion: Span,
161    #[subdiagnostic]
162    pub sub: Option<ShadowedIntoIterDiagSub>,
163}
164
165#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for ShadowedIntoIterDiagSub {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ShadowedIntoIterDiagSub::RemoveIntoIter { span: __binding_0
                        } => {
                        let __code_5 =
                            [::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("or remove `.into_iter()` to iterate by value")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_5, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    ShadowedIntoIterDiagSub::UseExplicitIntoIter {
                        start_span: __binding_0, end_span: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_6 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("IntoIterator::into_iter("))
                                });
                        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("or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
166pub(crate) enum ShadowedIntoIterDiagSub {
167    #[suggestion(
168        "or remove `.into_iter()` to iterate by value",
169        code = "",
170        applicability = "maybe-incorrect"
171    )]
172    RemoveIntoIter {
173        #[primary_span]
174        span: Span,
175    },
176    #[multipart_suggestion(
177        "or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value",
178        applicability = "maybe-incorrect"
179    )]
180    UseExplicitIntoIter {
181        #[suggestion_part(code = "IntoIterator::into_iter(")]
182        start_span: Span,
183        #[suggestion_part(code = ")")]
184        end_span: Span,
185    },
186}
187
188// autorefs.rs
189#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            ImplicitUnsafeAutorefsDiag<'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 {
                    ImplicitUnsafeAutorefsDiag {
                        raw_ptr_span: __binding_0,
                        raw_ptr_ty: __binding_1,
                        origin: __binding_2,
                        method: __binding_3,
                        suggestion: __binding_4 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implicit autoref creates a reference to the dereference of a raw pointer")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("creating a reference requires the pointer target to be valid and imposes aliasing requirements")));
                        ;
                        diag.arg("raw_ptr_ty", __binding_1);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this raw pointer has type `{$raw_ptr_ty}`")));
                        diag.subdiagnostic(__binding_2);
                        if let Some(__binding_3) = __binding_3 {
                            diag.subdiagnostic(__binding_3);
                        }
                        diag.subdiagnostic(__binding_4);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
190#[diag("implicit autoref creates a reference to the dereference of a raw pointer")]
191#[note(
192    "creating a reference requires the pointer target to be valid and imposes aliasing requirements"
193)]
194pub(crate) struct ImplicitUnsafeAutorefsDiag<'a> {
195    #[label("this raw pointer has type `{$raw_ptr_ty}`")]
196    pub raw_ptr_span: Span,
197    pub raw_ptr_ty: Ty<'a>,
198    #[subdiagnostic]
199    pub origin: ImplicitUnsafeAutorefsOrigin<'a>,
200    #[subdiagnostic]
201    pub method: Option<ImplicitUnsafeAutorefsMethodNote>,
202    #[subdiagnostic]
203    pub suggestion: ImplicitUnsafeAutorefsSuggestion,
204}
205
206#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for
            ImplicitUnsafeAutorefsOrigin<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ImplicitUnsafeAutorefsOrigin::Autoref {
                        autoref_span: __binding_0, autoref_ty: __binding_1 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("autoref_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("autoref is being applied to this expression, resulting in: `{$autoref_ty}`")),
                                &sub_args);
                        diag.span_note(__binding_0, __message);
                    }
                    ImplicitUnsafeAutorefsOrigin::OverloadedDeref => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("references are created through calls to explicit `Deref(Mut)::deref(_mut)` implementations")),
                                &sub_args);
                        diag.note(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
207pub(crate) enum ImplicitUnsafeAutorefsOrigin<'a> {
208    #[note("autoref is being applied to this expression, resulting in: `{$autoref_ty}`")]
209    Autoref {
210        #[primary_span]
211        autoref_span: Span,
212        autoref_ty: Ty<'a>,
213    },
214    #[note(
215        "references are created through calls to explicit `Deref(Mut)::deref(_mut)` implementations"
216    )]
217    OverloadedDeref,
218}
219
220#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for ImplicitUnsafeAutorefsMethodNote
            {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ImplicitUnsafeAutorefsMethodNote {
                        def_span: __binding_0, method_name: __binding_1 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("method_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("method calls to `{$method_name}` require a reference")),
                                &sub_args);
                        diag.span_note(__binding_0, __message);
                    }
                }
            }
        }
    };Subdiagnostic)]
221#[note("method calls to `{$method_name}` require a reference")]
222pub(crate) struct ImplicitUnsafeAutorefsMethodNote {
223    #[primary_span]
224    pub def_span: Span,
225    pub method_name: Symbol,
226}
227
228#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for ImplicitUnsafeAutorefsSuggestion
            {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ImplicitUnsafeAutorefsSuggestion {
                        mutbl: __binding_0,
                        deref: __binding_1,
                        start_span: __binding_2,
                        end_span: __binding_3 } => {
                        let mut suggestions = Vec::new();
                        let __code_8 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("({1}{0}", __binding_1,
                                            __binding_0))
                                });
                        let __code_9 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        suggestions.push((__binding_2, __code_8));
                        suggestions.push((__binding_3, __code_9));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using a raw pointer method instead; or if this reference is intentional, make it explicit")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
229#[multipart_suggestion(
230    "try using a raw pointer method instead; or if this reference is intentional, make it explicit",
231    applicability = "maybe-incorrect"
232)]
233pub(crate) struct ImplicitUnsafeAutorefsSuggestion {
234    pub mutbl: &'static str,
235    pub deref: &'static str,
236    #[suggestion_part(code = "({mutbl}{deref}")]
237    pub start_span: Span,
238    #[suggestion_part(code = ")")]
239    pub end_span: Span,
240}
241
242// builtin.rs
243#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinWhileTrue 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 {
                    BuiltinWhileTrue {
                        suggestion: __binding_0, replace: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("denote infinite loops with `loop {\"{\"} ... {\"}\"}`")));
                        let __code_10 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_1))
                                            })].into_iter();
                        ;
                        diag.span_suggestions_with_style(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `loop`")),
                            __code_10, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::HideCodeInline);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
244#[diag("denote infinite loops with `loop {\"{\"} ... {\"}\"}`")]
245pub(crate) struct BuiltinWhileTrue {
246    #[suggestion(
247        "use `loop`",
248        style = "short",
249        code = "{replace}",
250        applicability = "machine-applicable"
251    )]
252    pub suggestion: Span,
253    pub replace: String,
254}
255
256#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinNonShorthandFieldPatterns 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 {
                    BuiltinNonShorthandFieldPatterns {
                        ident: __binding_0,
                        suggestion: __binding_1,
                        prefix: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `{$ident}:` in this pattern is redundant")));
                        let __code_11 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{1}{0}", __binding_0,
                                                        __binding_2))
                                            })].into_iter();
                        ;
                        diag.arg("ident", __binding_0);
                        diag.span_suggestions_with_style(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use shorthand field pattern")),
                            __code_11, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
257#[diag("the `{$ident}:` in this pattern is redundant")]
258pub(crate) struct BuiltinNonShorthandFieldPatterns {
259    pub ident: Ident,
260    #[suggestion(
261        "use shorthand field pattern",
262        code = "{prefix}{ident}",
263        applicability = "machine-applicable"
264    )]
265    pub suggestion: Span,
266    pub prefix: &'static str,
267}
268
269#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for BuiltinUnsafe
            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 {
                    BuiltinUnsafe::AllowInternalUnsafe => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`allow_internal_unsafe` allows defining macros using unsafe without triggering the `unsafe_code` lint at their call site")));
                        ;
                        diag
                    }
                    BuiltinUnsafe::UnsafeBlock => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("usage of an `unsafe` block")));
                        ;
                        diag
                    }
                    BuiltinUnsafe::UnsafeExternBlock => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("usage of an `unsafe extern` block")));
                        ;
                        diag
                    }
                    BuiltinUnsafe::UnsafeTrait => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("declaration of an `unsafe` trait")));
                        ;
                        diag
                    }
                    BuiltinUnsafe::UnsafeImpl => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementation of an `unsafe` trait")));
                        ;
                        diag
                    }
                    BuiltinUnsafe::DeclUnsafeFn => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("declaration of an `unsafe` function")));
                        ;
                        diag
                    }
                    BuiltinUnsafe::DeclUnsafeMethod => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("declaration of an `unsafe` method")));
                        ;
                        diag
                    }
                    BuiltinUnsafe::ImplUnsafeMethod => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementation of an `unsafe` method")));
                        ;
                        diag
                    }
                    BuiltinUnsafe::GlobalAsm => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("usage of `core::arch::global_asm`")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using this macro is unsafe even though it does not need an `unsafe` block")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
270pub(crate) enum BuiltinUnsafe {
271    #[diag(
272        "`allow_internal_unsafe` allows defining macros using unsafe without triggering the `unsafe_code` lint at their call site"
273    )]
274    AllowInternalUnsafe,
275    #[diag("usage of an `unsafe` block")]
276    UnsafeBlock,
277    #[diag("usage of an `unsafe extern` block")]
278    UnsafeExternBlock,
279    #[diag("declaration of an `unsafe` trait")]
280    UnsafeTrait,
281    #[diag("implementation of an `unsafe` trait")]
282    UnsafeImpl,
283    #[diag("declaration of an `unsafe` function")]
284    DeclUnsafeFn,
285    #[diag("declaration of an `unsafe` method")]
286    DeclUnsafeMethod,
287    #[diag("implementation of an `unsafe` method")]
288    ImplUnsafeMethod,
289    #[diag("usage of `core::arch::global_asm`")]
290    #[note("using this macro is unsafe even though it does not need an `unsafe` block")]
291    GlobalAsm,
292}
293
294#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinMissingDoc<'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 {
                    BuiltinMissingDoc { article: __binding_0, desc: __binding_1
                        } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("missing documentation for {$article} {$desc}")));
                        ;
                        diag.arg("article", __binding_0);
                        diag.arg("desc", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
295#[diag("missing documentation for {$article} {$desc}")]
296pub(crate) struct BuiltinMissingDoc<'a> {
297    pub article: &'a str,
298    pub desc: &'a str,
299}
300
301#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinMissingCopyImpl 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 {
                    BuiltinMissingCopyImpl => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type could implement `Copy`; consider adding `impl Copy`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
302#[diag("type could implement `Copy`; consider adding `impl Copy`")]
303pub(crate) struct BuiltinMissingCopyImpl;
304
305pub(crate) struct BuiltinMissingDebugImpl<'a> {
306    pub tcx: TyCtxt<'a>,
307    pub def_id: DefId,
308}
309
310// Needed for def_path_str
311impl<'a> Diagnostic<'a, ()> for BuiltinMissingDebugImpl<'_> {
312    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
313        let Self { tcx, def_id } = self;
314        Diag::new(
315            dcx,
316            level,
317            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type does not implement `{$debug}`; consider adding `#[derive(Debug)]` or a manual implementation"))msg!("type does not implement `{$debug}`; consider adding `#[derive(Debug)]` or a manual implementation"),
318        ).with_arg("debug", tcx.def_path_str(def_id))
319    }
320}
321
322#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinAnonymousParams<'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 {
                    BuiltinAnonymousParams {
                        suggestion: __binding_0, ty_snip: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("anonymous parameters are deprecated and will be removed in the next edition")));
                        let __code_12 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("_: {0}", __binding_1))
                                            })].into_iter();
                        ;
                        diag.span_suggestions_with_style(__binding_0.0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try naming the parameter or explicitly ignoring it")),
                            __code_12, __binding_0.1,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
323#[diag("anonymous parameters are deprecated and will be removed in the next edition")]
324pub(crate) struct BuiltinAnonymousParams<'a> {
325    #[suggestion("try naming the parameter or explicitly ignoring it", code = "_: {ty_snip}")]
326    pub suggestion: (Span, Applicability),
327    pub ty_snip: &'a str,
328}
329
330#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinUnusedDocComment<'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 {
                    BuiltinUnusedDocComment {
                        kind: __binding_0, label: __binding_1, sub: __binding_2 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused doc comment")));
                        ;
                        diag.arg("kind", __binding_0);
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("rustdoc does not generate documentation for {$kind}")));
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
331#[diag("unused doc comment")]
332pub(crate) struct BuiltinUnusedDocComment<'a> {
333    pub kind: &'a str,
334    #[label("rustdoc does not generate documentation for {$kind}")]
335    pub label: Span,
336    #[subdiagnostic]
337    pub sub: BuiltinUnusedDocCommentSub,
338}
339
340#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for BuiltinUnusedDocCommentSub {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    BuiltinUnusedDocCommentSub::PlainHelp => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `//` for a plain comment")),
                                &sub_args);
                        diag.help(__message);
                    }
                    BuiltinUnusedDocCommentSub::BlockHelp => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `/* */` for a plain comment")),
                                &sub_args);
                        diag.help(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
341pub(crate) enum BuiltinUnusedDocCommentSub {
342    #[help("use `//` for a plain comment")]
343    PlainHelp,
344    #[help("use `/* */` for a plain comment")]
345    BlockHelp,
346}
347
348#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinConstNoMangle 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 {
                    BuiltinConstNoMangle { suggestion: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("const items should never be `#[no_mangle]`")));
                        let __code_13 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("pub static "))
                                            })].into_iter();
                        ;
                        if let Some(__binding_0) = __binding_0 {
                            diag.span_suggestions_with_style(__binding_0,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try a static value")),
                                __code_13, rustc_errors::Applicability::MachineApplicable,
                                rustc_errors::SuggestionStyle::ShowCode);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
349#[diag("const items should never be `#[no_mangle]`")]
350pub(crate) struct BuiltinConstNoMangle {
351    #[suggestion("try a static value", code = "pub static ", applicability = "machine-applicable")]
352    pub suggestion: Option<Span>,
353}
354
355#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinMutablesTransmutes 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 {
                    BuiltinMutablesTransmutes => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("transmuting &T to &mut T is undefined behavior, even if the reference is unused, consider instead using an UnsafeCell")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
356#[diag(
357    "transmuting &T to &mut T is undefined behavior, even if the reference is unused, consider instead using an UnsafeCell"
358)]
359pub(crate) struct BuiltinMutablesTransmutes;
360
361#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinUnstableFeatures 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 {
                    BuiltinUnstableFeatures => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of an unstable feature")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
362#[diag("use of an unstable feature")]
363pub(crate) struct BuiltinUnstableFeatures;
364
365// lint_ungated_async_fn_track_caller
366pub(crate) struct BuiltinUngatedAsyncFnTrackCaller<'a> {
367    pub label: Span,
368    pub session: &'a Session,
369}
370
371impl<'a> Diagnostic<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
372    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
373        let mut diag = Diag::new(dcx, level, "`#[track_caller]` on async functions is a no-op")
374            .with_span_label(self.label, "this function will not propagate the caller location");
375        rustc_session::diagnostics::add_feature_diagnostics(
376            &mut diag,
377            self.session,
378            sym::async_fn_track_caller,
379        );
380        diag
381    }
382}
383
384#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinUnreachablePub<'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 {
                    BuiltinUnreachablePub {
                        what: __binding_0,
                        new_vis: __binding_1,
                        suggestion: __binding_2,
                        help: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unreachable `pub` {$what}")));
                        let __code_14 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_1))
                                            })].into_iter();
                        ;
                        diag.arg("what", __binding_0);
                        diag.span_suggestions_with_style(__binding_2.0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider restricting its visibility")),
                            __code_14, __binding_2.1,
                            rustc_errors::SuggestionStyle::ShowCode);
                        if __binding_3 {
                            diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("or consider exporting it for use by other crates")));
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
385#[diag("unreachable `pub` {$what}")]
386pub(crate) struct BuiltinUnreachablePub<'a> {
387    pub what: &'a str,
388    pub new_vis: &'a str,
389    #[suggestion("consider restricting its visibility", code = "{new_vis}")]
390    pub suggestion: (Span, Applicability),
391    #[help("or consider exporting it for use by other crates")]
392    pub help: bool,
393}
394
395#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            MacroExprFragment2024 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 {
                    MacroExprFragment2024 { suggestion: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `expr` fragment specifier will accept more expressions in the 2024 edition")));
                        let __code_15 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("expr_2021"))
                                            })].into_iter();
                        ;
                        diag.span_suggestions_with_style(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to keep the existing behavior, use the `expr_2021` fragment specifier")),
                            __code_15, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
396#[diag("the `expr` fragment specifier will accept more expressions in the 2024 edition")]
397pub(crate) struct MacroExprFragment2024 {
398    #[suggestion(
399        "to keep the existing behavior, use the `expr_2021` fragment specifier",
400        code = "expr_2021",
401        applicability = "machine-applicable"
402    )]
403    pub suggestion: Span,
404}
405
406pub(crate) struct BuiltinTypeAliasBounds<'hir> {
407    pub in_where_clause: bool,
408    pub label: Span,
409    pub enable_feat_help: bool,
410    pub suggestions: Vec<(Span, String)>,
411    pub preds: &'hir [hir::WherePredicate<'hir>],
412    pub ty: Option<&'hir hir::Ty<'hir>>,
413}
414
415impl<'a> Diagnostic<'a, ()> for BuiltinTypeAliasBounds<'_> {
416    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
417        let mut diag = Diag::new(dcx, level, if self.in_where_clause {
418            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("where clauses on type aliases are not enforced"))msg!("where clauses on type aliases are not enforced")
419        } else {
420            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bounds on generic parameters in type aliases are not enforced"))msg!("bounds on generic parameters in type aliases are not enforced")
421        })
422            .with_span_label(self.label, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("will not be checked at usage sites of the type alias"))msg!("will not be checked at usage sites of the type alias"))
423            .with_note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is a known limitation of the type checker that may be lifted in a future edition.\n                see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information"))msg!(
424                "this is a known limitation of the type checker that may be lifted in a future edition.
425                see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information"
426            ));
427        if self.enable_feat_help {
428            diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `#![feature(checked_type_aliases)]` to the crate attributes to enable the desired semantics"))msg!("add `#![feature(checked_type_aliases)]` to the crate attributes to enable the desired semantics"));
429        }
430
431        // We perform the walk in here instead of in `<TypeAliasBounds as LateLintPass>` to
432        // avoid doing throwaway work in case the lint ends up getting suppressed.
433        let mut collector = ShorthandAssocTyCollector { qselves: Vec::new() };
434        if let Some(ty) = self.ty {
435            collector.visit_ty_unambig(ty);
436        }
437
438        let affect_object_lifetime_defaults = self
439            .preds
440            .iter()
441            .filter(|pred| pred.kind.in_where_clause() == self.in_where_clause)
442            .any(|pred| TypeAliasBounds::affects_object_lifetime_defaults(pred));
443
444        // If there are any shorthand assoc tys, then the bounds can't be removed automatically.
445        // The user first needs to fully qualify the assoc tys.
446        let applicability = if !collector.qselves.is_empty() || affect_object_lifetime_defaults {
447            Applicability::MaybeIncorrect
448        } else {
449            Applicability::MachineApplicable
450        };
451
452        diag.arg("count", self.suggestions.len());
453        diag.multipart_suggestion(
454            if self.in_where_clause {
455                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this where clause"))msg!("remove this where clause")
456            } else {
457                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove {$count ->\n                        [one] this bound\n                        *[other] these bounds\n                    }"))msg!(
458                    "remove {$count ->
459                        [one] this bound
460                        *[other] these bounds
461                    }"
462                )
463            },
464            self.suggestions,
465            applicability,
466        );
467
468        // Suggest fully qualifying paths of the form `T::Assoc` with `T` type param via
469        // `<T as /* Trait */>::Assoc` to remove their reliance on any type param bounds.
470        //
471        // Instead of attempting to figure out the necessary trait ref, just use a
472        // placeholder. Since we don't record type-dependent resolutions for non-body
473        // items like type aliases, we can't simply deduce the corresp. trait from
474        // the HIR path alone without rerunning parts of HIR ty lowering here
475        // (namely `probe_single_ty_param_bound_for_assoc_ty`) which is infeasible.
476        //
477        // (We could employ some simple heuristics but that's likely not worth it).
478        for qself in collector.qselves {
479            diag.multipart_suggestion(
480                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("fully qualify this associated type"))msg!("fully qualify this associated type"),
481                ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
        [(qself.shrink_to_lo(), "<".into()),
                (qself.shrink_to_hi(), " as /* Trait */>".into())]))vec![
482                    (qself.shrink_to_lo(), "<".into()),
483                    (qself.shrink_to_hi(), " as /* Trait */>".into()),
484                ],
485                Applicability::HasPlaceholders,
486            );
487        }
488        diag
489    }
490}
491
492#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinTrivialBounds<'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 {
                    BuiltinTrivialBounds {
                        clause_kind_name: __binding_0, clause: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$clause_kind_name} bound {$clause} does not depend on any type or lifetime parameters")));
                        ;
                        diag.arg("clause_kind_name", __binding_0);
                        diag.arg("clause", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
493#[diag("{$clause_kind_name} bound {$clause} does not depend on any type or lifetime parameters")]
494pub(crate) struct BuiltinTrivialBounds<'a> {
495    pub clause_kind_name: &'a str,
496    pub clause: Clause<'a>,
497}
498
499#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinDoubleNegations 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 {
                    BuiltinDoubleNegations { add_parens: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of a double negation")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the prefix `--` could be misinterpreted as a decrement operator which exists in other languages")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `-= 1` if you meant to decrement the value")));
                        ;
                        diag.subdiagnostic(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
500#[diag("use of a double negation")]
501#[note(
502    "the prefix `--` could be misinterpreted as a decrement operator which exists in other languages"
503)]
504#[note("use `-= 1` if you meant to decrement the value")]
505pub(crate) struct BuiltinDoubleNegations {
506    #[subdiagnostic]
507    pub add_parens: BuiltinDoubleNegationsAddParens,
508}
509
510#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for BuiltinDoubleNegationsAddParens {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    BuiltinDoubleNegationsAddParens {
                        start_span: __binding_0, end_span: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_16 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("("))
                                });
                        let __code_17 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        suggestions.push((__binding_0, __code_16));
                        suggestions.push((__binding_1, __code_17));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add parentheses for clarity")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
511#[multipart_suggestion("add parentheses for clarity", applicability = "maybe-incorrect")]
512pub(crate) struct BuiltinDoubleNegationsAddParens {
513    #[suggestion_part(code = "(")]
514    pub start_span: Span,
515    #[suggestion_part(code = ")")]
516    pub end_span: Span,
517}
518
519#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinEllipsisInclusiveRangePatternsLint 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 {
                    BuiltinEllipsisInclusiveRangePatternsLint::Parenthesise {
                        suggestion: __binding_0, replace: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`...` range patterns are deprecated")));
                        let __code_18 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_1))
                                            })].into_iter();
                        ;
                        diag.span_suggestions_with_style(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `..=` for an inclusive range")),
                            __code_18, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag
                    }
                    BuiltinEllipsisInclusiveRangePatternsLint::NonParenthesise {
                        suggestion: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`...` range patterns are deprecated")));
                        let __code_19 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("..="))
                                            })].into_iter();
                        ;
                        diag.span_suggestions_with_style(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `..=` for an inclusive range")),
                            __code_19, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::HideCodeInline);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
520pub(crate) enum BuiltinEllipsisInclusiveRangePatternsLint {
521    #[diag("`...` range patterns are deprecated")]
522    Parenthesise {
523        #[suggestion(
524            "use `..=` for an inclusive range",
525            code = "{replace}",
526            applicability = "machine-applicable"
527        )]
528        suggestion: Span,
529        replace: String,
530    },
531    #[diag("`...` range patterns are deprecated")]
532    NonParenthesise {
533        #[suggestion(
534            "use `..=` for an inclusive range",
535            style = "short",
536            code = "..=",
537            applicability = "machine-applicable"
538        )]
539        suggestion: Span,
540    },
541}
542
543#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinKeywordIdents 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 {
                    BuiltinKeywordIdents {
                        kw: __binding_0,
                        next: __binding_1,
                        suggestion: __binding_2,
                        prefix: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$kw}` is a keyword in the {$next} edition")));
                        let __code_20 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{1}r#{0}", __binding_0,
                                                        __binding_3))
                                            })].into_iter();
                        ;
                        diag.arg("kw", __binding_0);
                        diag.arg("next", __binding_1);
                        diag.span_suggestions_with_style(__binding_2,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you can use a raw identifier to stay compatible")),
                            __code_20, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
544#[diag("`{$kw}` is a keyword in the {$next} edition")]
545pub(crate) struct BuiltinKeywordIdents {
546    pub kw: Ident,
547    pub next: Edition,
548    #[suggestion(
549        "you can use a raw identifier to stay compatible",
550        code = "{prefix}r#{kw}",
551        applicability = "machine-applicable"
552    )]
553    pub suggestion: Span,
554    pub prefix: &'static str,
555}
556
557#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinExplicitOutlives 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 {
                    BuiltinExplicitOutlives { suggestion: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("outlives requirements can be inferred")));
                        ;
                        diag.subdiagnostic(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
558#[diag("outlives requirements can be inferred")]
559pub(crate) struct BuiltinExplicitOutlives {
560    #[subdiagnostic]
561    pub suggestion: BuiltinExplicitOutlivesSuggestion,
562}
563
564#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for BuiltinExplicitOutlivesSuggestion
            {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    BuiltinExplicitOutlivesSuggestion {
                        spans: __binding_0,
                        applicability: __binding_1,
                        count: __binding_2 } => {
                        let mut suggestions = Vec::new();
                        let __code_21 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(""))
                                });
                        for __binding_0 in __binding_0 {
                            suggestions.push((__binding_0, __code_21.clone()));
                        }
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("count".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("remove {$count ->\n        [one] this bound\n        *[other] these bounds\n    }")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            __binding_1, rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
565#[multipart_suggestion(
566    "remove {$count ->
567        [one] this bound
568        *[other] these bounds
569    }"
570)]
571pub(crate) struct BuiltinExplicitOutlivesSuggestion {
572    #[suggestion_part(code = "")]
573    pub spans: Vec<Span>,
574    #[applicability]
575    pub applicability: Applicability,
576    pub count: usize,
577}
578
579#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinIncompleteFeatures 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 {
                    BuiltinIncompleteFeatures {
                        name: __binding_0, note: __binding_1, help: __binding_2 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the feature `{$name}` is incomplete and may not be safe to use and/or cause compiler crashes")));
                        ;
                        diag.arg("name", __binding_0);
                        if let Some(__binding_1) = __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        if let Some(__binding_2) = __binding_2 {
                            diag.subdiagnostic(__binding_2);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
580#[diag(
581    "the feature `{$name}` is incomplete and may not be safe to use and/or cause compiler crashes"
582)]
583pub(crate) struct BuiltinIncompleteFeatures {
584    pub name: Symbol,
585    #[subdiagnostic]
586    pub note: Option<BuiltinFeatureIssueNote>,
587    #[subdiagnostic]
588    pub help: Option<BuiltinIncompleteFeaturesHelp>,
589}
590
591#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinInternalFeatures 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 {
                    BuiltinInternalFeatures { name: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the feature `{$name}` is internal to the compiler or standard library")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using it is strongly discouraged")));
                        ;
                        diag.arg("name", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
592#[diag("the feature `{$name}` is internal to the compiler or standard library")]
593#[note("using it is strongly discouraged")]
594pub(crate) struct BuiltinInternalFeatures {
595    pub name: Symbol,
596}
597
598#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for BuiltinIncompleteFeaturesHelp {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    BuiltinIncompleteFeaturesHelp { name: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("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("consider using `min_{$name}` instead, which is more stable and complete")),
                                &sub_args);
                        diag.help(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
599#[help("consider using `min_{$name}` instead, which is more stable and complete")]
600pub(crate) struct BuiltinIncompleteFeaturesHelp {
601    pub name: Symbol,
602}
603
604#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for BuiltinFeatureIssueNote {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    BuiltinFeatureIssueNote { n: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("n".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("see issue #{$n} <https://github.com/rust-lang/rust/issues/{$n}> for more information")),
                                &sub_args);
                        diag.note(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
605#[note("see issue #{$n} <https://github.com/rust-lang/rust/issues/{$n}> for more information")]
606pub(crate) struct BuiltinFeatureIssueNote {
607    pub n: NonZero<u32>,
608}
609
610pub(crate) struct BuiltinUnpermittedTypeInit<'a> {
611    pub msg: DiagMessage,
612    pub ty: Ty<'a>,
613    pub label: Span,
614    pub sub: BuiltinUnpermittedTypeInitSub,
615    pub tcx: TyCtxt<'a>,
616}
617
618impl<'a> Diagnostic<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
619    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
620        let mut diag = Diag::new(dcx, level, self.msg)
621            .with_arg("ty", self.ty)
622            .with_span_label(self.label, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this code causes undefined behavior when executed"))msg!("this code causes undefined behavior when executed"));
623        if let InhabitedPredicate::True = self.ty.inhabited_predicate(self.tcx) {
624            // Only suggest late `MaybeUninit::assume_init` initialization if the type is inhabited.
625            diag.span_label(
626                self.label,
627                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done"))msg!("help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done"),
628            );
629        }
630        self.sub.add_to_diag(&mut diag);
631        diag
632    }
633}
634
635// FIXME(davidtwco): make translatable
636pub(crate) struct BuiltinUnpermittedTypeInitSub {
637    pub err: InitError,
638}
639
640impl Subdiagnostic for BuiltinUnpermittedTypeInitSub {
641    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
642        let mut err = self.err;
643        loop {
644            if let Some(span) = err.span {
645                diag.span_note(span, err.message);
646            } else {
647                diag.note(err.message);
648            }
649            if let Some(e) = err.nested {
650                err = *e;
651            } else {
652                break;
653            }
654        }
655    }
656}
657
658#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinClashingExtern<'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 {
                    BuiltinClashingExtern::SameName {
                        this: __binding_0,
                        orig: __binding_1,
                        previous_decl_label: __binding_2,
                        mismatch_label: __binding_3,
                        sub: __binding_4 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$this}` redeclared with a different signature")));
                        ;
                        diag.arg("this", __binding_0);
                        diag.arg("orig", __binding_1);
                        diag.span_label(__binding_2,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$orig}` previously declared here")));
                        diag.span_label(__binding_3,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this signature doesn't match the previous declaration")));
                        diag.subdiagnostic(__binding_4);
                        diag
                    }
                    BuiltinClashingExtern::DiffName {
                        this: __binding_0,
                        orig: __binding_1,
                        previous_decl_label: __binding_2,
                        mismatch_label: __binding_3,
                        sub: __binding_4 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$this}` redeclares `{$orig}` with a different signature")));
                        ;
                        diag.arg("this", __binding_0);
                        diag.arg("orig", __binding_1);
                        diag.span_label(__binding_2,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$orig}` previously declared here")));
                        diag.span_label(__binding_3,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this signature doesn't match the previous declaration")));
                        diag.subdiagnostic(__binding_4);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
659pub(crate) enum BuiltinClashingExtern<'a> {
660    #[diag("`{$this}` redeclared with a different signature")]
661    SameName {
662        this: Symbol,
663        orig: Symbol,
664        #[label("`{$orig}` previously declared here")]
665        previous_decl_label: Span,
666        #[label("this signature doesn't match the previous declaration")]
667        mismatch_label: Span,
668        #[subdiagnostic]
669        sub: BuiltinClashingExternSub<'a>,
670    },
671    #[diag("`{$this}` redeclares `{$orig}` with a different signature")]
672    DiffName {
673        this: Symbol,
674        orig: Symbol,
675        #[label("`{$orig}` previously declared here")]
676        previous_decl_label: Span,
677        #[label("this signature doesn't match the previous declaration")]
678        mismatch_label: Span,
679        #[subdiagnostic]
680        sub: BuiltinClashingExternSub<'a>,
681    },
682}
683
684// FIXME(davidtwco): translatable expected/found
685pub(crate) struct BuiltinClashingExternSub<'a> {
686    pub tcx: TyCtxt<'a>,
687    pub expected: Ty<'a>,
688    pub found: Ty<'a>,
689}
690
691impl Subdiagnostic for BuiltinClashingExternSub<'_> {
692    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
693        let mut expected_str = DiagStyledString::new();
694        expected_str.push(self.expected.fn_sig(self.tcx).to_string(), false);
695        let mut found_str = DiagStyledString::new();
696        found_str.push(self.found.fn_sig(self.tcx).to_string(), true);
697        diag.note_expected_found("", expected_str, "", found_str);
698    }
699}
700
701#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinDerefNullptr 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 {
                    BuiltinDerefNullptr { label: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("dereferencing a null pointer")));
                        ;
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this code causes undefined behavior when executed")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
702#[diag("dereferencing a null pointer")]
703pub(crate) struct BuiltinDerefNullptr {
704    #[label("this code causes undefined behavior when executed")]
705    pub label: Span,
706}
707
708#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BuiltinSpecialModuleNameUsed 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 {
                    BuiltinSpecialModuleNameUsed::Lib => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found module declaration for lib.rs")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lib.rs is the root of this crate's library target")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to refer to it from other targets, use the library's name as the path")));
                        ;
                        diag
                    }
                    BuiltinSpecialModuleNameUsed::Main => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found module declaration for main.rs")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a binary crate cannot be used as library")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
709pub(crate) enum BuiltinSpecialModuleNameUsed {
710    #[diag("found module declaration for lib.rs")]
711    #[note("lib.rs is the root of this crate's library target")]
712    #[help("to refer to it from other targets, use the library's name as the path")]
713    Lib,
714    #[diag("found module declaration for main.rs")]
715    #[note("a binary crate cannot be used as library")]
716    Main,
717}
718
719// c_void_return.rs
720#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for CVoidReturn
            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 {
                    CVoidReturn { suggestion: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`c_void` should not be used as a return type")));
                        let __code_22 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(""))
                                            })].into_iter();
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("returning `()` in Rust is equivalent to returning `void` in C")));
                        ;
                        diag.span_suggestions_with_style(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the return type to implicitly return `()`")),
                            __code_22, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
721#[diag("`c_void` should not be used as a return type")]
722#[help("returning `()` in Rust is equivalent to returning `void` in C")]
723pub(crate) struct CVoidReturn {
724    #[suggestion(
725        "remove the return type to implicitly return `()`",
726        code = "",
727        applicability = "maybe-incorrect"
728    )]
729    pub suggestion: Span,
730}
731
732// c_void_return.rs
733#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ExternCVoidReturn 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 {
                    ExternCVoidReturn { suggestion: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("declarations returning `c_void` are not compatible with C functions returning `void`")));
                        let __code_23 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(""))
                                            })].into_iter();
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("returning `()` in Rust is equivalent to returning `void` in C")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`c_void` is only used through raw pointers for compatibility with `void` pointers")));
                        ;
                        diag.span_suggestions_with_style(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the return type to implicitly return `()`")),
                            __code_23, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
734#[diag("declarations returning `c_void` are not compatible with C functions returning `void`")]
735#[help("returning `()` in Rust is equivalent to returning `void` in C")]
736#[note("`c_void` is only used through raw pointers for compatibility with `void` pointers")]
737pub(crate) struct ExternCVoidReturn {
738    #[suggestion(
739        "remove the return type to implicitly return `()`",
740        code = "",
741        applicability = "maybe-incorrect"
742    )]
743    pub suggestion: Span,
744}
745
746// deref_into_dyn_supertrait.rs
747#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            SupertraitAsDerefTarget<'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 {
                    SupertraitAsDerefTarget {
                        self_ty: __binding_0,
                        supertrait_principal: __binding_1,
                        target_principal: __binding_2,
                        label: __binding_3,
                        label2: __binding_4 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this `Deref` implementation is covered by an implicit supertrait coercion")));
                        ;
                        diag.arg("self_ty", __binding_0);
                        diag.arg("supertrait_principal", __binding_1);
                        diag.arg("target_principal", __binding_2);
                        diag.span_label(__binding_3,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$self_ty}` implements `Deref<Target = dyn {$target_principal}>` which conflicts with supertrait `{$supertrait_principal}`")));
                        if let Some(__binding_4) = __binding_4 {
                            diag.subdiagnostic(__binding_4);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
748#[diag("this `Deref` implementation is covered by an implicit supertrait coercion")]
749pub(crate) struct SupertraitAsDerefTarget<'a> {
750    pub self_ty: Ty<'a>,
751    pub supertrait_principal: PolyExistentialTraitRef<'a>,
752    pub target_principal: PolyExistentialTraitRef<'a>,
753    #[label(
754        "`{$self_ty}` implements `Deref<Target = dyn {$target_principal}>` which conflicts with supertrait `{$supertrait_principal}`"
755    )]
756    pub label: Span,
757    #[subdiagnostic]
758    pub label2: Option<SupertraitAsDerefTargetLabel<'a>>,
759}
760
761#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for
            SupertraitAsDerefTargetLabel<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    SupertraitAsDerefTargetLabel {
                        label: __binding_0, self_ty: __binding_1 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("self_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("target type is a supertrait of `{$self_ty}`")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                }
            }
        }
    };Subdiagnostic)]
762#[label("target type is a supertrait of `{$self_ty}`")]
763pub(crate) struct SupertraitAsDerefTargetLabel<'a> {
764    #[primary_span]
765    pub label: Span,
766    pub self_ty: Ty<'a>,
767}
768
769// enum_intrinsics_non_enums.rs
770#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            EnumIntrinsicsMemDiscriminate<'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 {
                    EnumIntrinsicsMemDiscriminate {
                        ty_param: __binding_0, note: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the return value of `mem::discriminant` is unspecified when called with a non-enum type")));
                        ;
                        diag.arg("ty_param", __binding_0);
                        diag.span_note(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `{$ty_param}`, which is not an enum")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
771#[diag("the return value of `mem::discriminant` is unspecified when called with a non-enum type")]
772pub(crate) struct EnumIntrinsicsMemDiscriminate<'a> {
773    pub ty_param: Ty<'a>,
774    #[note(
775        "the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `{$ty_param}`, which is not an enum"
776    )]
777    pub note: Span,
778}
779
780#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            EnumIntrinsicsMemVariant<'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 {
                    EnumIntrinsicsMemVariant { ty_param: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the return value of `mem::variant_count` is unspecified when called with a non-enum type")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type parameter of `variant_count` should be an enum, but it was instantiated with the type `{$ty_param}`, which is not an enum")));
                        ;
                        diag.arg("ty_param", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
781#[diag("the return value of `mem::variant_count` is unspecified when called with a non-enum type")]
782#[note(
783    "the type parameter of `variant_count` should be an enum, but it was instantiated with the type `{$ty_param}`, which is not an enum"
784)]
785pub(crate) struct EnumIntrinsicsMemVariant<'a> {
786    pub ty_param: Ty<'a>,
787}
788
789// expect.rs
790#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for Expectation
            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 {
                    Expectation { rationale: __binding_0, note: __binding_1 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this lint expectation is unfulfilled")));
                        ;
                        if let Some(__binding_0) = __binding_0 {
                            diag.subdiagnostic(__binding_0);
                        }
                        if __binding_1 {
                            diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message")));
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
791#[diag("this lint expectation is unfulfilled")]
792pub(crate) struct Expectation {
793    #[subdiagnostic]
794    pub rationale: Option<ExpectationNote>,
795    #[note(
796        "the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message"
797    )]
798    pub note: bool,
799}
800
801#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for ExpectationNote {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ExpectationNote { rationale: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("rationale".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("{$rationale}")),
                                &sub_args);
                        diag.note(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
802#[note("{$rationale}")]
803pub(crate) struct ExpectationNote {
804    pub rationale: Symbol,
805}
806
807// ptr_nulls.rs
808#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            UselessPtrNullChecksDiag<'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 {
                    UselessPtrNullChecksDiag::FnPtr {
                        orig_ty: __binding_0, label: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function pointers are not nullable, so checking them for null will always return false")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value")));
                        ;
                        diag.arg("orig_ty", __binding_0);
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expression has type `{$orig_ty}`")));
                        diag
                    }
                    UselessPtrNullChecksDiag::Ref {
                        orig_ty: __binding_0, label: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("references are not nullable, so checking them for null will always return false")));
                        ;
                        diag.arg("orig_ty", __binding_0);
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expression has type `{$orig_ty}`")));
                        diag
                    }
                    UselessPtrNullChecksDiag::FnRet { fn_name: __binding_0 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("returned pointer of `{$fn_name}` call is never null, so checking it for null will always return false")));
                        ;
                        diag.arg("fn_name", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
809pub(crate) enum UselessPtrNullChecksDiag<'a> {
810    #[diag(
811        "function pointers are not nullable, so checking them for null will always return false"
812    )]
813    #[help(
814        "wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value"
815    )]
816    FnPtr {
817        orig_ty: Ty<'a>,
818        #[label("expression has type `{$orig_ty}`")]
819        label: Span,
820    },
821    #[diag("references are not nullable, so checking them for null will always return false")]
822    Ref {
823        orig_ty: Ty<'a>,
824        #[label("expression has type `{$orig_ty}`")]
825        label: Span,
826    },
827    #[diag(
828        "returned pointer of `{$fn_name}` call is never null, so checking it for null will always return false"
829    )]
830    FnRet { fn_name: Ident },
831}
832
833#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidNullArgumentsDiag 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 {
                    InvalidNullArgumentsDiag::NullPtrInline {
                        null_span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calling this function with a null pointer is undefined behavior, even if the result of the function is unused")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, visit <https://doc.rust-lang.org/std/ptr/index.html> and <https://doc.rust-lang.org/reference/behavior-considered-undefined.html>")));
                        ;
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("null pointer originates from here")));
                        diag
                    }
                    InvalidNullArgumentsDiag::NullPtrThroughBinding {
                        null_span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calling this function with a null pointer is undefined behavior, even if the result of the function is unused")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, visit <https://doc.rust-lang.org/std/ptr/index.html> and <https://doc.rust-lang.org/reference/behavior-considered-undefined.html>")));
                        ;
                        diag.span_note(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("null pointer originates from here")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
834pub(crate) enum InvalidNullArgumentsDiag {
835    #[diag(
836        "calling this function with a null pointer is undefined behavior, even if the result of the function is unused"
837    )]
838    #[help(
839        "for more information, visit <https://doc.rust-lang.org/std/ptr/index.html> and <https://doc.rust-lang.org/reference/behavior-considered-undefined.html>"
840    )]
841    NullPtrInline {
842        #[label("null pointer originates from here")]
843        null_span: Span,
844    },
845    #[diag(
846        "calling this function with a null pointer is undefined behavior, even if the result of the function is unused"
847    )]
848    #[help(
849        "for more information, visit <https://doc.rust-lang.org/std/ptr/index.html> and <https://doc.rust-lang.org/reference/behavior-considered-undefined.html>"
850    )]
851    NullPtrThroughBinding {
852        #[note("null pointer originates from here")]
853        null_span: Span,
854    },
855}
856
857// for_loops_over_fallibles.rs
858#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            ForLoopsOverFalliblesDiag<'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 {
                    ForLoopsOverFalliblesDiag {
                        article: __binding_0,
                        ref_prefix: __binding_1,
                        ty: __binding_2,
                        sub: __binding_3,
                        question_mark: __binding_4,
                        suggestion: __binding_5 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for loop over {$article} `{$ref_prefix}{$ty}`. This is more readably written as an `if let` statement")));
                        ;
                        diag.arg("article", __binding_0);
                        diag.arg("ref_prefix", __binding_1);
                        diag.arg("ty", __binding_2);
                        diag.subdiagnostic(__binding_3);
                        if let Some(__binding_4) = __binding_4 {
                            diag.subdiagnostic(__binding_4);
                        }
                        diag.subdiagnostic(__binding_5);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
859#[diag(
860    "for loop over {$article} `{$ref_prefix}{$ty}`. This is more readably written as an `if let` statement"
861)]
862pub(crate) struct ForLoopsOverFalliblesDiag<'a> {
863    pub article: &'static str,
864    pub ref_prefix: &'static str,
865    pub ty: &'static str,
866    #[subdiagnostic]
867    pub sub: ForLoopsOverFalliblesLoopSub<'a>,
868    #[subdiagnostic]
869    pub question_mark: Option<ForLoopsOverFalliblesQuestionMark>,
870    #[subdiagnostic]
871    pub suggestion: ForLoopsOverFalliblesSuggestion<'a>,
872}
873
874#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for
            ForLoopsOverFalliblesLoopSub<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ForLoopsOverFalliblesLoopSub::RemoveNext {
                        suggestion: __binding_0, recv_snip: __binding_1 } => {
                        let __code_24 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(".by_ref()"))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("recv_snip".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("to iterate over `{$recv_snip}` remove the call to `next`")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_24, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    ForLoopsOverFalliblesLoopSub::UseWhileLet {
                        start_span: __binding_0,
                        end_span: __binding_1,
                        var: __binding_2 } => {
                        let mut suggestions = Vec::new();
                        let __code_25 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("while let {0}(",
                                            __binding_2))
                                });
                        let __code_26 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(") = "))
                                });
                        suggestions.push((__binding_0, __code_25));
                        suggestions.push((__binding_1, __code_26));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("to check pattern in a loop use `while let`")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
875pub(crate) enum ForLoopsOverFalliblesLoopSub<'a> {
876    #[suggestion(
877        "to iterate over `{$recv_snip}` remove the call to `next`",
878        code = ".by_ref()",
879        applicability = "maybe-incorrect"
880    )]
881    RemoveNext {
882        #[primary_span]
883        suggestion: Span,
884        recv_snip: String,
885    },
886    #[multipart_suggestion(
887        "to check pattern in a loop use `while let`",
888        applicability = "maybe-incorrect"
889    )]
890    UseWhileLet {
891        #[suggestion_part(code = "while let {var}(")]
892        start_span: Span,
893        #[suggestion_part(code = ") = ")]
894        end_span: Span,
895        var: &'a str,
896    },
897}
898
899#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for ForLoopsOverFalliblesQuestionMark
            {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ForLoopsOverFalliblesQuestionMark { suggestion: __binding_0
                        } => {
                        let __code_27 =
                            [::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 unwrapping the `Result` with `?` to iterate over its contents")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_27, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
900#[suggestion(
901    "consider unwrapping the `Result` with `?` to iterate over its contents",
902    code = "?",
903    applicability = "maybe-incorrect"
904)]
905pub(crate) struct ForLoopsOverFalliblesQuestionMark {
906    #[primary_span]
907    pub suggestion: Span,
908}
909
910#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for
            ForLoopsOverFalliblesSuggestion<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ForLoopsOverFalliblesSuggestion {
                        var: __binding_0,
                        start_span: __binding_1,
                        end_span: __binding_2 } => {
                        let mut suggestions = Vec::new();
                        let __code_28 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("if let {0}(",
                                            __binding_0))
                                });
                        let __code_29 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(") = "))
                                });
                        suggestions.push((__binding_1, __code_28));
                        suggestions.push((__binding_2, __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("consider using `if let` to clear intent")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
911#[multipart_suggestion(
912    "consider using `if let` to clear intent",
913    applicability = "maybe-incorrect"
914)]
915pub(crate) struct ForLoopsOverFalliblesSuggestion<'a> {
916    pub var: &'a str,
917    #[suggestion_part(code = "if let {var}(")]
918    pub start_span: Span,
919    #[suggestion_part(code = ") = ")]
920    pub end_span: Span,
921}
922
923#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for UseLetUnderscoreIgnoreSuggestion
            {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    UseLetUnderscoreIgnoreSuggestion::Note => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `let _ = ...` to ignore the expression or result")),
                                &sub_args);
                        diag.note(__message);
                    }
                    UseLetUnderscoreIgnoreSuggestion::Suggestion {
                        start_span: __binding_0, end_span: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_30 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("let _ = "))
                                });
                        let __code_31 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(""))
                                });
                        suggestions.push((__binding_0, __code_30));
                        suggestions.push((__binding_1, __code_31));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `let _ = ...` to ignore the expression or result")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
924pub(crate) enum UseLetUnderscoreIgnoreSuggestion {
925    #[note("use `let _ = ...` to ignore the expression or result")]
926    Note,
927    #[multipart_suggestion(
928        "use `let _ = ...` to ignore the expression or result",
929        style = "verbose",
930        applicability = "maybe-incorrect"
931    )]
932    Suggestion {
933        #[suggestion_part(code = "let _ = ")]
934        start_span: Span,
935        #[suggestion_part(code = "")]
936        end_span: Span,
937    },
938}
939
940// runtime_symbols.rs
941#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            RedefiningRuntimeSymbolsDiag<'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 {
                    RedefiningRuntimeSymbolsDiag::Invalid {
                        symbol_name: __binding_0,
                        expected_fn_sig: __binding_1,
                        found_fn_sig: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid definition of the runtime `{$symbol_name}` symbol used by the standard library")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `{$expected_fn_sig}` (for the current target)\n    found    `{$found_fn_sig}`")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = \"{$symbol_name}\")]`, or `#[link_name = \"{$symbol_name}\"]`")));
                        ;
                        diag.arg("symbol_name", __binding_0);
                        diag.arg("expected_fn_sig", __binding_1);
                        diag.arg("found_fn_sig", __binding_2);
                        diag
                    }
                    RedefiningRuntimeSymbolsDiag::Suspicious {
                        symbol_name: __binding_0,
                        expected_fn_sig: __binding_1,
                        found_fn_sig: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("suspicious definition of the runtime `{$symbol_name}` symbol used by the standard library")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `{$expected_fn_sig}` (for the current target)\n    found    `{$found_fn_sig}`")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = \"{$symbol_name}\")]`, or `#[link_name = \"{$symbol_name}\"]`")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("allow this lint if the signature is compatible")));
                        ;
                        diag.arg("symbol_name", __binding_0);
                        diag.arg("expected_fn_sig", __binding_1);
                        diag.arg("found_fn_sig", __binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
942pub(crate) enum RedefiningRuntimeSymbolsDiag<'tcx> {
943    #[diag(
944        "invalid definition of the runtime `{$symbol_name}` symbol used by the standard library"
945    )]
946    #[note(
947        "expected `{$expected_fn_sig}` (for the current target)
948    found    `{$found_fn_sig}`"
949    )]
950    #[help(
951        "either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = \"{$symbol_name}\")]`, or `#[link_name = \"{$symbol_name}\"]`"
952    )]
953    Invalid { symbol_name: String, expected_fn_sig: Ty<'tcx>, found_fn_sig: Ty<'tcx> },
954    #[diag(
955        "suspicious definition of the runtime `{$symbol_name}` symbol used by the standard library"
956    )]
957    #[note(
958        "expected `{$expected_fn_sig}` (for the current target)
959    found    `{$found_fn_sig}`"
960    )]
961    #[help(
962        "either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = \"{$symbol_name}\")]`, or `#[link_name = \"{$symbol_name}\"]`"
963    )]
964    #[help("allow this lint if the signature is compatible")]
965    Suspicious { symbol_name: String, expected_fn_sig: Ty<'tcx>, found_fn_sig: Ty<'tcx> },
966}
967
968// drop_forget_useless.rs
969#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            DropRefDiag<'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 {
                    DropRefDiag {
                        arg_ty: __binding_0, label: __binding_1, sugg: __binding_2 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calls to `std::mem::drop` with a reference instead of an owned value does nothing")));
                        ;
                        diag.arg("arg_ty", __binding_0);
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("argument has type `{$arg_ty}`")));
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
970#[diag("calls to `std::mem::drop` with a reference instead of an owned value does nothing")]
971pub(crate) struct DropRefDiag<'a> {
972    pub arg_ty: Ty<'a>,
973    #[label("argument has type `{$arg_ty}`")]
974    pub label: Span,
975    #[subdiagnostic]
976    pub sugg: UseLetUnderscoreIgnoreSuggestion,
977}
978
979#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            DropCopyDiag<'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 {
                    DropCopyDiag {
                        arg_ty: __binding_0, label: __binding_1, sugg: __binding_2 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calls to `std::mem::drop` with a value that implements `Copy` does nothing")));
                        ;
                        diag.arg("arg_ty", __binding_0);
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("argument has type `{$arg_ty}`")));
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
980#[diag("calls to `std::mem::drop` with a value that implements `Copy` does nothing")]
981pub(crate) struct DropCopyDiag<'a> {
982    pub arg_ty: Ty<'a>,
983    #[label("argument has type `{$arg_ty}`")]
984    pub label: Span,
985    #[subdiagnostic]
986    pub sugg: UseLetUnderscoreIgnoreSuggestion,
987}
988
989#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            DropInPlaceRefDiag<'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 {
                    DropInPlaceRefDiag {
                        from_fn: __binding_0,
                        arg_ty: __binding_1,
                        label: __binding_2,
                        sugg: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calls to {$from_fn ->\n        [true] `std::ptr::drop_in_place`\n        *[false] `drop_in_place`\n    } with a pointer to a reference instead of a pointer to an owned value does nothing")));
                        ;
                        diag.arg("from_fn", __binding_0);
                        diag.arg("arg_ty", __binding_1);
                        diag.span_label(__binding_2,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("argument has type `{$arg_ty}`")));
                        diag.subdiagnostic(__binding_3);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
990#[diag(
991    "calls to {$from_fn ->
992        [true] `std::ptr::drop_in_place`
993        *[false] `drop_in_place`
994    } with a pointer to a reference instead of a pointer to an owned value does nothing"
995)]
996pub(crate) struct DropInPlaceRefDiag<'a> {
997    pub from_fn: bool,
998    pub arg_ty: Ty<'a>,
999    #[label("argument has type `{$arg_ty}`")]
1000    pub label: Span,
1001    #[subdiagnostic]
1002    pub sugg: UseLetUnderscoreIgnoreSuggestion,
1003}
1004
1005#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            DropInPlaceCopyDiag<'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 {
                    DropInPlaceCopyDiag {
                        from_fn: __binding_0,
                        arg_ty: __binding_1,
                        label: __binding_2,
                        sugg: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calls to {$from_fn ->\n        [true] `std::ptr::drop_in_place`\n        *[false] `drop_in_place`\n    } with a pointer to a value that implements `Copy` does nothing")));
                        ;
                        diag.arg("from_fn", __binding_0);
                        diag.arg("arg_ty", __binding_1);
                        diag.span_label(__binding_2,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("argument has type `{$arg_ty}`")));
                        diag.subdiagnostic(__binding_3);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1006#[diag(
1007    "calls to {$from_fn ->
1008        [true] `std::ptr::drop_in_place`
1009        *[false] `drop_in_place`
1010    } with a pointer to a value that implements `Copy` does nothing"
1011)]
1012pub(crate) struct DropInPlaceCopyDiag<'a> {
1013    pub from_fn: bool,
1014    pub arg_ty: Ty<'a>,
1015    #[label("argument has type `{$arg_ty}`")]
1016    pub label: Span,
1017    #[subdiagnostic]
1018    pub sugg: UseLetUnderscoreIgnoreSuggestion,
1019}
1020
1021#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            ForgetRefDiag<'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 {
                    ForgetRefDiag {
                        arg_ty: __binding_0, label: __binding_1, sugg: __binding_2 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calls to `std::mem::forget` with a reference instead of an owned value does nothing")));
                        ;
                        diag.arg("arg_ty", __binding_0);
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("argument has type `{$arg_ty}`")));
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1022#[diag("calls to `std::mem::forget` with a reference instead of an owned value does nothing")]
1023pub(crate) struct ForgetRefDiag<'a> {
1024    pub arg_ty: Ty<'a>,
1025    #[label("argument has type `{$arg_ty}`")]
1026    pub label: Span,
1027    #[subdiagnostic]
1028    pub sugg: UseLetUnderscoreIgnoreSuggestion,
1029}
1030
1031#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            ForgetCopyDiag<'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 {
                    ForgetCopyDiag {
                        arg_ty: __binding_0, label: __binding_1, sugg: __binding_2 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calls to `std::mem::forget` with a value that implements `Copy` does nothing")));
                        ;
                        diag.arg("arg_ty", __binding_0);
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("argument has type `{$arg_ty}`")));
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1032#[diag("calls to `std::mem::forget` with a value that implements `Copy` does nothing")]
1033pub(crate) struct ForgetCopyDiag<'a> {
1034    pub arg_ty: Ty<'a>,
1035    #[label("argument has type `{$arg_ty}`")]
1036    pub label: Span,
1037    #[subdiagnostic]
1038    pub sugg: UseLetUnderscoreIgnoreSuggestion,
1039}
1040
1041#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            UndroppedManuallyDropsDiag<'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 {
                    UndroppedManuallyDropsDiag {
                        arg_ty: __binding_0,
                        label: __binding_1,
                        suggestion: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calls to `std::mem::drop` with `std::mem::ManuallyDrop` instead of the inner value does nothing")));
                        ;
                        diag.arg("arg_ty", __binding_0);
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("argument has type `{$arg_ty}`")));
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1042#[diag(
1043    "calls to `std::mem::drop` with `std::mem::ManuallyDrop` instead of the inner value does nothing"
1044)]
1045pub(crate) struct UndroppedManuallyDropsDiag<'a> {
1046    pub arg_ty: Ty<'a>,
1047    #[label("argument has type `{$arg_ty}`")]
1048    pub label: Span,
1049    #[subdiagnostic]
1050    pub suggestion: UndroppedManuallyDropsSuggestion,
1051}
1052
1053#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for UndroppedManuallyDropsSuggestion
            {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    UndroppedManuallyDropsSuggestion {
                        start_span: __binding_0, end_span: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_32 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("std::mem::ManuallyDrop::into_inner("))
                                });
                        let __code_33 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        suggestions.push((__binding_0, __code_32));
                        suggestions.push((__binding_1, __code_33));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `std::mem::ManuallyDrop::into_inner` to get the inner value")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
1054#[multipart_suggestion(
1055    "use `std::mem::ManuallyDrop::into_inner` to get the inner value",
1056    applicability = "machine-applicable"
1057)]
1058pub(crate) struct UndroppedManuallyDropsSuggestion {
1059    #[suggestion_part(code = "std::mem::ManuallyDrop::into_inner(")]
1060    pub start_span: Span,
1061    #[suggestion_part(code = ")")]
1062    pub end_span: Span,
1063}
1064
1065#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            UndroppedManuallyDropsInPlaceDiag<'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 {
                    UndroppedManuallyDropsInPlaceDiag {
                        arg_ty: __binding_0,
                        label: __binding_1,
                        suggestion: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calls to `drop_in_place` with a pointer to a `std::mem::ManuallyDrop` instead of the inner value does nothing")));
                        ;
                        diag.arg("arg_ty", __binding_0);
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("argument has type `{$arg_ty}`")));
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1066#[diag(
1067    "calls to `drop_in_place` with a pointer to a `std::mem::ManuallyDrop` instead of the inner value does nothing"
1068)]
1069pub(crate) struct UndroppedManuallyDropsInPlaceDiag<'a> {
1070    pub arg_ty: Ty<'a>,
1071    #[label("argument has type `{$arg_ty}`")]
1072    pub label: Span,
1073    #[subdiagnostic]
1074    pub suggestion: UndroppedManuallyDropsInPlaceSuggestion,
1075}
1076
1077#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for
            UndroppedManuallyDropsInPlaceSuggestion {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    UndroppedManuallyDropsInPlaceSuggestion {
                        start_span: __binding_0, end_span: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_34 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("std::mem::ManuallyDrop::drop(&mut *"))
                                });
                        let __code_35 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        suggestions.push((__binding_0, __code_34));
                        suggestions.push((__binding_1, __code_35));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `std::mem::ManuallyDrop::drop` to drop the inner value")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
1078#[multipart_suggestion(
1079    "use `std::mem::ManuallyDrop::drop` to drop the inner value",
1080    applicability = "maybe-incorrect"
1081)]
1082pub(crate) struct UndroppedManuallyDropsInPlaceSuggestion {
1083    #[suggestion_part(code = "std::mem::ManuallyDrop::drop(&mut *")]
1084    pub start_span: Span,
1085    #[suggestion_part(code = ")")]
1086    pub end_span: Span,
1087}
1088
1089// invalid_from_utf8.rs
1090#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidFromUtf8Diag 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 {
                    InvalidFromUtf8Diag::Unchecked {
                        method: __binding_0,
                        valid_up_to: __binding_1,
                        label: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calls to `{$method}` with an invalid literal are undefined behavior")));
                        ;
                        diag.arg("method", __binding_0);
                        diag.arg("valid_up_to", __binding_1);
                        diag.span_label(__binding_2,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the literal was valid UTF-8 up to the {$valid_up_to} bytes")));
                        diag
                    }
                    InvalidFromUtf8Diag::Checked {
                        method: __binding_0,
                        valid_up_to: __binding_1,
                        label: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calls to `{$method}` with an invalid literal always return an error")));
                        ;
                        diag.arg("method", __binding_0);
                        diag.arg("valid_up_to", __binding_1);
                        diag.span_label(__binding_2,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the literal was valid UTF-8 up to the {$valid_up_to} bytes")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1091pub(crate) enum InvalidFromUtf8Diag {
1092    #[diag("calls to `{$method}` with an invalid literal are undefined behavior")]
1093    Unchecked {
1094        method: String,
1095        valid_up_to: usize,
1096        #[label("the literal was valid UTF-8 up to the {$valid_up_to} bytes")]
1097        label: Span,
1098    },
1099    #[diag("calls to `{$method}` with an invalid literal always return an error")]
1100    Checked {
1101        method: String,
1102        valid_up_to: usize,
1103        #[label("the literal was valid UTF-8 up to the {$valid_up_to} bytes")]
1104        label: Span,
1105    },
1106}
1107
1108// interior_mutable_consts.rs
1109#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            ConstItemInteriorMutationsDiag<'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 {
                    ConstItemInteriorMutationsDiag {
                        method_name: __binding_0,
                        const_name: __binding_1,
                        const_ty: __binding_2,
                        receiver_span: __binding_3,
                        sugg_static: __binding_4 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mutation of an interior mutable `const` item with call to `{$method_name}`")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("each usage of a `const` item creates a new temporary")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only the temporaries and never the original `const {$const_name}` will be modified")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>")));
                        ;
                        diag.arg("method_name", __binding_0);
                        diag.arg("const_name", __binding_1);
                        diag.arg("const_ty", __binding_2);
                        diag.span_label(__binding_3,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$const_name}` is a interior mutable `const` item of type `{$const_ty}`")));
                        if let Some(__binding_4) = __binding_4 {
                            diag.subdiagnostic(__binding_4);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1110#[diag("mutation of an interior mutable `const` item with call to `{$method_name}`")]
1111#[note("each usage of a `const` item creates a new temporary")]
1112#[note("only the temporaries and never the original `const {$const_name}` will be modified")]
1113#[help(
1114    "for more details on interior mutability see <https://doc.rust-lang.org/reference/interior-mutability.html>"
1115)]
1116pub(crate) struct ConstItemInteriorMutationsDiag<'tcx> {
1117    pub method_name: Ident,
1118    pub const_name: Ident,
1119    pub const_ty: Ty<'tcx>,
1120    #[label("`{$const_name}` is a interior mutable `const` item of type `{$const_ty}`")]
1121    pub receiver_span: Span,
1122    #[subdiagnostic]
1123    pub sugg_static: Option<ConstItemInteriorMutationsSuggestionStatic>,
1124}
1125
1126#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for
            ConstItemInteriorMutationsSuggestionStatic {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ConstItemInteriorMutationsSuggestionStatic::Spanful {
                        const_: __binding_0,
                        before: __binding_1,
                        const_name: __binding_2 } => {
                        let __code_36 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}static ",
                                                        __binding_1))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("const_name".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 a shared instance of `{$const_name}`, consider making it a `static` item instead")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_36, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    ConstItemInteriorMutationsSuggestionStatic::Spanless {
                        const_name: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("const_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("for a shared instance of `{$const_name}`, consider making it a `static` item instead")),
                                &sub_args);
                        diag.help(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
1127pub(crate) enum ConstItemInteriorMutationsSuggestionStatic {
1128    #[suggestion(
1129        "for a shared instance of `{$const_name}`, consider making it a `static` item instead",
1130        code = "{before}static ",
1131        style = "verbose",
1132        applicability = "maybe-incorrect"
1133    )]
1134    Spanful {
1135        #[primary_span]
1136        const_: Span,
1137        before: &'static str,
1138        const_name: Ident,
1139    },
1140    #[help("for a shared instance of `{$const_name}`, consider making it a `static` item instead")]
1141    Spanless { const_name: Ident },
1142}
1143
1144// reference_casting.rs
1145#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidReferenceCastingDiag<'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 {
                    InvalidReferenceCastingDiag::BorrowAsMut {
                        orig_cast: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>")));
                        ;
                        if let Some(__binding_0) = __binding_0 {
                            diag.span_label(__binding_0,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("casting happened here")));
                        }
                        diag
                    }
                    InvalidReferenceCastingDiag::AssignToRef {
                        orig_cast: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("assigning to `&T` is undefined behavior, consider using an `UnsafeCell`")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>")));
                        ;
                        if let Some(__binding_0) = __binding_0 {
                            diag.span_label(__binding_0,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("casting happened here")));
                        }
                        diag
                    }
                    InvalidReferenceCastingDiag::BiggerLayout {
                        orig_cast: __binding_0,
                        alloc: __binding_1,
                        from_ty: __binding_2,
                        from_size: __binding_3,
                        to_ty: __binding_4,
                        to_size: __binding_5 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("casting from `{$from_ty}` ({$from_size} bytes) to `{$to_ty}` ({$to_size} bytes)")));
                        ;
                        diag.arg("from_ty", __binding_2);
                        diag.arg("from_size", __binding_3);
                        diag.arg("to_ty", __binding_4);
                        diag.arg("to_size", __binding_5);
                        if let Some(__binding_0) = __binding_0 {
                            diag.span_label(__binding_0,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("casting happened here")));
                        }
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("backing allocation comes from here")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1146pub(crate) enum InvalidReferenceCastingDiag<'tcx> {
1147    #[diag(
1148        "casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`"
1149    )]
1150    #[note(
1151        "for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>"
1152    )]
1153    BorrowAsMut {
1154        #[label("casting happened here")]
1155        orig_cast: Option<Span>,
1156    },
1157    #[diag("assigning to `&T` is undefined behavior, consider using an `UnsafeCell`")]
1158    #[note(
1159        "for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>"
1160    )]
1161    AssignToRef {
1162        #[label("casting happened here")]
1163        orig_cast: Option<Span>,
1164    },
1165    #[diag(
1166        "casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused"
1167    )]
1168    #[note("casting from `{$from_ty}` ({$from_size} bytes) to `{$to_ty}` ({$to_size} bytes)")]
1169    BiggerLayout {
1170        #[label("casting happened here")]
1171        orig_cast: Option<Span>,
1172        #[label("backing allocation comes from here")]
1173        alloc: Span,
1174        from_ty: Ty<'tcx>,
1175        from_size: u64,
1176        to_ty: Ty<'tcx>,
1177        to_size: u64,
1178    },
1179}
1180
1181// map_unit_fn.rs
1182#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for MappingToUnit
            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 {
                    MappingToUnit {
                        function_label: __binding_0,
                        argument_label: __binding_1,
                        map_label: __binding_2,
                        suggestion: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Iterator::map` call that discard the iterator's values")));
                        let __code_37 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("for_each"))
                                            })].into_iter();
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Iterator::map`, like many of the methods on `Iterator`, gets executed lazily, meaning that its effects won't be visible until it is iterated")));
                        ;
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this function returns `()`, which is likely not what you wanted")));
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("called `Iterator::map` with callable that returns `()`")));
                        diag.span_label(__binding_2,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("after this call to map, the resulting iterator is `impl Iterator<Item = ()>`, which means the only information carried by the iterator is the number of items")));
                        diag.span_suggestions_with_style(__binding_3,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to use `Iterator::for_each`")),
                            __code_37, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1183#[diag("`Iterator::map` call that discard the iterator's values")]
1184#[note(
1185    "`Iterator::map`, like many of the methods on `Iterator`, gets executed lazily, meaning that its effects won't be visible until it is iterated"
1186)]
1187pub(crate) struct MappingToUnit {
1188    #[label("this function returns `()`, which is likely not what you wanted")]
1189    pub function_label: Span,
1190    #[label("called `Iterator::map` with callable that returns `()`")]
1191    pub argument_label: Span,
1192    #[label(
1193        "after this call to map, the resulting iterator is `impl Iterator<Item = ()>`, which means the only information carried by the iterator is the number of items"
1194    )]
1195    pub map_label: Span,
1196    #[suggestion(
1197        "you might have meant to use `Iterator::for_each`",
1198        style = "verbose",
1199        code = "for_each",
1200        applicability = "maybe-incorrect"
1201    )]
1202    pub suggestion: Span,
1203}
1204
1205// internal.rs
1206#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            DefaultHashTypesDiag<'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 {
                    DefaultHashTypesDiag {
                        preferred: __binding_0, used: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("prefer `{$preferred}` over `{$used}`, it has better performance")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a `use rustc_data_structures::fx::{$preferred}` may be necessary")));
                        ;
                        diag.arg("preferred", __binding_0);
                        diag.arg("used", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1207#[diag("prefer `{$preferred}` over `{$used}`, it has better performance")]
1208#[note("a `use rustc_data_structures::fx::{$preferred}` may be necessary")]
1209pub(crate) struct DefaultHashTypesDiag<'a> {
1210    pub preferred: &'a str,
1211    pub used: Symbol,
1212}
1213
1214#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            QueryInstability 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 {
                    QueryInstability { query: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using `{$query}` can result in unstable query results")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you believe this case to be fine, allow this lint and add a comment explaining your rationale")));
                        ;
                        diag.arg("query", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1215#[diag("using `{$query}` can result in unstable query results")]
1216#[note(
1217    "if you believe this case to be fine, allow this lint and add a comment explaining your rationale"
1218)]
1219pub(crate) struct QueryInstability {
1220    pub query: Symbol,
1221}
1222
1223#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for QueryUntracked
            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 {
                    QueryUntracked { method: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$method}` accesses information that is not tracked by the query system")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you believe this case to be fine, allow this lint and add a comment explaining your rationale")));
                        ;
                        diag.arg("method", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1224#[diag("`{$method}` accesses information that is not tracked by the query system")]
1225#[note(
1226    "if you believe this case to be fine, allow this lint and add a comment explaining your rationale"
1227)]
1228pub(crate) struct QueryUntracked {
1229    pub method: Symbol,
1230}
1231
1232#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SpanUseEqCtxtDiag 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 {
                    SpanUseEqCtxtDiag => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `.eq_ctxt()` instead of `.ctxt() == .ctxt()`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1233#[diag("use `.eq_ctxt()` instead of `.ctxt() == .ctxt()`")]
1234pub(crate) struct SpanUseEqCtxtDiag;
1235
1236#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SymbolInternStringLiteralDiag 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 {
                    SymbolInternStringLiteralDiag => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using `Symbol::intern` on a string literal")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider adding the symbol to `compiler/rustc_span/src/symbol.rs`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1237#[diag("using `Symbol::intern` on a string literal")]
1238#[help("consider adding the symbol to `compiler/rustc_span/src/symbol.rs`")]
1239pub(crate) struct SymbolInternStringLiteralDiag;
1240
1241#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for TykindKind
            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 {
                    TykindKind { suggestion: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("usage of `ty::TyKind::<kind>`")));
                        let __code_38 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("ty"))
                                            })].into_iter();
                        ;
                        diag.span_suggestions_with_style(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using `ty::<kind>` directly")),
                            __code_38, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1242#[diag("usage of `ty::TyKind::<kind>`")]
1243pub(crate) struct TykindKind {
1244    #[suggestion(
1245        "try using `ty::<kind>` directly",
1246        code = "ty",
1247        applicability = "maybe-incorrect"
1248    )]
1249    pub suggestion: Span,
1250}
1251
1252#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for TykindDiag
            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 {
                    TykindDiag => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("usage of `ty::TyKind`")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using `Ty` instead")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1253#[diag("usage of `ty::TyKind`")]
1254#[help("try using `Ty` instead")]
1255pub(crate) struct TykindDiag;
1256
1257#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for TyQualified
            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 {
                    TyQualified { ty: __binding_0, suggestion: __binding_1 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("usage of qualified `ty::{$ty}`")));
                        let __code_39 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_0))
                                            })].into_iter();
                        ;
                        diag.arg("ty", __binding_0);
                        diag.span_suggestions_with_style(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try importing it and using it unqualified")),
                            __code_39, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1258#[diag("usage of qualified `ty::{$ty}`")]
1259pub(crate) struct TyQualified {
1260    pub ty: String,
1261    #[suggestion(
1262        "try importing it and using it unqualified",
1263        code = "{ty}",
1264        applicability = "maybe-incorrect"
1265    )]
1266    pub suggestion: Span,
1267}
1268
1269#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            TypeIrInherentUsage 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 {
                    TypeIrInherentUsage => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("do not use `rustc_type_ir::inherent` unless you're inside of the trait solver")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the method or struct you're looking for is likely defined somewhere else downstream in the compiler")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1270#[diag("do not use `rustc_type_ir::inherent` unless you're inside of the trait solver")]
1271#[note(
1272    "the method or struct you're looking for is likely defined somewhere else downstream in the compiler"
1273)]
1274pub(crate) struct TypeIrInherentUsage;
1275
1276#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            TypeIrTraitUsage 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 {
                    TypeIrTraitUsage => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("do not use `rustc_type_ir::Interner` or `rustc_type_ir::InferCtxtLike` unless you're inside of the trait solver")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the method or struct you're looking for is likely defined somewhere else downstream in the compiler")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1277#[diag(
1278    "do not use `rustc_type_ir::Interner` or `rustc_type_ir::InferCtxtLike` unless you're inside of the trait solver"
1279)]
1280#[note(
1281    "the method or struct you're looking for is likely defined somewhere else downstream in the compiler"
1282)]
1283pub(crate) struct TypeIrTraitUsage;
1284
1285#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            TypeIrDirectUse 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 {
                    TypeIrDirectUse => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("do not use `rustc_type_ir` unless you are implementing type system internals")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `rustc_middle::ty` instead")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1286#[diag("do not use `rustc_type_ir` unless you are implementing type system internals")]
1287#[note("use `rustc_middle::ty` instead")]
1288pub(crate) struct TypeIrDirectUse;
1289
1290#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            NonGlobImportTypeIrInherent 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 {
                    NonGlobImportTypeIrInherent {
                        suggestion: __binding_0, snippet: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-glob import of `rustc_type_ir::inherent`")));
                        let __code_40 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_1))
                                            })].into_iter();
                        ;
                        if let Some(__binding_0) = __binding_0 {
                            diag.span_suggestions_with_style(__binding_0,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using a glob import instead")),
                                __code_40, rustc_errors::Applicability::MaybeIncorrect,
                                rustc_errors::SuggestionStyle::ShowCode);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1291#[diag("non-glob import of `rustc_type_ir::inherent`")]
1292pub(crate) struct NonGlobImportTypeIrInherent {
1293    #[suggestion(
1294        "try using a glob import instead",
1295        code = "{snippet}",
1296        applicability = "maybe-incorrect"
1297    )]
1298    pub suggestion: Option<Span>,
1299    pub snippet: &'static str,
1300}
1301
1302#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for LintPassByHand
            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 {
                    LintPassByHand => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementing `LintPass` by hand")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using `declare_lint_pass!` or `impl_lint_pass!` instead")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1303#[diag("implementing `LintPass` by hand")]
1304#[help("try using `declare_lint_pass!` or `impl_lint_pass!` instead")]
1305pub(crate) struct LintPassByHand;
1306
1307#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            BadOptAccessDiag<'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 {
                    BadOptAccessDiag { msg: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$msg}")));
                        ;
                        diag.arg("msg", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1308#[diag("{$msg}")]
1309pub(crate) struct BadOptAccessDiag<'a> {
1310    pub msg: &'a str,
1311}
1312
1313#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            ImplicitSysrootCrateImportDiag<'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 {
                    ImplicitSysrootCrateImportDiag { name: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("dangerous use of `extern crate {$name}` which is not guaranteed to exist exactly once in the sysroot")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using a cargo dependency or using a re-export of the dependency provided by a rustc_* crate")));
                        ;
                        diag.arg("name", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1314#[diag(
1315    "dangerous use of `extern crate {$name}` which is not guaranteed to exist exactly once in the sysroot"
1316)]
1317#[help(
1318    "try using a cargo dependency or using a re-export of the dependency provided by a rustc_* crate"
1319)]
1320pub(crate) struct ImplicitSysrootCrateImportDiag<'a> {
1321    pub name: &'a str,
1322}
1323
1324#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            AttributeKindInFindAttr 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 {
                    AttributeKindInFindAttr => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use of `AttributeKind` in `find_attr!(...)` invocation")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`find_attr!(...)` already imports `AttributeKind::*`")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove `AttributeKind`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1325#[diag("use of `AttributeKind` in `find_attr!(...)` invocation")]
1326#[note("`find_attr!(...)` already imports `AttributeKind::*`")]
1327#[help("remove `AttributeKind`")]
1328pub(crate) struct AttributeKindInFindAttr;
1329
1330#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            RustcMustMatchExhaustivelyNotExhaustive 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 {
                    RustcMustMatchExhaustivelyNotExhaustive {
                        attr_span: __binding_0,
                        pat_span: __binding_1,
                        message: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("match is not exhaustive")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("explicitly list all variants of the enum in a `match`")));
                        ;
                        diag.arg("message", __binding_2);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("required because of this attribute")));
                        diag.span_note(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$message}")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1331#[diag("match is not exhaustive")]
1332#[help("explicitly list all variants of the enum in a `match`")]
1333pub(crate) struct RustcMustMatchExhaustivelyNotExhaustive {
1334    #[label("required because of this attribute")]
1335    pub attr_span: Span,
1336
1337    #[note("{$message}")]
1338    pub pat_span: Span,
1339    pub message: &'static str,
1340}
1341
1342// let_underscore.rs
1343#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for NonBindingLet
            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 {
                    NonBindingLet::SyncLock { pat: __binding_0, sub: __binding_1
                        } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-binding let on a synchronization lock")));
                        ;
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this lock is not assigned to a binding and is immediately dropped")));
                        diag.subdiagnostic(__binding_1);
                        diag
                    }
                    NonBindingLet::DropType { sub: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-binding let on a type that has a destructor")));
                        ;
                        diag.subdiagnostic(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1344pub(crate) enum NonBindingLet {
1345    #[diag("non-binding let on a synchronization lock")]
1346    SyncLock {
1347        #[label("this lock is not assigned to a binding and is immediately dropped")]
1348        pat: Span,
1349        #[subdiagnostic]
1350        sub: NonBindingLetSub,
1351    },
1352    #[diag("non-binding let on a type that has a destructor")]
1353    DropType {
1354        #[subdiagnostic]
1355        sub: NonBindingLetSub,
1356    },
1357}
1358
1359pub(crate) struct NonBindingLetSub {
1360    pub suggestion: Span,
1361    pub drop_fn_start_end: Option<(Span, Span)>,
1362    pub is_assign_desugar: bool,
1363}
1364
1365impl Subdiagnostic for NonBindingLetSub {
1366    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1367        let can_suggest_binding = self.drop_fn_start_end.is_some() || !self.is_assign_desugar;
1368
1369        if can_suggest_binding {
1370            let prefix = if self.is_assign_desugar { "let " } else { "" };
1371            diag.span_suggestion_verbose(
1372                self.suggestion,
1373                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider binding to an unused variable to avoid immediately dropping the value"))msg!(
1374                    "consider binding to an unused variable to avoid immediately dropping the value"
1375                ),
1376                ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0}_unused", prefix))
    })format!("{prefix}_unused"),
1377                Applicability::MachineApplicable,
1378            );
1379        } else {
1380            diag.span_help(
1381                self.suggestion,
1382                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider binding to an unused variable to avoid immediately dropping the value"))msg!(
1383                    "consider binding to an unused variable to avoid immediately dropping the value"
1384                ),
1385            );
1386        }
1387        if let Some(drop_fn_start_end) = self.drop_fn_start_end {
1388            diag.multipart_suggestion(
1389                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider immediately dropping the value"))msg!("consider immediately dropping the value"),
1390                ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
        [(drop_fn_start_end.0, "drop(".to_string()),
                (drop_fn_start_end.1, ")".to_string())]))vec![
1391                    (drop_fn_start_end.0, "drop(".to_string()),
1392                    (drop_fn_start_end.1, ")".to_string()),
1393                ],
1394                Applicability::MachineApplicable,
1395            );
1396        } else {
1397            diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider immediately dropping the value using `drop(..)` after the `let` statement"))msg!(
1398                "consider immediately dropping the value using `drop(..)` after the `let` statement"
1399            ));
1400        }
1401    }
1402}
1403
1404// levels.rs
1405#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            OverruledAttributeLint<'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 {
                    OverruledAttributeLint {
                        overruled: __binding_0,
                        lint_level: __binding_1,
                        lint_source: __binding_2,
                        sub: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$lint_level}({$lint_source}) incompatible with previous forbid")));
                        ;
                        diag.arg("lint_level", __binding_1);
                        diag.arg("lint_source", __binding_2);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("overruled by previous forbid")));
                        diag.subdiagnostic(__binding_3);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1406#[diag("{$lint_level}({$lint_source}) incompatible with previous forbid")]
1407pub(crate) struct OverruledAttributeLint<'a> {
1408    #[label("overruled by previous forbid")]
1409    pub overruled: Span,
1410    pub lint_level: &'a str,
1411    pub lint_source: Symbol,
1412    #[subdiagnostic]
1413    pub sub: OverruledAttributeSub,
1414}
1415
1416#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            DeprecatedLintName<'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 {
                    DeprecatedLintName {
                        name: __binding_0,
                        suggestion: __binding_1,
                        replace: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lint name `{$name}` is deprecated and may not have an effect in the future")));
                        let __code_41 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_2))
                                            })].into_iter();
                        ;
                        diag.arg("name", __binding_0);
                        diag.span_suggestions_with_style(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("change it to")),
                            __code_41, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1417#[diag("lint name `{$name}` is deprecated and may not have an effect in the future")]
1418pub(crate) struct DeprecatedLintName<'a> {
1419    pub name: String,
1420    #[suggestion("change it to", code = "{replace}", applicability = "machine-applicable")]
1421    pub suggestion: Span,
1422    pub replace: &'a str,
1423}
1424
1425#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            DeprecatedLintNameFromCommandLine<'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 {
                    DeprecatedLintNameFromCommandLine {
                        name: __binding_0,
                        replace: __binding_1,
                        requested_level: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lint name `{$name}` is deprecated and may not have an effect in the future")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("change it to {$replace}")));
                        ;
                        diag.arg("name", __binding_0);
                        diag.arg("replace", __binding_1);
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1426#[diag("lint name `{$name}` is deprecated and may not have an effect in the future")]
1427#[help("change it to {$replace}")]
1428pub(crate) struct DeprecatedLintNameFromCommandLine<'a> {
1429    pub name: String,
1430    pub replace: &'a str,
1431    #[subdiagnostic]
1432    pub requested_level: RequestedLevel<'a>,
1433}
1434
1435#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            RenamedLint<'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 {
                    RenamedLint {
                        name: __binding_0,
                        replace: __binding_1,
                        suggestion: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lint `{$name}` has been renamed to `{$replace}`")));
                        ;
                        diag.arg("name", __binding_0);
                        diag.arg("replace", __binding_1);
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1436#[diag("lint `{$name}` has been renamed to `{$replace}`")]
1437pub(crate) struct RenamedLint<'a> {
1438    pub name: &'a str,
1439    pub replace: &'a str,
1440    #[subdiagnostic]
1441    pub suggestion: RenamedLintSuggestion<'a>,
1442}
1443
1444#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for RenamedLintSuggestion<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    RenamedLintSuggestion::WithSpan {
                        suggestion: __binding_0, replace: __binding_1 } => {
                        let __code_42 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_1))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use the new name")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_42, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    RenamedLintSuggestion::WithoutSpan { replace: __binding_0 }
                        => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("replace".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("use the new name `{$replace}`")),
                                &sub_args);
                        diag.help(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
1445pub(crate) enum RenamedLintSuggestion<'a> {
1446    #[suggestion("use the new name", code = "{replace}", applicability = "machine-applicable")]
1447    WithSpan {
1448        #[primary_span]
1449        suggestion: Span,
1450        replace: &'a str,
1451    },
1452    #[help("use the new name `{$replace}`")]
1453    WithoutSpan { replace: &'a str },
1454}
1455
1456#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            RenamedLintFromCommandLine<'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 {
                    RenamedLintFromCommandLine {
                        name: __binding_0,
                        replace: __binding_1,
                        suggestion: __binding_2,
                        requested_level: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lint `{$name}` has been renamed to `{$replace}`")));
                        ;
                        diag.arg("name", __binding_0);
                        diag.arg("replace", __binding_1);
                        diag.subdiagnostic(__binding_2);
                        diag.subdiagnostic(__binding_3);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1457#[diag("lint `{$name}` has been renamed to `{$replace}`")]
1458pub(crate) struct RenamedLintFromCommandLine<'a> {
1459    pub name: &'a str,
1460    pub replace: &'a str,
1461    #[subdiagnostic]
1462    pub suggestion: RenamedLintSuggestion<'a>,
1463    #[subdiagnostic]
1464    pub requested_level: RequestedLevel<'a>,
1465}
1466
1467#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            RemovedLint<'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 {
                    RemovedLint { name: __binding_0, reason: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lint `{$name}` has been removed: {$reason}")));
                        ;
                        diag.arg("name", __binding_0);
                        diag.arg("reason", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1468#[diag("lint `{$name}` has been removed: {$reason}")]
1469pub(crate) struct RemovedLint<'a> {
1470    pub name: &'a str,
1471    pub reason: &'a str,
1472}
1473
1474#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            RemovedLintFromCommandLine<'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 {
                    RemovedLintFromCommandLine {
                        name: __binding_0,
                        reason: __binding_1,
                        requested_level: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lint `{$name}` has been removed: {$reason}")));
                        ;
                        diag.arg("name", __binding_0);
                        diag.arg("reason", __binding_1);
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1475#[diag("lint `{$name}` has been removed: {$reason}")]
1476pub(crate) struct RemovedLintFromCommandLine<'a> {
1477    pub name: &'a str,
1478    pub reason: &'a str,
1479    #[subdiagnostic]
1480    pub requested_level: RequestedLevel<'a>,
1481}
1482
1483#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for UnknownLint
            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 {
                    UnknownLint { name: __binding_0, suggestion: __binding_1 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown lint: `{$name}`")));
                        ;
                        diag.arg("name", __binding_0);
                        if let Some(__binding_1) = __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1484#[diag("unknown lint: `{$name}`")]
1485pub(crate) struct UnknownLint {
1486    pub name: String,
1487    #[subdiagnostic]
1488    pub suggestion: Option<UnknownLintSuggestion>,
1489}
1490
1491#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for UnknownLintSuggestion {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    UnknownLintSuggestion::WithSpan {
                        suggestion: __binding_0,
                        replace: __binding_1,
                        from_rustc: __binding_2 } => {
                        let __code_43 =
                            [::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("from_rustc".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("{$from_rustc ->\n            [true] a lint with a similar name exists in `rustc` lints\n            *[false] did you mean\n        }")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_43, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    UnknownLintSuggestion::WithoutSpan {
                        replace: __binding_0, from_rustc: __binding_1 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("replace".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("from_rustc".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("{$from_rustc ->\n            [true] a lint with a similar name exists in `rustc` lints: `{$replace}`\n            *[false] did you mean: `{$replace}`\n        }")),
                                &sub_args);
                        diag.help(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
1492pub(crate) enum UnknownLintSuggestion {
1493    #[suggestion(
1494        "{$from_rustc ->
1495            [true] a lint with a similar name exists in `rustc` lints
1496            *[false] did you mean
1497        }",
1498        code = "{replace}",
1499        applicability = "maybe-incorrect"
1500    )]
1501    WithSpan {
1502        #[primary_span]
1503        suggestion: Span,
1504        replace: Symbol,
1505        from_rustc: bool,
1506    },
1507    #[help(
1508        "{$from_rustc ->
1509            [true] a lint with a similar name exists in `rustc` lints: `{$replace}`
1510            *[false] did you mean: `{$replace}`
1511        }"
1512    )]
1513    WithoutSpan { replace: Symbol, from_rustc: bool },
1514}
1515
1516#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            UnknownLintFromCommandLine<'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 {
                    UnknownLintFromCommandLine {
                        name: __binding_0,
                        suggestion: __binding_1,
                        requested_level: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown lint: `{$name}`")));
                        diag.code(E0602);
                        ;
                        diag.arg("name", __binding_0);
                        if let Some(__binding_1) = __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1517#[diag("unknown lint: `{$name}`", code = E0602)]
1518pub(crate) struct UnknownLintFromCommandLine<'a> {
1519    pub name: String,
1520    #[subdiagnostic]
1521    pub suggestion: Option<UnknownLintSuggestion>,
1522    #[subdiagnostic]
1523    pub requested_level: RequestedLevel<'a>,
1524}
1525
1526#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            IgnoredUnlessCrateSpecified<'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 {
                    IgnoredUnlessCrateSpecified {
                        level: __binding_0, name: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$level}({$name}) is ignored unless specified at crate level")));
                        ;
                        diag.arg("level", __binding_0);
                        diag.arg("name", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1527#[diag("{$level}({$name}) is ignored unless specified at crate level")]
1528pub(crate) struct IgnoredUnlessCrateSpecified<'a> {
1529    pub level: &'a str,
1530    pub name: Symbol,
1531}
1532
1533// dangling.rs
1534#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            DanglingPointersFromTemporaries<'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 {
                    DanglingPointersFromTemporaries {
                        callee: __binding_0,
                        ty: __binding_1,
                        ptr_span: __binding_2,
                        temporary_span: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this creates a dangling pointer because temporary `{$ty}` is dropped at end of statement")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bind the `{$ty}` to a variable such that it outlives the pointer returned by `{$callee}`")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a dangling pointer is safe, but dereferencing one is undefined behavior")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("returning a pointer to a local variable will always result in a dangling pointer")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, see <https://doc.rust-lang.org/reference/destructors.html>")));
                        ;
                        diag.arg("callee", __binding_0);
                        diag.arg("ty", __binding_1);
                        diag.span_label(__binding_2,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("pointer created here")));
                        diag.span_label(__binding_3,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this `{$ty}` is dropped at end of statement")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1535#[diag("this creates a dangling pointer because temporary `{$ty}` is dropped at end of statement")]
1536#[help("bind the `{$ty}` to a variable such that it outlives the pointer returned by `{$callee}`")]
1537#[note("a dangling pointer is safe, but dereferencing one is undefined behavior")]
1538#[note("returning a pointer to a local variable will always result in a dangling pointer")]
1539#[note("for more information, see <https://doc.rust-lang.org/reference/destructors.html>")]
1540// FIXME: put #[primary_span] on `ptr_span` once it does not cause conflicts
1541pub(crate) struct DanglingPointersFromTemporaries<'tcx> {
1542    pub callee: Ident,
1543    pub ty: Ty<'tcx>,
1544    #[label("pointer created here")]
1545    pub ptr_span: Span,
1546    #[label("this `{$ty}` is dropped at end of statement")]
1547    pub temporary_span: Span,
1548}
1549
1550#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            DanglingPointersFromLocals<'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 {
                    DanglingPointersFromLocals {
                        ret_ty: __binding_0,
                        ret_ty_span: __binding_1,
                        fn_kind: __binding_2,
                        local_var: __binding_3,
                        local_var_name: __binding_4,
                        local_var_ty: __binding_5,
                        created_at: __binding_6 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$fn_kind} returns a dangling pointer to dropped local variable `{$local_var_name}`")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a dangling pointer is safe, but dereferencing one is undefined behavior")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, see <https://doc.rust-lang.org/reference/destructors.html>")));
                        ;
                        diag.arg("ret_ty", __binding_0);
                        diag.arg("fn_kind", __binding_2);
                        diag.arg("local_var_name", __binding_4);
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("return type is `{$ret_ty}`")));
                        diag.span_label(__binding_3,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("local variable `{$local_var_name}` is dropped at the end of the {$fn_kind}")));
                        if let Some(__binding_6) = __binding_6 {
                            diag.span_label(__binding_6,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("dangling pointer created here")));
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1551#[diag("{$fn_kind} returns a dangling pointer to dropped local variable `{$local_var_name}`")]
1552#[note("a dangling pointer is safe, but dereferencing one is undefined behavior")]
1553#[note("for more information, see <https://doc.rust-lang.org/reference/destructors.html>")]
1554pub(crate) struct DanglingPointersFromLocals<'tcx> {
1555    pub ret_ty: Ty<'tcx>,
1556    #[label("return type is `{$ret_ty}`")]
1557    pub ret_ty_span: Span,
1558    pub fn_kind: &'static str,
1559    #[label("local variable `{$local_var_name}` is dropped at the end of the {$fn_kind}")]
1560    pub local_var: Span,
1561    pub local_var_name: Ident,
1562    pub local_var_ty: Ty<'tcx>,
1563    #[label("dangling pointer created here")]
1564    pub created_at: Option<Span>,
1565}
1566
1567// multiple_supertrait_upcastable.rs
1568#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            MultipleSupertraitUpcastable 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 {
                    MultipleSupertraitUpcastable { ident: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$ident}` is dyn-compatible and has multiple supertraits")));
                        ;
                        diag.arg("ident", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1569#[diag("`{$ident}` is dyn-compatible and has multiple supertraits")]
1570pub(crate) struct MultipleSupertraitUpcastable {
1571    pub ident: Ident,
1572}
1573
1574// non_ascii_idents.rs
1575#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            IdentifierNonAsciiChar 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 {
                    IdentifierNonAsciiChar => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("identifier contains non-ASCII characters")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1576#[diag("identifier contains non-ASCII characters")]
1577pub(crate) struct IdentifierNonAsciiChar;
1578
1579#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            IdentifierUncommonCodepoints 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 {
                    IdentifierUncommonCodepoints {
                        codepoints: __binding_0,
                        codepoints_len: __binding_1,
                        identifier_type: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("identifier contains {$codepoints_len ->\n        [one] { $identifier_type ->\n            [Exclusion] a character from an archaic script\n            [Technical] a character that is for non-linguistic, specialized usage\n            [Limited_Use] a character from a script in limited use\n            [Not_NFKC] a non normalized (NFKC) character\n            *[other] an uncommon character\n        }\n        *[other] { $identifier_type ->\n            [Exclusion] {$codepoints_len} characters from archaic scripts\n            [Technical] {$codepoints_len} characters that are for non-linguistic, specialized usage\n            [Limited_Use] {$codepoints_len} characters from scripts in limited use\n            [Not_NFKC] {$codepoints_len} non normalized (NFKC) characters\n            *[other] uncommon characters\n        }\n    }: {$codepoints}")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$codepoints_len ->\n        [one] this character is\n        *[other] these characters are\n    } included in the{$identifier_type ->\n        [Restricted] {\"\"}\n        *[other] {\" \"}{$identifier_type}\n    } Unicode general security profile")));
                        ;
                        diag.arg("codepoints", __binding_0);
                        diag.arg("codepoints_len", __binding_1);
                        diag.arg("identifier_type", __binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1580#[diag(
1581    "identifier contains {$codepoints_len ->
1582        [one] { $identifier_type ->
1583            [Exclusion] a character from an archaic script
1584            [Technical] a character that is for non-linguistic, specialized usage
1585            [Limited_Use] a character from a script in limited use
1586            [Not_NFKC] a non normalized (NFKC) character
1587            *[other] an uncommon character
1588        }
1589        *[other] { $identifier_type ->
1590            [Exclusion] {$codepoints_len} characters from archaic scripts
1591            [Technical] {$codepoints_len} characters that are for non-linguistic, specialized usage
1592            [Limited_Use] {$codepoints_len} characters from scripts in limited use
1593            [Not_NFKC] {$codepoints_len} non normalized (NFKC) characters
1594            *[other] uncommon characters
1595        }
1596    }: {$codepoints}"
1597)]
1598#[note(
1599    r#"{$codepoints_len ->
1600        [one] this character is
1601        *[other] these characters are
1602    } included in the{$identifier_type ->
1603        [Restricted] {""}
1604        *[other] {" "}{$identifier_type}
1605    } Unicode general security profile"#
1606)]
1607pub(crate) struct IdentifierUncommonCodepoints {
1608    pub codepoints: Vec<char>,
1609    pub codepoints_len: usize,
1610    pub identifier_type: &'static str,
1611}
1612
1613#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ConfusableIdentifierPair 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 {
                    ConfusableIdentifierPair {
                        existing_sym: __binding_0,
                        sym: __binding_1,
                        label: __binding_2,
                        main_label: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found both `{$existing_sym}` and `{$sym}` as identifiers, which look alike")));
                        ;
                        diag.arg("existing_sym", __binding_0);
                        diag.arg("sym", __binding_1);
                        diag.span_label(__binding_2,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("other identifier used here")));
                        diag.span_label(__binding_3,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this identifier can be confused with `{$existing_sym}`")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1614#[diag("found both `{$existing_sym}` and `{$sym}` as identifiers, which look alike")]
1615pub(crate) struct ConfusableIdentifierPair {
1616    pub existing_sym: Symbol,
1617    pub sym: Symbol,
1618    #[label("other identifier used here")]
1619    pub label: Span,
1620    #[label("this identifier can be confused with `{$existing_sym}`")]
1621    pub main_label: Span,
1622}
1623
1624#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            MixedScriptConfusables 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 {
                    MixedScriptConfusables {
                        set: __binding_0, includes: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the usage of Script Group `{$set}` in this crate consists solely of mixed script confusables")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the usage includes {$includes}")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("please recheck to make sure their usages are indeed what you want")));
                        ;
                        diag.arg("set", __binding_0);
                        diag.arg("includes", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1625#[diag(
1626    "the usage of Script Group `{$set}` in this crate consists solely of mixed script confusables"
1627)]
1628#[note("the usage includes {$includes}")]
1629#[note("please recheck to make sure their usages are indeed what you want")]
1630pub(crate) struct MixedScriptConfusables {
1631    pub set: String,
1632    pub includes: String,
1633}
1634
1635// non_fmt_panic.rs
1636pub(crate) struct NonFmtPanicUnused {
1637    pub count: usize,
1638    pub suggestion: Option<Span>,
1639}
1640
1641// Used because of two suggestions based on one Option<Span>
1642impl<'a> Diagnostic<'a, ()> for NonFmtPanicUnused {
1643    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
1644        let mut diag = Diag::new(dcx, level, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("panic message contains {$count ->\n                [one] an unused\n                *[other] unused\n            } formatting {$count ->\n                [one] placeholder\n                *[other] placeholders\n            }"))msg!(
1645            "panic message contains {$count ->
1646                [one] an unused
1647                *[other] unused
1648            } formatting {$count ->
1649                [one] placeholder
1650                *[other] placeholders
1651            }"
1652        ))
1653            .with_arg("count", self.count)
1654            .with_note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this message is not used as a format string when given without arguments, but will be in Rust 2021"))msg!("this message is not used as a format string when given without arguments, but will be in Rust 2021"));
1655        if let Some(span) = self.suggestion {
1656            diag.span_suggestion(
1657                span.shrink_to_hi(),
1658                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add the missing {$count ->\n                        [one] argument\n                        *[other] arguments\n                    }"))msg!(
1659                    "add the missing {$count ->
1660                        [one] argument
1661                        *[other] arguments
1662                    }"
1663                ),
1664                ", ...",
1665                Applicability::HasPlaceholders,
1666            );
1667            diag.span_suggestion(
1668                span.shrink_to_lo(),
1669                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("or add a \"{\"{\"}{\"}\"}\" format string to use the message literally"))msg!(r#"or add a "{"{"}{"}"}" format string to use the message literally"#),
1670                "\"{}\", ",
1671                Applicability::MachineApplicable,
1672            );
1673        }
1674        diag
1675    }
1676}
1677
1678#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            NonFmtPanicBraces 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 {
                    NonFmtPanicBraces {
                        count: __binding_0, suggestion: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("panic message contains {$count ->\n        [one] a brace\n        *[other] braces\n    }")));
                        let __code_44 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("\"{{}}\", "))
                                            })].into_iter();
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this message is not used as a format string, but will be in Rust 2021")));
                        ;
                        diag.arg("count", __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 a \"{\"{\"}{\"}\"}\" format string to use the message literally")),
                                __code_44, rustc_errors::Applicability::MachineApplicable,
                                rustc_errors::SuggestionStyle::ShowCode);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1679#[diag(
1680    "panic message contains {$count ->
1681        [one] a brace
1682        *[other] braces
1683    }"
1684)]
1685#[note("this message is not used as a format string, but will be in Rust 2021")]
1686pub(crate) struct NonFmtPanicBraces {
1687    pub count: usize,
1688    #[suggestion(
1689        "add a \"{\"{\"}{\"}\"}\" format string to use the message literally",
1690        code = "\"{{}}\", ",
1691        applicability = "machine-applicable"
1692    )]
1693    pub suggestion: Option<Span>,
1694}
1695
1696// nonstandard_style.rs
1697#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            NonCamelCaseType<'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 {
                    NonCamelCaseType {
                        sort: __binding_0, name: __binding_1, sub: __binding_2 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$sort} `{$name}` should have an upper camel case name")));
                        ;
                        diag.arg("sort", __binding_0);
                        diag.arg("name", __binding_1);
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1698#[diag("{$sort} `{$name}` should have an upper camel case name")]
1699pub(crate) struct NonCamelCaseType<'a> {
1700    pub sort: &'a str,
1701    pub name: &'a str,
1702    #[subdiagnostic]
1703    pub sub: NonCamelCaseTypeSub,
1704}
1705
1706#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for NonCamelCaseTypeSub {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    NonCamelCaseTypeSub::Label { 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("should have an UpperCamelCase name")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                    NonCamelCaseTypeSub::Suggestion {
                        span: __binding_0, replace: __binding_1 } => {
                        let __code_45 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_1))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("convert the identifier to upper camel case")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_45, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
1707pub(crate) enum NonCamelCaseTypeSub {
1708    #[label("should have an UpperCamelCase name")]
1709    Label {
1710        #[primary_span]
1711        span: Span,
1712    },
1713    #[suggestion(
1714        "convert the identifier to upper camel case",
1715        code = "{replace}",
1716        applicability = "maybe-incorrect"
1717    )]
1718    Suggestion {
1719        #[primary_span]
1720        span: Span,
1721        replace: String,
1722    },
1723}
1724
1725#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            NonSnakeCaseDiag<'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 {
                    NonSnakeCaseDiag {
                        sort: __binding_0, name: __binding_1, sub: __binding_2 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$sort} `{$name}` should have a snake case name")));
                        ;
                        diag.arg("sort", __binding_0);
                        diag.arg("name", __binding_1);
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1726#[diag("{$sort} `{$name}` should have a snake case name")]
1727pub(crate) struct NonSnakeCaseDiag<'a> {
1728    pub sort: &'a str,
1729    pub name: &'a str,
1730    #[subdiagnostic]
1731    pub sub: NonSnakeCaseDiagSub,
1732}
1733
1734pub(crate) enum NonSnakeCaseDiagSub {
1735    Label { span: Span },
1736    Help { sc: String },
1737    RenameOrConvertSuggestion { span: Span, suggestion: Ident },
1738    ConvertSuggestion { span: Span, suggestion: String },
1739    SuggestionAndNote { sc: String, span: Span },
1740}
1741
1742impl Subdiagnostic for NonSnakeCaseDiagSub {
1743    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1744        match self {
1745            NonSnakeCaseDiagSub::Label { span } => {
1746                diag.span_label(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("should have a snake_case name"))msg!("should have a snake_case name"));
1747            }
1748            NonSnakeCaseDiagSub::Help { sc } => {
1749                diag.arg("sc", sc);
1750                diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("convert the identifier to snake case: `{$sc}`"))msg!("convert the identifier to snake case: `{$sc}`"));
1751            }
1752            NonSnakeCaseDiagSub::ConvertSuggestion { span, suggestion } => {
1753                diag.span_suggestion(
1754                    span,
1755                    rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("convert the identifier to snake case"))msg!("convert the identifier to snake case"),
1756                    suggestion,
1757                    Applicability::MaybeIncorrect,
1758                );
1759            }
1760            NonSnakeCaseDiagSub::RenameOrConvertSuggestion { span, suggestion } => {
1761                diag.span_suggestion(
1762                    span,
1763                    rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("rename the identifier or convert it to a snake case raw identifier"))msg!("rename the identifier or convert it to a snake case raw identifier"),
1764                    suggestion,
1765                    Applicability::MaybeIncorrect,
1766                );
1767            }
1768            NonSnakeCaseDiagSub::SuggestionAndNote { sc, span } => {
1769                diag.arg("sc", sc);
1770                diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$sc}` cannot be used as a raw identifier"))msg!("`{$sc}` cannot be used as a raw identifier"));
1771                diag.span_suggestion(
1772                    span,
1773                    rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("rename the identifier"))msg!("rename the identifier"),
1774                    "",
1775                    Applicability::MaybeIncorrect,
1776                );
1777            }
1778        }
1779    }
1780}
1781
1782#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            NonUpperCaseGlobal<'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 {
                    NonUpperCaseGlobal {
                        sort: __binding_0,
                        name: __binding_1,
                        sub: __binding_2,
                        usages: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$sort} `{$name}` should have an upper case name")));
                        ;
                        diag.arg("sort", __binding_0);
                        diag.arg("name", __binding_1);
                        diag.subdiagnostic(__binding_2);
                        for __binding_3 in __binding_3 {
                            diag.subdiagnostic(__binding_3);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1783#[diag("{$sort} `{$name}` should have an upper case name")]
1784pub(crate) struct NonUpperCaseGlobal<'a> {
1785    pub sort: &'a str,
1786    pub name: &'a str,
1787    #[subdiagnostic]
1788    pub sub: NonUpperCaseGlobalSub,
1789    #[subdiagnostic]
1790    pub usages: Vec<NonUpperCaseGlobalSubTool>,
1791}
1792
1793#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for NonUpperCaseGlobalSub {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    NonUpperCaseGlobalSub::Label { 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("should have an UPPER_CASE name")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                    NonUpperCaseGlobalSub::Suggestion {
                        span: __binding_0,
                        applicability: __binding_1,
                        replace: __binding_2 } => {
                        let __code_46 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_2))
                                            })].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("convert the identifier to upper case")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_46, __binding_1,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
1794pub(crate) enum NonUpperCaseGlobalSub {
1795    #[label("should have an UPPER_CASE name")]
1796    Label {
1797        #[primary_span]
1798        span: Span,
1799    },
1800    #[suggestion("convert the identifier to upper case", code = "{replace}")]
1801    Suggestion {
1802        #[primary_span]
1803        span: Span,
1804        #[applicability]
1805        applicability: Applicability,
1806        replace: String,
1807    },
1808}
1809
1810#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for NonUpperCaseGlobalSubTool {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    NonUpperCaseGlobalSubTool {
                        span: __binding_0, replace: __binding_1 } => {
                        let __code_47 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_1))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("convert the identifier to upper case")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_47, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::CompletelyHidden);
                    }
                }
            }
        }
    };Subdiagnostic)]
1811#[suggestion(
1812    "convert the identifier to upper case",
1813    code = "{replace}",
1814    applicability = "machine-applicable",
1815    style = "tool-only"
1816)]
1817pub(crate) struct NonUpperCaseGlobalSubTool {
1818    #[primary_span]
1819    pub(crate) span: Span,
1820    pub(crate) replace: String,
1821}
1822
1823// noop_method_call.rs
1824#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            NoopMethodCallDiag<'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 {
                    NoopMethodCallDiag {
                        method: __binding_0,
                        orig_ty: __binding_1,
                        trait_: __binding_2,
                        label: __binding_3,
                        suggest_derive: __binding_4 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to `.{$method}()` on a reference in this situation does nothing")));
                        let __code_48 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(""))
                                            })].into_iter();
                        let __code_49 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("#[derive(Clone)]\n"))
                                            })].into_iter();
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type `{$orig_ty}` does not implement `{$trait_}`, so calling `{$method}` on `&{$orig_ty}` copies the reference, which does not do anything and can be removed")));
                        ;
                        diag.arg("method", __binding_0);
                        diag.arg("orig_ty", __binding_1);
                        diag.arg("trait_", __binding_2);
                        diag.span_suggestions_with_style(__binding_3,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove this redundant call")),
                            __code_48, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                        if let Some(__binding_4) = __binding_4 {
                            diag.span_suggestions_with_style(__binding_4,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you meant to clone `{$orig_ty}`, implement `Clone` for it")),
                                __code_49, rustc_errors::Applicability::MaybeIncorrect,
                                rustc_errors::SuggestionStyle::ShowCode);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1825#[diag("call to `.{$method}()` on a reference in this situation does nothing")]
1826#[note(
1827    "the type `{$orig_ty}` does not implement `{$trait_}`, so calling `{$method}` on `&{$orig_ty}` copies the reference, which does not do anything and can be removed"
1828)]
1829pub(crate) struct NoopMethodCallDiag<'a> {
1830    pub method: Ident,
1831    pub orig_ty: Ty<'a>,
1832    pub trait_: Symbol,
1833    #[suggestion("remove this redundant call", code = "", applicability = "machine-applicable")]
1834    pub label: Span,
1835    #[suggestion(
1836        "if you meant to clone `{$orig_ty}`, implement `Clone` for it",
1837        code = "#[derive(Clone)]\n",
1838        applicability = "maybe-incorrect"
1839    )]
1840    pub suggest_derive: Option<Span>,
1841}
1842
1843#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            SuspiciousDoubleRefDerefDiag<'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 {
                    SuspiciousDoubleRefDerefDiag { ty: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using `.deref()` on a double reference, which returns `{$ty}` instead of dereferencing the inner type")));
                        ;
                        diag.arg("ty", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1844#[diag(
1845    "using `.deref()` on a double reference, which returns `{$ty}` instead of dereferencing the inner type"
1846)]
1847pub(crate) struct SuspiciousDoubleRefDerefDiag<'a> {
1848    pub ty: Ty<'a>,
1849}
1850
1851#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            SuspiciousDoubleRefCloneDiag<'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 {
                    SuspiciousDoubleRefCloneDiag { ty: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using `.clone()` on a double reference, which returns `{$ty}` instead of cloning the inner type")));
                        ;
                        diag.arg("ty", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1852#[diag(
1853    "using `.clone()` on a double reference, which returns `{$ty}` instead of cloning the inner type"
1854)]
1855pub(crate) struct SuspiciousDoubleRefCloneDiag<'a> {
1856    pub ty: Ty<'a>,
1857}
1858
1859// non_local_defs.rs
1860pub(crate) enum NonLocalDefinitionsDiag {
1861    Impl {
1862        depth: u32,
1863        body_kind_descr: &'static str,
1864        body_name: String,
1865        cargo_update: Option<NonLocalDefinitionsCargoUpdateNote>,
1866        const_anon: Option<Option<Span>>,
1867        doctest: bool,
1868        macro_to_change: Option<(String, &'static str)>,
1869    },
1870    MacroRules {
1871        depth: u32,
1872        body_kind_descr: &'static str,
1873        body_name: String,
1874        doctest: bool,
1875        cargo_update: Option<NonLocalDefinitionsCargoUpdateNote>,
1876    },
1877}
1878
1879impl<'a> Diagnostic<'a, ()> for NonLocalDefinitionsDiag {
1880    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
1881        let mut diag = Diag::new(dcx, level, "");
1882        match self {
1883            NonLocalDefinitionsDiag::Impl {
1884                depth,
1885                body_kind_descr,
1886                body_name,
1887                cargo_update,
1888                const_anon,
1889                doctest,
1890                macro_to_change,
1891            } => {
1892                diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-local `impl` definition, `impl` blocks should be written at the same level as their item"))msg!("non-local `impl` definition, `impl` blocks should be written at the same level as their item"));
1893                diag.arg("depth", depth);
1894                diag.arg("body_kind_descr", body_kind_descr);
1895                diag.arg("body_name", body_name);
1896
1897                if let Some((macro_to_change, macro_kind)) = macro_to_change {
1898                    diag.arg("macro_to_change", macro_to_change);
1899                    diag.arg("macro_kind", macro_kind);
1900                    diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$macro_kind} `{$macro_to_change}` defines the non-local `impl`, and may need to be changed"))msg!("the {$macro_kind} `{$macro_to_change}` defines the non-local `impl`, and may need to be changed"));
1901                }
1902                if let Some(cargo_update) = cargo_update {
1903                    diag.subdiagnostic(cargo_update);
1904                }
1905
1906                diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`"))msg!("an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`"));
1907
1908                if doctest {
1909                    diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("make this doc-test a standalone test with its own `fn main() {\"{\"} ... {\"}\"}`"))msg!("make this doc-test a standalone test with its own `fn main() {\"{\"} ... {\"}\"}`"));
1910                }
1911
1912                if let Some(const_anon) = const_anon {
1913                    diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("items in an anonymous const item (`const _: () = {\"{\"} ... {\"}\"}`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint"))msg!("items in an anonymous const item (`const _: () = {\"{\"} ... {\"}\"}`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint"));
1914                    if let Some(const_anon) = const_anon {
1915                        diag.span_suggestion(
1916                            const_anon,
1917                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use a const-anon item to suppress this lint"))msg!("use a const-anon item to suppress this lint"),
1918                            "_",
1919                            Applicability::MachineApplicable,
1920                        );
1921                    }
1922                }
1923            }
1924            NonLocalDefinitionsDiag::MacroRules {
1925                depth,
1926                body_kind_descr,
1927                body_name,
1928                doctest,
1929                cargo_update,
1930            } => {
1931                diag.primary_message(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module"))msg!("non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module"));
1932                diag.arg("depth", depth);
1933                diag.arg("body_kind_descr", body_kind_descr);
1934                diag.arg("body_name", body_name);
1935
1936                if doctest {
1937                    diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `#[macro_export]` or make this doc-test a standalone test with its own `fn main() {\"{\"} ... {\"}\"}`"))msg!(r#"remove the `#[macro_export]` or make this doc-test a standalone test with its own `fn main() {"{"} ... {"}"}`"#));
1938                } else {
1939                    diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `#[macro_export]` or move this `macro_rules!` outside the of the current {$body_kind_descr} {$depth ->\n                            [one] `{$body_name}`\n                            *[other] `{$body_name}` and up {$depth} bodies\n                        }"))msg!(
1940                        "remove the `#[macro_export]` or move this `macro_rules!` outside the of the current {$body_kind_descr} {$depth ->
1941                            [one] `{$body_name}`
1942                            *[other] `{$body_name}` and up {$depth} bodies
1943                        }"
1944                    ));
1945                }
1946
1947                diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute"))msg!("a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute"));
1948
1949                if let Some(cargo_update) = cargo_update {
1950                    diag.subdiagnostic(cargo_update);
1951                }
1952            }
1953        }
1954        diag
1955    }
1956}
1957
1958#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for
            NonLocalDefinitionsCargoUpdateNote {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    NonLocalDefinitionsCargoUpdateNote {
                        macro_kind: __binding_0,
                        macro_name: __binding_1,
                        crate_name: __binding_2 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("macro_kind".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("macro_name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("crate_name".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("the {$macro_kind} `{$macro_name}` may come from an old version of the `{$crate_name}` crate, try updating your dependency with `cargo update -p {$crate_name}`")),
                                &sub_args);
                        diag.note(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
1959#[note(
1960    "the {$macro_kind} `{$macro_name}` may come from an old version of the `{$crate_name}` crate, try updating your dependency with `cargo update -p {$crate_name}`"
1961)]
1962pub(crate) struct NonLocalDefinitionsCargoUpdateNote {
1963    pub macro_kind: &'static str,
1964    pub macro_name: Symbol,
1965    pub crate_name: Symbol,
1966}
1967
1968// precedence.rs
1969#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            AmbiguousNegativeLiteralsDiag 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 {
                    AmbiguousNegativeLiteralsDiag {
                        negative_literal: __binding_0, current_behavior: __binding_1
                        } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-` has lower precedence than method calls, which might be unexpected")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("e.g. `-4.abs()` equals `-4`; while `(-4).abs()` equals `4`")));
                        ;
                        diag.subdiagnostic(__binding_0);
                        diag.subdiagnostic(__binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1970#[diag("`-` has lower precedence than method calls, which might be unexpected")]
1971#[note("e.g. `-4.abs()` equals `-4`; while `(-4).abs()` equals `4`")]
1972pub(crate) struct AmbiguousNegativeLiteralsDiag {
1973    #[subdiagnostic]
1974    pub negative_literal: AmbiguousNegativeLiteralsNegativeLiteralSuggestion,
1975    #[subdiagnostic]
1976    pub current_behavior: AmbiguousNegativeLiteralsCurrentBehaviorSuggestion,
1977}
1978
1979#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for
            AmbiguousNegativeLiteralsNegativeLiteralSuggestion {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    AmbiguousNegativeLiteralsNegativeLiteralSuggestion {
                        start_span: __binding_0, end_span: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_50 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("("))
                                });
                        let __code_51 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        suggestions.push((__binding_0, __code_50));
                        suggestions.push((__binding_1, __code_51));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add parentheses around the `-` and the literal to call the method on a negative literal")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
1980#[multipart_suggestion(
1981    "add parentheses around the `-` and the literal to call the method on a negative literal",
1982    applicability = "maybe-incorrect"
1983)]
1984pub(crate) struct AmbiguousNegativeLiteralsNegativeLiteralSuggestion {
1985    #[suggestion_part(code = "(")]
1986    pub start_span: Span,
1987    #[suggestion_part(code = ")")]
1988    pub end_span: Span,
1989}
1990
1991#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for
            AmbiguousNegativeLiteralsCurrentBehaviorSuggestion {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    AmbiguousNegativeLiteralsCurrentBehaviorSuggestion {
                        start_span: __binding_0, end_span: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_52 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("("))
                                });
                        let __code_53 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        suggestions.push((__binding_0, __code_52));
                        suggestions.push((__binding_1, __code_53));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add parentheses around the literal and the method call to keep the current behavior")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
1992#[multipart_suggestion(
1993    "add parentheses around the literal and the method call to keep the current behavior",
1994    applicability = "maybe-incorrect"
1995)]
1996pub(crate) struct AmbiguousNegativeLiteralsCurrentBehaviorSuggestion {
1997    #[suggestion_part(code = "(")]
1998    pub start_span: Span,
1999    #[suggestion_part(code = ")")]
2000    pub end_span: Span,
2001}
2002
2003// disallowed_pass_by_ref.rs
2004#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            DisallowedPassByRefDiag 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 {
                    DisallowedPassByRefDiag {
                        ty: __binding_0, suggestion: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("passing `{$ty}` by reference")));
                        let __code_54 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_0))
                                            })].into_iter();
                        ;
                        diag.arg("ty", __binding_0);
                        diag.span_suggestions_with_style(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try passing by value")),
                            __code_54, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2005#[diag("passing `{$ty}` by reference")]
2006pub(crate) struct DisallowedPassByRefDiag {
2007    pub ty: String,
2008    #[suggestion("try passing by value", code = "{ty}", applicability = "maybe-incorrect")]
2009    pub suggestion: Span,
2010}
2011
2012// redundant_semicolon.rs
2013#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            RedundantSemicolonsDiag 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 {
                    RedundantSemicolonsDiag {
                        multiple: __binding_0, suggestion: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unnecessary trailing {$multiple ->\n        [true] semicolons\n        *[false] semicolon\n    }")));
                        ;
                        diag.arg("multiple", __binding_0);
                        if let Some(__binding_1) = __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2014#[diag(
2015    "unnecessary trailing {$multiple ->
2016        [true] semicolons
2017        *[false] semicolon
2018    }"
2019)]
2020pub(crate) struct RedundantSemicolonsDiag {
2021    pub multiple: bool,
2022    #[subdiagnostic]
2023    pub suggestion: Option<RedundantSemicolonsSuggestion>,
2024}
2025
2026#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for RedundantSemicolonsSuggestion {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    RedundantSemicolonsSuggestion {
                        multiple_semicolons: __binding_0, span: __binding_1 } => {
                        let __code_55 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(""))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("multiple_semicolons".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("remove {$multiple_semicolons ->\n        [true] these semicolons\n        *[false] this semicolon\n    }")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_1, __message,
                            __code_55, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
2027#[suggestion(
2028    "remove {$multiple_semicolons ->
2029        [true] these semicolons
2030        *[false] this semicolon
2031    }",
2032    code = "",
2033    applicability = "maybe-incorrect"
2034)]
2035pub(crate) struct RedundantSemicolonsSuggestion {
2036    pub multiple_semicolons: bool,
2037    #[primary_span]
2038    pub span: Span,
2039}
2040
2041// traits.rs
2042pub(crate) struct DropTraitConstraintsDiag<'a> {
2043    pub clause: Clause<'a>,
2044    pub tcx: TyCtxt<'a>,
2045    pub def_id: DefId,
2046}
2047
2048// Needed for def_path_str
2049impl<'a> Diagnostic<'a, ()> for DropTraitConstraintsDiag<'_> {
2050    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
2051        Diag::new(dcx, level, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("bounds on `{$clause}` are most likely incorrect, consider instead using `{$needs_drop}` to detect whether a type can be trivially dropped"))msg!("bounds on `{$clause}` are most likely incorrect, consider instead using `{$needs_drop}` to detect whether a type can be trivially dropped"))
2052            .with_arg("clause", self.clause)
2053            .with_arg("needs_drop", self.tcx.def_path_str(self.def_id))
2054    }
2055}
2056
2057pub(crate) struct DropGlue<'a> {
2058    pub tcx: TyCtxt<'a>,
2059    pub def_id: DefId,
2060}
2061
2062// Needed for def_path_str
2063impl<'a> Diagnostic<'a, ()> for DropGlue<'_> {
2064    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
2065        Diag::new(dcx, level, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("types that do not implement `Drop` can still have drop glue, consider instead using `{$needs_drop}` to detect whether a type is trivially dropped"))msg!("types that do not implement `Drop` can still have drop glue, consider instead using `{$needs_drop}` to detect whether a type is trivially dropped"))
2066            .with_arg("needs_drop", self.tcx.def_path_str(self.def_id))
2067    }
2068}
2069
2070// transmute.rs
2071#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            IntegerToPtrTransmutes<'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 {
                    IntegerToPtrTransmutes { suggestion: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("transmuting an integer to a pointer creates a pointer without provenance")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is dangerous because dereferencing the resulting pointer is undefined behavior")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("exposed provenance semantics can be used to create a pointer based on some previously exposed provenance")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut`")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers>")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>")));
                        ;
                        if let Some(__binding_0) = __binding_0 {
                            diag.subdiagnostic(__binding_0);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2072#[diag("transmuting an integer to a pointer creates a pointer without provenance")]
2073#[note("this is dangerous because dereferencing the resulting pointer is undefined behavior")]
2074#[note(
2075    "exposed provenance semantics can be used to create a pointer based on some previously exposed provenance"
2076)]
2077#[help(
2078    "if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut`"
2079)]
2080#[help(
2081    "for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers>"
2082)]
2083#[help(
2084    "for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>"
2085)]
2086pub(crate) struct IntegerToPtrTransmutes<'tcx> {
2087    #[subdiagnostic]
2088    pub suggestion: Option<IntegerToPtrTransmutesSuggestion<'tcx>>,
2089}
2090
2091#[derive(const _: () =
    {
        impl<'tcx> rustc_errors::Subdiagnostic for
            IntegerToPtrTransmutesSuggestion<'tcx> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    IntegerToPtrTransmutesSuggestion::ToPtr {
                        dst: __binding_0,
                        suffix: __binding_1,
                        start_call: __binding_2 } => {
                        let mut suggestions = Vec::new();
                        let __code_56 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("std::ptr::with_exposed_provenance{1}::<{0}>(",
                                            __binding_0, __binding_1))
                                });
                        suggestions.push((__binding_2, __code_56));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("suffix".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 `std::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    IntegerToPtrTransmutesSuggestion::ToRef {
                        dst: __binding_0,
                        suffix: __binding_1,
                        ref_mutbl: __binding_2,
                        start_call: __binding_3 } => {
                        let mut suggestions = Vec::new();
                        let __code_57 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("&{1}*std::ptr::with_exposed_provenance{2}::<{0}>(",
                                            __binding_0, __binding_2, __binding_1))
                                });
                        suggestions.push((__binding_3, __code_57));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("suffix".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 `std::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
2092pub(crate) enum IntegerToPtrTransmutesSuggestion<'tcx> {
2093    #[multipart_suggestion(
2094        "use `std::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance",
2095        applicability = "machine-applicable",
2096        style = "verbose"
2097    )]
2098    ToPtr {
2099        dst: Ty<'tcx>,
2100        suffix: &'static str,
2101        #[suggestion_part(code = "std::ptr::with_exposed_provenance{suffix}::<{dst}>(")]
2102        start_call: Span,
2103    },
2104    #[multipart_suggestion(
2105        "use `std::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance",
2106        applicability = "machine-applicable",
2107        style = "verbose"
2108    )]
2109    ToRef {
2110        dst: Ty<'tcx>,
2111        suffix: &'static str,
2112        ref_mutbl: &'static str,
2113        #[suggestion_part(
2114            code = "&{ref_mutbl}*std::ptr::with_exposed_provenance{suffix}::<{dst}>("
2115        )]
2116        start_call: Span,
2117    },
2118}
2119
2120// types.rs
2121#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            RangeEndpointOutOfRange<'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 {
                    RangeEndpointOutOfRange { ty: __binding_0, sub: __binding_1
                        } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("range endpoint is out of range for `{$ty}`")));
                        ;
                        diag.arg("ty", __binding_0);
                        diag.subdiagnostic(__binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2122#[diag("range endpoint is out of range for `{$ty}`")]
2123pub(crate) struct RangeEndpointOutOfRange<'a> {
2124    pub ty: &'a str,
2125    #[subdiagnostic]
2126    pub sub: UseInclusiveRange<'a>,
2127}
2128
2129#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for UseInclusiveRange<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    UseInclusiveRange::WithoutParen {
                        sugg: __binding_0,
                        start: __binding_1,
                        literal: __binding_2,
                        suffix: __binding_3 } => {
                        let __code_58 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{1}..={0}{2}",
                                                        __binding_2, __binding_1, __binding_3))
                                            })].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 an inclusive range instead")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_58, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    UseInclusiveRange::WithParen {
                        eq_sugg: __binding_0,
                        lit_sugg: __binding_1,
                        literal: __binding_2,
                        suffix: __binding_3 } => {
                        let mut suggestions = Vec::new();
                        let __code_59 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("="))
                                });
                        let __code_60 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{0}{1}", __binding_2,
                                            __binding_3))
                                });
                        suggestions.push((__binding_0, __code_59));
                        suggestions.push((__binding_1, __code_60));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use an inclusive range instead")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
2130pub(crate) enum UseInclusiveRange<'a> {
2131    #[suggestion(
2132        "use an inclusive range instead",
2133        code = "{start}..={literal}{suffix}",
2134        applicability = "machine-applicable"
2135    )]
2136    WithoutParen {
2137        #[primary_span]
2138        sugg: Span,
2139        start: String,
2140        literal: u128,
2141        suffix: &'a str,
2142    },
2143    #[multipart_suggestion("use an inclusive range instead", applicability = "machine-applicable")]
2144    WithParen {
2145        #[suggestion_part(code = "=")]
2146        eq_sugg: Span,
2147        #[suggestion_part(code = "{literal}{suffix}")]
2148        lit_sugg: Span,
2149        literal: u128,
2150        suffix: &'a str,
2151    },
2152}
2153
2154#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            OverflowingBinHex<'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 {
                    OverflowingBinHex {
                        ty: __binding_0,
                        sign: __binding_1,
                        sub: __binding_2,
                        sign_bit_sub: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("literal out of range for `{$ty}`")));
                        ;
                        diag.arg("ty", __binding_0);
                        diag.subdiagnostic(__binding_1);
                        if let Some(__binding_2) = __binding_2 {
                            diag.subdiagnostic(__binding_2);
                        }
                        if let Some(__binding_3) = __binding_3 {
                            diag.subdiagnostic(__binding_3);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2155#[diag("literal out of range for `{$ty}`")]
2156pub(crate) struct OverflowingBinHex<'a> {
2157    pub ty: &'a str,
2158    #[subdiagnostic]
2159    pub sign: OverflowingBinHexSign<'a>,
2160    #[subdiagnostic]
2161    pub sub: Option<OverflowingBinHexSub<'a>>,
2162    #[subdiagnostic]
2163    pub sign_bit_sub: Option<OverflowingBinHexSignBitSub<'a>>,
2164}
2165
2166#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for OverflowingBinHexSign<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    OverflowingBinHexSign::Positive {
                        lit: __binding_0,
                        ty: __binding_1,
                        actually: __binding_2,
                        dec: __binding_3 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("lit".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("ty".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("actually".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("dec".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("the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}` and will become `{$actually}{$ty}`")),
                                &sub_args);
                        diag.note(__message);
                    }
                    OverflowingBinHexSign::Negative {
                        lit: __binding_0,
                        ty: __binding_1,
                        actually: __binding_2,
                        dec: __binding_3 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("lit".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("ty".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("actually".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("dec".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("the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}`")),
                                &sub_args);
                        diag.note(__message);
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("and the value `-{$lit}` will become `{$actually}{$ty}`")),
                                &sub_args);
                        diag.note(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
2167pub(crate) enum OverflowingBinHexSign<'a> {
2168    #[note(
2169        "the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}` and will become `{$actually}{$ty}`"
2170    )]
2171    Positive { lit: String, ty: &'a str, actually: String, dec: u128 },
2172    #[note("the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}`")]
2173    #[note("and the value `-{$lit}` will become `{$actually}{$ty}`")]
2174    Negative { lit: String, ty: &'a str, actually: String, dec: u128 },
2175}
2176
2177#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for OverflowingBinHexSub<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    OverflowingBinHexSub::Suggestion {
                        span: __binding_0,
                        suggestion_ty: __binding_1,
                        sans_suffix: __binding_2 } => {
                        let __code_61 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}{1}", __binding_2,
                                                        __binding_1))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("suggestion_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("consider using the type `{$suggestion_ty}` instead")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_61, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    OverflowingBinHexSub::Help { suggestion_ty: __binding_0 } =>
                        {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("suggestion_ty".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("consider using the type `{$suggestion_ty}` instead")),
                                &sub_args);
                        diag.help(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
2178pub(crate) enum OverflowingBinHexSub<'a> {
2179    #[suggestion(
2180        "consider using the type `{$suggestion_ty}` instead",
2181        code = "{sans_suffix}{suggestion_ty}",
2182        applicability = "machine-applicable"
2183    )]
2184    Suggestion {
2185        #[primary_span]
2186        span: Span,
2187        suggestion_ty: &'a str,
2188        sans_suffix: &'a str,
2189    },
2190    #[help("consider using the type `{$suggestion_ty}` instead")]
2191    Help { suggestion_ty: &'a str },
2192}
2193
2194#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for
            OverflowingBinHexSignBitSub<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    OverflowingBinHexSignBitSub::CastSigned {
                        span: __binding_0,
                        lit_no_suffix: __binding_1,
                        negative_val: __binding_2,
                        uint_ty: __binding_3,
                        int_ty: __binding_4 } => {
                        let __code_62 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}{1}.cast_signed()",
                                                        __binding_1, __binding_3))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("negative_val".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("uint_ty".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        sub_args.insert("int_ty".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("to use as a negative number (decimal `{$negative_val}`), consider using the type `{$uint_ty}` for the literal and cast it to `{$int_ty}`")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_62, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    OverflowingBinHexSignBitSub::AsCast {
                        span: __binding_0,
                        lit_no_suffix: __binding_1,
                        negative_val: __binding_2,
                        uint_ty: __binding_3,
                        int_ty: __binding_4 } => {
                        let __code_63 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{1}{2} as {0}",
                                                        __binding_4, __binding_1, __binding_3))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("negative_val".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("uint_ty".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        sub_args.insert("int_ty".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("to use as a negative number (decimal `{$negative_val}`), consider using the type `{$uint_ty}` for the literal and cast it to `{$int_ty}`")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_63, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
2195pub(crate) enum OverflowingBinHexSignBitSub<'a> {
2196    #[suggestion(
2197        "to use as a negative number (decimal `{$negative_val}`), consider using the type `{$uint_ty}` for the literal and cast it to `{$int_ty}`",
2198        code = "{lit_no_suffix}{uint_ty}.cast_signed()",
2199        applicability = "maybe-incorrect"
2200    )]
2201    CastSigned {
2202        #[primary_span]
2203        span: Span,
2204        lit_no_suffix: &'a str,
2205        negative_val: String,
2206        uint_ty: &'a str,
2207        int_ty: &'a str,
2208    },
2209    #[suggestion(
2210        "to use as a negative number (decimal `{$negative_val}`), consider using the type `{$uint_ty}` for the literal and cast it to `{$int_ty}`",
2211        code = "{lit_no_suffix}{uint_ty} as {int_ty}",
2212        applicability = "maybe-incorrect"
2213    )]
2214    AsCast {
2215        #[primary_span]
2216        span: Span,
2217        lit_no_suffix: &'a str,
2218        negative_val: String,
2219        uint_ty: &'a str,
2220        int_ty: &'a str,
2221    },
2222}
2223
2224#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            OverflowingInt<'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 {
                    OverflowingInt {
                        ty: __binding_0,
                        lit: __binding_1,
                        min: __binding_2,
                        max: __binding_3,
                        help: __binding_4 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("literal out of range for `{$ty}`")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the literal `{$lit}` does not fit into the type `{$ty}` whose range is `{$min}..={$max}`")));
                        ;
                        diag.arg("ty", __binding_0);
                        diag.arg("lit", __binding_1);
                        diag.arg("min", __binding_2);
                        diag.arg("max", __binding_3);
                        if let Some(__binding_4) = __binding_4 {
                            diag.subdiagnostic(__binding_4);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2225#[diag("literal out of range for `{$ty}`")]
2226#[note("the literal `{$lit}` does not fit into the type `{$ty}` whose range is `{$min}..={$max}`")]
2227pub(crate) struct OverflowingInt<'a> {
2228    pub ty: &'a str,
2229    pub lit: String,
2230    pub min: i128,
2231    pub max: u128,
2232    #[subdiagnostic]
2233    pub help: Option<OverflowingIntHelp<'a>>,
2234}
2235
2236#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for OverflowingIntHelp<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    OverflowingIntHelp { suggestion_ty: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("suggestion_ty".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("consider using the type `{$suggestion_ty}` instead")),
                                &sub_args);
                        diag.help(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
2237#[help("consider using the type `{$suggestion_ty}` instead")]
2238pub(crate) struct OverflowingIntHelp<'a> {
2239    pub suggestion_ty: &'a str,
2240}
2241
2242#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            OnlyCastu8ToChar 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 {
                    OnlyCastu8ToChar { span: __binding_0, literal: __binding_1 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only `u8` can be cast into `char`")));
                        let __code_64 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("\'\\u{{{0:X}}}\'",
                                                        __binding_1))
                                            })].into_iter();
                        ;
                        diag.span_suggestions_with_style(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use a `char` literal instead")),
                            __code_64, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2243#[diag("only `u8` can be cast into `char`")]
2244pub(crate) struct OnlyCastu8ToChar {
2245    #[suggestion(
2246        "use a `char` literal instead",
2247        code = "'\\u{{{literal:X}}}'",
2248        applicability = "machine-applicable"
2249    )]
2250    pub span: Span,
2251    pub literal: u128,
2252}
2253
2254#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            OverflowingUInt<'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 {
                    OverflowingUInt {
                        ty: __binding_0,
                        lit: __binding_1,
                        min: __binding_2,
                        max: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("literal out of range for `{$ty}`")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the literal `{$lit}` does not fit into the type `{$ty}` whose range is `{$min}..={$max}`")));
                        ;
                        diag.arg("ty", __binding_0);
                        diag.arg("lit", __binding_1);
                        diag.arg("min", __binding_2);
                        diag.arg("max", __binding_3);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2255#[diag("literal out of range for `{$ty}`")]
2256#[note("the literal `{$lit}` does not fit into the type `{$ty}` whose range is `{$min}..={$max}`")]
2257pub(crate) struct OverflowingUInt<'a> {
2258    pub ty: &'a str,
2259    pub lit: String,
2260    pub min: u128,
2261    pub max: u128,
2262}
2263
2264#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            OverflowingLiteral<'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 {
                    OverflowingLiteral { ty: __binding_0, lit: __binding_1 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("literal out of range for `{$ty}`")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the literal `{$lit}` does not fit into the type `{$ty}` and will be converted to `{$ty}::INFINITY`")));
                        ;
                        diag.arg("ty", __binding_0);
                        diag.arg("lit", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2265#[diag("literal out of range for `{$ty}`")]
2266#[note(
2267    "the literal `{$lit}` does not fit into the type `{$ty}` and will be converted to `{$ty}::INFINITY`"
2268)]
2269pub(crate) struct OverflowingLiteral<'a> {
2270    pub ty: &'a str,
2271    pub lit: String,
2272}
2273
2274#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SurrogateCharCast 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 {
                    SurrogateCharCast { literal: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("surrogate values are not valid for `char`")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`0xD800..=0xDFFF` are reserved for Unicode surrogates and are not valid `char` values")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2275#[diag("surrogate values are not valid for `char`")]
2276#[note("`0xD800..=0xDFFF` are reserved for Unicode surrogates and are not valid `char` values")]
2277pub(crate) struct SurrogateCharCast {
2278    pub literal: u128,
2279}
2280
2281#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            TooLargeCharCast 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 {
                    TooLargeCharCast { literal: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("value exceeds maximum `char` value")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("maximum valid `char` value is `0x10FFFF`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2282#[diag("value exceeds maximum `char` value")]
2283#[note("maximum valid `char` value is `0x10FFFF`")]
2284pub(crate) struct TooLargeCharCast {
2285    pub literal: u128,
2286}
2287
2288#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UsesPowerAlignment 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 {
                    UsesPowerAlignment => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2289#[diag(
2290    "repr(C) does not follow the power alignment rule. This may affect platform C ABI compatibility for this type"
2291)]
2292pub(crate) struct UsesPowerAlignment;
2293
2294#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnusedComparisons 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 {
                    UnusedComparisons => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("comparison is useless due to type limits")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2295#[diag("comparison is useless due to type limits")]
2296pub(crate) struct UnusedComparisons;
2297
2298#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidNanComparisons 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 {
                    InvalidNanComparisons::EqNe { suggestion: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect NaN comparison, NaN cannot be directly compared to itself")));
                        ;
                        diag.subdiagnostic(__binding_0);
                        diag
                    }
                    InvalidNanComparisons::LtLeGtGe => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incorrect NaN comparison, NaN is not orderable")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2299pub(crate) enum InvalidNanComparisons {
2300    #[diag("incorrect NaN comparison, NaN cannot be directly compared to itself")]
2301    EqNe {
2302        #[subdiagnostic]
2303        suggestion: InvalidNanComparisonsSuggestion,
2304    },
2305    #[diag("incorrect NaN comparison, NaN is not orderable")]
2306    LtLeGtGe,
2307}
2308
2309#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for InvalidNanComparisonsSuggestion {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    InvalidNanComparisonsSuggestion::Spanful {
                        neg: __binding_0,
                        float: __binding_1,
                        nan_plus_binop: __binding_2 } => {
                        let mut suggestions = Vec::new();
                        let __code_65 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("!"))
                                });
                        let __code_66 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(".is_nan()"))
                                });
                        let __code_67 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(""))
                                });
                        if let Some(__binding_0) = __binding_0 {
                            suggestions.push((__binding_0, __code_65));
                        }
                        suggestions.push((__binding_1, __code_66));
                        suggestions.push((__binding_2, __code_67));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `f32::is_nan()` or `f64::is_nan()` instead")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    InvalidNanComparisonsSuggestion::Spanless => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `f32::is_nan()` or `f64::is_nan()` instead")),
                                &sub_args);
                        diag.help(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
2310pub(crate) enum InvalidNanComparisonsSuggestion {
2311    #[multipart_suggestion(
2312        "use `f32::is_nan()` or `f64::is_nan()` instead",
2313        style = "verbose",
2314        applicability = "machine-applicable"
2315    )]
2316    Spanful {
2317        #[suggestion_part(code = "!")]
2318        neg: Option<Span>,
2319        #[suggestion_part(code = ".is_nan()")]
2320        float: Span,
2321        #[suggestion_part(code = "")]
2322        nan_plus_binop: Span,
2323    },
2324    #[help("use `f32::is_nan()` or `f64::is_nan()` instead")]
2325    Spanless,
2326}
2327
2328#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            AmbiguousWidePointerComparisons<'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 {
                    AmbiguousWidePointerComparisons::SpanfulEq {
                        addr_suggestion: __binding_0,
                        addr_metadata_suggestion: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ambiguous wide pointer comparison, the comparison includes metadata which may not be expected")));
                        ;
                        diag.subdiagnostic(__binding_0);
                        if let Some(__binding_1) = __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                    AmbiguousWidePointerComparisons::SpanfulCmp {
                        cast_suggestion: __binding_0, expect_suggestion: __binding_1
                        } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ambiguous wide pointer comparison, the comparison includes metadata which may not be expected")));
                        ;
                        diag.subdiagnostic(__binding_0);
                        diag.subdiagnostic(__binding_1);
                        diag
                    }
                    AmbiguousWidePointerComparisons::Spanless => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ambiguous wide pointer comparison, the comparison includes metadata which may not be expected")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use explicit `std::ptr::eq` method to compare metadata and addresses")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `std::ptr::addr_eq` or untyped pointers to only compare their addresses")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2329pub(crate) enum AmbiguousWidePointerComparisons<'a> {
2330    #[diag(
2331        "ambiguous wide pointer comparison, the comparison includes metadata which may not be expected"
2332    )]
2333    SpanfulEq {
2334        #[subdiagnostic]
2335        addr_suggestion: AmbiguousWidePointerComparisonsAddrSuggestion<'a>,
2336        #[subdiagnostic]
2337        addr_metadata_suggestion: Option<AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a>>,
2338    },
2339    #[diag(
2340        "ambiguous wide pointer comparison, the comparison includes metadata which may not be expected"
2341    )]
2342    SpanfulCmp {
2343        #[subdiagnostic]
2344        cast_suggestion: AmbiguousWidePointerComparisonsCastSuggestion<'a>,
2345        #[subdiagnostic]
2346        expect_suggestion: AmbiguousWidePointerComparisonsExpectSuggestion<'a>,
2347    },
2348    #[diag(
2349        "ambiguous wide pointer comparison, the comparison includes metadata which may not be expected"
2350    )]
2351    #[help("use explicit `std::ptr::eq` method to compare metadata and addresses")]
2352    #[help("use `std::ptr::addr_eq` or untyped pointers to only compare their addresses")]
2353    Spanless,
2354}
2355
2356#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for
            AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    AmbiguousWidePointerComparisonsAddrMetadataSuggestion {
                        ne: __binding_0,
                        deref_left: __binding_1,
                        deref_right: __binding_2,
                        l_modifiers: __binding_3,
                        r_modifiers: __binding_4,
                        left: __binding_5,
                        middle: __binding_6,
                        right: __binding_7 } => {
                        let mut suggestions = Vec::new();
                        let __code_68 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{1}std::ptr::eq({0}",
                                            __binding_1, __binding_0))
                                });
                        let __code_69 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{1}, {0}", __binding_2,
                                            __binding_3))
                                });
                        let __code_70 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{0})", __binding_4))
                                });
                        suggestions.push((__binding_5, __code_68));
                        suggestions.push((__binding_6, __code_69));
                        suggestions.push((__binding_7, __code_70));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use explicit `std::ptr::eq` method to compare metadata and addresses")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
2357#[multipart_suggestion(
2358    "use explicit `std::ptr::eq` method to compare metadata and addresses",
2359    style = "verbose",
2360    // FIXME(#53934): make machine-applicable again
2361    applicability = "maybe-incorrect"
2362)]
2363pub(crate) struct AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a> {
2364    pub ne: &'a str,
2365    pub deref_left: &'a str,
2366    pub deref_right: &'a str,
2367    pub l_modifiers: &'a str,
2368    pub r_modifiers: &'a str,
2369    #[suggestion_part(code = "{ne}std::ptr::eq({deref_left}")]
2370    pub left: Span,
2371    #[suggestion_part(code = "{l_modifiers}, {deref_right}")]
2372    pub middle: Span,
2373    #[suggestion_part(code = "{r_modifiers})")]
2374    pub right: Span,
2375}
2376
2377#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for
            AmbiguousWidePointerComparisonsAddrSuggestion<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    AmbiguousWidePointerComparisonsAddrSuggestion {
                        ne: __binding_0,
                        deref_left: __binding_1,
                        deref_right: __binding_2,
                        l_modifiers: __binding_3,
                        r_modifiers: __binding_4,
                        left: __binding_5,
                        middle: __binding_6,
                        right: __binding_7 } => {
                        let mut suggestions = Vec::new();
                        let __code_71 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{1}std::ptr::addr_eq({0}",
                                            __binding_1, __binding_0))
                                });
                        let __code_72 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{1}, {0}", __binding_2,
                                            __binding_3))
                                });
                        let __code_73 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{0})", __binding_4))
                                });
                        suggestions.push((__binding_5, __code_71));
                        suggestions.push((__binding_6, __code_72));
                        suggestions.push((__binding_7, __code_73));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `std::ptr::addr_eq` or untyped pointers to only compare their addresses")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
2378#[multipart_suggestion(
2379    "use `std::ptr::addr_eq` or untyped pointers to only compare their addresses",
2380    style = "verbose",
2381    // FIXME(#53934): make machine-applicable again
2382    applicability = "maybe-incorrect"
2383)]
2384pub(crate) struct AmbiguousWidePointerComparisonsAddrSuggestion<'a> {
2385    pub(crate) ne: &'a str,
2386    pub(crate) deref_left: &'a str,
2387    pub(crate) deref_right: &'a str,
2388    pub(crate) l_modifiers: &'a str,
2389    pub(crate) r_modifiers: &'a str,
2390    #[suggestion_part(code = "{ne}std::ptr::addr_eq({deref_left}")]
2391    pub(crate) left: Span,
2392    #[suggestion_part(code = "{l_modifiers}, {deref_right}")]
2393    pub(crate) middle: Span,
2394    #[suggestion_part(code = "{r_modifiers})")]
2395    pub(crate) right: Span,
2396}
2397
2398#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for
            AmbiguousWidePointerComparisonsCastSuggestion<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    AmbiguousWidePointerComparisonsCastSuggestion {
                        deref_left: __binding_0,
                        deref_right: __binding_1,
                        paren_left: __binding_2,
                        paren_right: __binding_3,
                        l_modifiers: __binding_4,
                        r_modifiers: __binding_5,
                        left_before: __binding_6,
                        left_after: __binding_7,
                        right_before: __binding_8,
                        right_after: __binding_9 } => {
                        let mut suggestions = Vec::new();
                        let __code_74 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("({0}", __binding_0))
                                });
                        let __code_75 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{0}{1}.cast::<()>()",
                                            __binding_4, __binding_2))
                                });
                        let __code_76 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("({0}", __binding_1))
                                });
                        let __code_77 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{1}{0}.cast::<()>()",
                                            __binding_3, __binding_5))
                                });
                        if let Some(__binding_6) = __binding_6 {
                            suggestions.push((__binding_6, __code_74));
                        }
                        suggestions.push((__binding_7, __code_75));
                        if let Some(__binding_8) = __binding_8 {
                            suggestions.push((__binding_8, __code_76));
                        }
                        suggestions.push((__binding_9, __code_77));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use untyped pointers to only compare their addresses")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
2399#[multipart_suggestion(
2400    "use untyped pointers to only compare their addresses",
2401    style = "verbose",
2402    // FIXME(#53934): make machine-applicable again
2403    applicability = "maybe-incorrect"
2404)]
2405pub(crate) struct AmbiguousWidePointerComparisonsCastSuggestion<'a> {
2406    pub(crate) deref_left: &'a str,
2407    pub(crate) deref_right: &'a str,
2408    pub(crate) paren_left: &'a str,
2409    pub(crate) paren_right: &'a str,
2410    pub(crate) l_modifiers: &'a str,
2411    pub(crate) r_modifiers: &'a str,
2412    #[suggestion_part(code = "({deref_left}")]
2413    pub(crate) left_before: Option<Span>,
2414    #[suggestion_part(code = "{l_modifiers}{paren_left}.cast::<()>()")]
2415    pub(crate) left_after: Span,
2416    #[suggestion_part(code = "({deref_right}")]
2417    pub(crate) right_before: Option<Span>,
2418    #[suggestion_part(code = "{r_modifiers}{paren_right}.cast::<()>()")]
2419    pub(crate) right_after: Span,
2420}
2421
2422#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for
            AmbiguousWidePointerComparisonsExpectSuggestion<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    AmbiguousWidePointerComparisonsExpectSuggestion {
                        paren_left: __binding_0,
                        paren_right: __binding_1,
                        before: __binding_2,
                        after: __binding_3 } => {
                        let mut suggestions = Vec::new();
                        let __code_78 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{{ #[expect(ambiguous_wide_pointer_comparisons, reason = \"...\")] {0}",
                                            __binding_0))
                                });
                        let __code_79 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{0} }}", __binding_1))
                                });
                        suggestions.push((__binding_2, __code_78));
                        suggestions.push((__binding_3, __code_79));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("or expect the lint to compare the pointers metadata and addresses")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
2423#[multipart_suggestion(
2424    "or expect the lint to compare the pointers metadata and addresses",
2425    style = "verbose",
2426    // FIXME(#53934): make machine-applicable again
2427    applicability = "maybe-incorrect"
2428)]
2429pub(crate) struct AmbiguousWidePointerComparisonsExpectSuggestion<'a> {
2430    pub(crate) paren_left: &'a str,
2431    pub(crate) paren_right: &'a str,
2432    // FIXME(#127436): Adjust once resolved
2433    #[suggestion_part(
2434        code = r#"{{ #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] {paren_left}"#
2435    )]
2436    pub(crate) before: Span,
2437    #[suggestion_part(code = "{paren_right} }}")]
2438    pub(crate) after: Span,
2439}
2440
2441#[derive(const _: () =
    {
        impl<'_sess, 'a, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            UnpredictableFunctionPointerComparisons<'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 {
                    UnpredictableFunctionPointerComparisons::Suggestion {
                        sugg: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the address of the same function can vary between different codegen units")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("furthermore, different functions could have the same address after being merged together")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html>")));
                        ;
                        diag.subdiagnostic(__binding_0);
                        diag
                    }
                    UnpredictableFunctionPointerComparisons::Warn => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the address of the same function can vary between different codegen units")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("furthermore, different functions could have the same address after being merged together")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html>")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2442pub(crate) enum UnpredictableFunctionPointerComparisons<'a, 'tcx> {
2443    #[diag(
2444        "function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique"
2445    )]
2446    #[note("the address of the same function can vary between different codegen units")]
2447    #[note(
2448        "furthermore, different functions could have the same address after being merged together"
2449    )]
2450    #[note(
2451        "for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html>"
2452    )]
2453    Suggestion {
2454        #[subdiagnostic]
2455        sugg: UnpredictableFunctionPointerComparisonsSuggestion<'a, 'tcx>,
2456    },
2457    #[diag(
2458        "function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique"
2459    )]
2460    #[note("the address of the same function can vary between different codegen units")]
2461    #[note(
2462        "furthermore, different functions could have the same address after being merged together"
2463    )]
2464    #[note(
2465        "for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html>"
2466    )]
2467    Warn,
2468}
2469
2470#[derive(const _: () =
    {
        impl<'a, 'tcx> rustc_errors::Subdiagnostic for
            UnpredictableFunctionPointerComparisonsSuggestion<'a, 'tcx> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    UnpredictableFunctionPointerComparisonsSuggestion::FnAddrEq {
                        ne: __binding_0,
                        deref_left: __binding_1,
                        deref_right: __binding_2,
                        left: __binding_3,
                        middle: __binding_4,
                        right: __binding_5 } => {
                        let mut suggestions = Vec::new();
                        let __code_80 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{1}std::ptr::fn_addr_eq({0}",
                                            __binding_1, __binding_0))
                                });
                        let __code_81 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(", {0}", __binding_2))
                                });
                        let __code_82 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        suggestions.push((__binding_3, __code_80));
                        suggestions.push((__binding_4, __code_81));
                        suggestions.push((__binding_5, __code_82));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    UnpredictableFunctionPointerComparisonsSuggestion::FnAddrEqWithCast {
                        ne: __binding_0,
                        deref_left: __binding_1,
                        deref_right: __binding_2,
                        fn_sig: __binding_3,
                        left: __binding_4,
                        middle: __binding_5,
                        right: __binding_6 } => {
                        let mut suggestions = Vec::new();
                        let __code_83 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{1}std::ptr::fn_addr_eq({0}",
                                            __binding_1, __binding_0))
                                });
                        let __code_84 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(", {0}", __binding_2))
                                });
                        let __code_85 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(" as {0})", __binding_3))
                                });
                        suggestions.push((__binding_4, __code_83));
                        suggestions.push((__binding_5, __code_84));
                        suggestions.push((__binding_6, __code_85));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
2471pub(crate) enum UnpredictableFunctionPointerComparisonsSuggestion<'a, 'tcx> {
2472    #[multipart_suggestion(
2473        "refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint",
2474        style = "verbose",
2475        applicability = "maybe-incorrect"
2476    )]
2477    FnAddrEq {
2478        ne: &'a str,
2479        deref_left: &'a str,
2480        deref_right: &'a str,
2481        #[suggestion_part(code = "{ne}std::ptr::fn_addr_eq({deref_left}")]
2482        left: Span,
2483        #[suggestion_part(code = ", {deref_right}")]
2484        middle: Span,
2485        #[suggestion_part(code = ")")]
2486        right: Span,
2487    },
2488    #[multipart_suggestion(
2489        "refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint",
2490        style = "verbose",
2491        applicability = "maybe-incorrect"
2492    )]
2493    FnAddrEqWithCast {
2494        ne: &'a str,
2495        deref_left: &'a str,
2496        deref_right: &'a str,
2497        fn_sig: rustc_middle::ty::PolyFnSig<'tcx>,
2498        #[suggestion_part(code = "{ne}std::ptr::fn_addr_eq({deref_left}")]
2499        left: Span,
2500        #[suggestion_part(code = ", {deref_right}")]
2501        middle: Span,
2502        #[suggestion_part(code = " as {fn_sig})")]
2503        right: Span,
2504    },
2505}
2506
2507pub(crate) struct ImproperCTypes<'a> {
2508    pub ty: Ty<'a>,
2509    pub desc: &'a str,
2510    pub label: Span,
2511    pub help: Option<DiagMessage>,
2512    pub note: DiagMessage,
2513    pub span_note: Option<Span>,
2514}
2515
2516// Used because of the complexity of Option<DiagMessage>, DiagMessage, and Option<Span>
2517impl<'a> Diagnostic<'a, ()> for ImproperCTypes<'_> {
2518    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
2519        let mut diag = Diag::new(
2520            dcx,
2521            level,
2522            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`extern` {$desc} uses type `{$ty}`, which is not FFI-safe"))msg!("`extern` {$desc} uses type `{$ty}`, which is not FFI-safe"),
2523        )
2524        .with_arg("ty", self.ty)
2525        .with_arg("desc", self.desc)
2526        .with_span_label(self.label, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not FFI-safe"))msg!("not FFI-safe"));
2527        if let Some(help) = self.help {
2528            diag.help(help);
2529        }
2530        diag.note(self.note);
2531        if let Some(note) = self.span_note {
2532            diag.span_note(note, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type is defined here"))msg!("the type is defined here"));
2533        }
2534        diag
2535    }
2536}
2537
2538#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            ImproperGpuKernelArg<'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 {
                    ImproperGpuKernelArg { ty: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("passing type `{$ty}` to a function with \"gpu-kernel\" ABI may have unexpected behavior")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use primitive types and raw pointers to get reliable behavior")));
                        ;
                        diag.arg("ty", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2539#[diag("passing type `{$ty}` to a function with \"gpu-kernel\" ABI may have unexpected behavior")]
2540#[help("use primitive types and raw pointers to get reliable behavior")]
2541pub(crate) struct ImproperGpuKernelArg<'a> {
2542    pub ty: Ty<'a>,
2543}
2544
2545#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            MissingGpuKernelExportName 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 {
                    MissingGpuKernelExportName => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function with the \"gpu-kernel\" ABI has a mangled name")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `unsafe(no_mangle)` or `unsafe(export_name = \"<name>\")`")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mangled names make it hard to find the kernel, this is usually not intended")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2546#[diag("function with the \"gpu-kernel\" ABI has a mangled name")]
2547#[help("use `unsafe(no_mangle)` or `unsafe(export_name = \"<name>\")`")]
2548#[note("mangled names make it hard to find the kernel, this is usually not intended")]
2549pub(crate) struct MissingGpuKernelExportName;
2550
2551#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            VariantSizeDifferencesDiag 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 {
                    VariantSizeDifferencesDiag { largest: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("enum variant is more than three times larger ({$largest} bytes) than the next largest")));
                        ;
                        diag.arg("largest", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2552#[diag("enum variant is more than three times larger ({$largest} bytes) than the next largest")]
2553pub(crate) struct VariantSizeDifferencesDiag {
2554    pub largest: u64,
2555}
2556
2557#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            AtomicOrderingLoad 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 {
                    AtomicOrderingLoad => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("atomic loads cannot have `Release` or `AcqRel` ordering")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using ordering modes `Acquire`, `SeqCst` or `Relaxed`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2558#[diag("atomic loads cannot have `Release` or `AcqRel` ordering")]
2559#[help("consider using ordering modes `Acquire`, `SeqCst` or `Relaxed`")]
2560pub(crate) struct AtomicOrderingLoad;
2561
2562#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            AtomicOrderingStore 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 {
                    AtomicOrderingStore => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("atomic stores cannot have `Acquire` or `AcqRel` ordering")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using ordering modes `Release`, `SeqCst` or `Relaxed`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2563#[diag("atomic stores cannot have `Acquire` or `AcqRel` ordering")]
2564#[help("consider using ordering modes `Release`, `SeqCst` or `Relaxed`")]
2565pub(crate) struct AtomicOrderingStore;
2566
2567#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            AtomicOrderingFence 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 {
                    AtomicOrderingFence => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("memory fences cannot have `Relaxed` ordering")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using ordering modes `Acquire`, `Release`, `AcqRel` or `SeqCst`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2568#[diag("memory fences cannot have `Relaxed` ordering")]
2569#[help("consider using ordering modes `Acquire`, `Release`, `AcqRel` or `SeqCst`")]
2570pub(crate) struct AtomicOrderingFence;
2571
2572#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidAtomicOrderingDiag 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 {
                    InvalidAtomicOrderingDiag {
                        method: __binding_0, fail_order_arg_span: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`{$method}`'s failure ordering may not be `Release` or `AcqRel`, since a failed `{$method}` does not result in a write")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using `Acquire` or `Relaxed` failure ordering instead")));
                        ;
                        diag.arg("method", __binding_0);
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid failure ordering")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2573#[diag(
2574    "`{$method}`'s failure ordering may not be `Release` or `AcqRel`, since a failed `{$method}` does not result in a write"
2575)]
2576#[help("consider using `Acquire` or `Relaxed` failure ordering instead")]
2577pub(crate) struct InvalidAtomicOrderingDiag {
2578    pub method: Symbol,
2579    #[label("invalid failure ordering")]
2580    pub fail_order_arg_span: Span,
2581}
2582
2583// unused.rs
2584#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            UnusedOp<'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 {
                    UnusedOp {
                        op: __binding_0, label: __binding_1, suggestion: __binding_2
                        } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused {$op} that must be used")));
                        ;
                        diag.arg("op", __binding_0);
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the {$op} produces a value")));
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2585#[diag("unused {$op} that must be used")]
2586pub(crate) struct UnusedOp<'a> {
2587    pub op: &'a str,
2588    #[label("the {$op} produces a value")]
2589    pub label: Span,
2590    #[subdiagnostic]
2591    pub suggestion: UnusedOpSuggestion,
2592}
2593
2594#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for UnusedOpSuggestion {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    UnusedOpSuggestion::NormalExpr { span: __binding_0 } => {
                        let __code_86 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("let _ = "))
                                            })].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 `let _ = ...` to ignore the resulting value")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_86, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    UnusedOpSuggestion::BlockTailExpr {
                        before_span: __binding_0, after_span: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_87 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("let _ = "))
                                });
                        let __code_88 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(";"))
                                });
                        suggestions.push((__binding_0, __code_87));
                        suggestions.push((__binding_1, __code_88));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `let _ = ...` to ignore the resulting value")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
2595pub(crate) enum UnusedOpSuggestion {
2596    #[suggestion(
2597        "use `let _ = ...` to ignore the resulting value",
2598        style = "verbose",
2599        code = "let _ = ",
2600        applicability = "maybe-incorrect"
2601    )]
2602    NormalExpr {
2603        #[primary_span]
2604        span: Span,
2605    },
2606    #[multipart_suggestion(
2607        "use `let _ = ...` to ignore the resulting value",
2608        style = "verbose",
2609        applicability = "maybe-incorrect"
2610    )]
2611    BlockTailExpr {
2612        #[suggestion_part(code = "let _ = ")]
2613        before_span: Span,
2614        #[suggestion_part(code = ";")]
2615        after_span: Span,
2616    },
2617}
2618
2619#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            UnusedResult<'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 {
                    UnusedResult { ty: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused result of type `{$ty}`")));
                        ;
                        diag.arg("ty", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2620#[diag("unused result of type `{$ty}`")]
2621pub(crate) struct UnusedResult<'a> {
2622    pub ty: Ty<'a>,
2623}
2624
2625// FIXME(davidtwco): this isn't properly translatable because of the
2626// pre/post strings
2627#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            UnusedClosure<'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 {
                    UnusedClosure {
                        count: __binding_0, pre: __binding_1, post: __binding_2 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused {$pre}{$count ->\n        [one] closure\n        *[other] closures\n    }{$post} that must be used")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("closures are lazy and do nothing unless called")));
                        ;
                        diag.arg("count", __binding_0);
                        diag.arg("pre", __binding_1);
                        diag.arg("post", __binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2628#[diag(
2629    "unused {$pre}{$count ->
2630        [one] closure
2631        *[other] closures
2632    }{$post} that must be used"
2633)]
2634#[note("closures are lazy and do nothing unless called")]
2635pub(crate) struct UnusedClosure<'a> {
2636    pub count: usize,
2637    pub pre: &'a str,
2638    pub post: &'a str,
2639}
2640
2641// FIXME(davidtwco): this isn't properly translatable because of the
2642// pre/post strings
2643#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            UnusedCoroutine<'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 {
                    UnusedCoroutine {
                        count: __binding_0, pre: __binding_1, post: __binding_2 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused {$pre}{$count ->\n        [one] coroutine\n        *[other] coroutine\n    }{$post} that must be used")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("coroutines are lazy and do nothing unless resumed")));
                        ;
                        diag.arg("count", __binding_0);
                        diag.arg("pre", __binding_1);
                        diag.arg("post", __binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2644#[diag(
2645    "unused {$pre}{$count ->
2646        [one] coroutine
2647        *[other] coroutine
2648    }{$post} that must be used"
2649)]
2650#[note("coroutines are lazy and do nothing unless resumed")]
2651pub(crate) struct UnusedCoroutine<'a> {
2652    pub count: usize,
2653    pub pre: &'a str,
2654    pub post: &'a str,
2655}
2656
2657// FIXME(davidtwco): this isn't properly translatable because of the pre/post
2658// strings
2659pub(crate) struct UnusedDef<'a, 'b> {
2660    pub pre: &'a str,
2661    pub post: &'a str,
2662    pub cx: &'a LateContext<'b>,
2663    pub def_id: DefId,
2664    pub note: Option<Symbol>,
2665    pub suggestion: Option<UnusedDefSuggestion>,
2666}
2667
2668#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for UnusedDefSuggestion {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    UnusedDefSuggestion::NormalExpr { span: __binding_0 } => {
                        let __code_89 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("let _ = "))
                                            })].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 `let _ = ...` to ignore the resulting value")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_89, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    UnusedDefSuggestion::BlockTailExpr {
                        before_span: __binding_0, after_span: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_90 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("let _ = "))
                                });
                        let __code_91 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(";"))
                                });
                        suggestions.push((__binding_0, __code_90));
                        suggestions.push((__binding_1, __code_91));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `let _ = ...` to ignore the resulting value")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
2669pub(crate) enum UnusedDefSuggestion {
2670    #[suggestion(
2671        "use `let _ = ...` to ignore the resulting value",
2672        style = "verbose",
2673        code = "let _ = ",
2674        applicability = "maybe-incorrect"
2675    )]
2676    NormalExpr {
2677        #[primary_span]
2678        span: Span,
2679    },
2680    #[multipart_suggestion(
2681        "use `let _ = ...` to ignore the resulting value",
2682        style = "verbose",
2683        applicability = "maybe-incorrect"
2684    )]
2685    BlockTailExpr {
2686        #[suggestion_part(code = "let _ = ")]
2687        before_span: Span,
2688        #[suggestion_part(code = ";")]
2689        after_span: Span,
2690    },
2691}
2692
2693// Needed because of def_path_str
2694impl<'a> Diagnostic<'a, ()> for UnusedDef<'_, '_> {
2695    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
2696        let mut diag =
2697            Diag::new(dcx, level, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unused {$pre}`{$def}`{$post} that must be used"))msg!("unused {$pre}`{$def}`{$post} that must be used"))
2698                .with_arg("pre", self.pre)
2699                .with_arg("post", self.post)
2700                .with_arg("def", self.cx.tcx.def_path_str(self.def_id));
2701        // check for #[must_use = "..."]
2702        if let Some(note) = self.note {
2703            diag.note(note.to_string());
2704        }
2705        if let Some(sugg) = self.suggestion {
2706            diag.subdiagnostic(sugg);
2707        }
2708        diag
2709    }
2710}
2711
2712#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            PathStatementDrop 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 {
                    PathStatementDrop { sub: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("path statement drops value")));
                        ;
                        diag.subdiagnostic(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2713#[diag("path statement drops value")]
2714pub(crate) struct PathStatementDrop {
2715    #[subdiagnostic]
2716    pub sub: PathStatementDropSub,
2717}
2718
2719#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for PathStatementDropSub {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    PathStatementDropSub::Suggestion {
                        span: __binding_0, snippet: __binding_1 } => {
                        let __code_92 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("drop({0});",
                                                        __binding_1))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `drop` to clarify the intent")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_92, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    PathStatementDropSub::Help { 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("use `drop` to clarify the intent")),
                                &sub_args);
                        diag.span_help(__binding_0, __message);
                    }
                }
            }
        }
    };Subdiagnostic)]
2720pub(crate) enum PathStatementDropSub {
2721    #[suggestion(
2722        "use `drop` to clarify the intent",
2723        code = "drop({snippet});",
2724        applicability = "machine-applicable"
2725    )]
2726    Suggestion {
2727        #[primary_span]
2728        span: Span,
2729        snippet: String,
2730    },
2731    #[help("use `drop` to clarify the intent")]
2732    Help {
2733        #[primary_span]
2734        span: Span,
2735    },
2736}
2737
2738#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            PathStatementNoEffect 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 {
                    PathStatementNoEffect => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("path statement with no effect")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2739#[diag("path statement with no effect")]
2740pub(crate) struct PathStatementNoEffect;
2741
2742#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            UnusedDelim<'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 {
                    UnusedDelim {
                        delim: __binding_0,
                        item: __binding_1,
                        suggestion: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unnecessary {$delim} around {$item}")));
                        ;
                        diag.arg("delim", __binding_0);
                        diag.arg("item", __binding_1);
                        if let Some(__binding_2) = __binding_2 {
                            diag.subdiagnostic(__binding_2);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2743#[diag("unnecessary {$delim} around {$item}")]
2744pub(crate) struct UnusedDelim<'a> {
2745    pub delim: &'static str,
2746    pub item: &'a str,
2747    #[subdiagnostic]
2748    pub suggestion: Option<UnusedDelimSuggestion>,
2749}
2750
2751#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for UnusedDelimSuggestion {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    UnusedDelimSuggestion {
                        start_span: __binding_0,
                        start_replace: __binding_1,
                        end_span: __binding_2,
                        end_replace: __binding_3,
                        delim: __binding_4 } => {
                        let mut suggestions = Vec::new();
                        let __code_93 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{0}", __binding_1))
                                });
                        let __code_94 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{0}", __binding_3))
                                });
                        suggestions.push((__binding_0, __code_93));
                        suggestions.push((__binding_2, __code_94));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("delim".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("remove these {$delim}")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
2752#[multipart_suggestion("remove these {$delim}", applicability = "machine-applicable")]
2753pub(crate) struct UnusedDelimSuggestion {
2754    #[suggestion_part(code = "{start_replace}")]
2755    pub start_span: Span,
2756    pub start_replace: &'static str,
2757    #[suggestion_part(code = "{end_replace}")]
2758    pub end_span: Span,
2759    pub end_replace: &'static str,
2760    pub delim: &'static str,
2761}
2762
2763#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnusedImportBracesDiag 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 {
                    UnusedImportBracesDiag { node: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("braces around {$node} is unnecessary")));
                        ;
                        diag.arg("node", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2764#[diag("braces around {$node} is unnecessary")]
2765pub(crate) struct UnusedImportBracesDiag {
2766    pub node: Symbol,
2767}
2768
2769#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnusedAllocationDiag 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 {
                    UnusedAllocationDiag => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unnecessary allocation, use `&` instead")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2770#[diag("unnecessary allocation, use `&` instead")]
2771pub(crate) struct UnusedAllocationDiag;
2772
2773#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnusedAllocationMutDiag 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 {
                    UnusedAllocationMutDiag => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unnecessary allocation, use `&mut` instead")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2774#[diag("unnecessary allocation, use `&mut` instead")]
2775pub(crate) struct UnusedAllocationMutDiag;
2776
2777pub(crate) struct AsyncFnInTraitDiag {
2778    pub sugg: Option<Vec<(Span, String)>>,
2779}
2780
2781impl<'a> Diagnostic<'a, ()> for AsyncFnInTraitDiag {
2782    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
2783        let mut diag = Diag::new(
2784            dcx,
2785            level,
2786            "use of `async fn` in public traits is discouraged as auto trait bounds cannot be specified",
2787        );
2788        diag.note("you can suppress this lint if you plan to use the trait only in your own code, or do not care about auto traits like `Send` on the `Future`");
2789        if let Some(sugg) = self.sugg {
2790            diag.multipart_suggestion("you can alternatively desugar to a normal `fn` that returns `impl Future` and add any desired bounds such as `Send`, but these cannot be relaxed without a breaking API change", sugg, Applicability::MaybeIncorrect);
2791        }
2792        diag
2793    }
2794}
2795
2796#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnitBindingsDiag 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 {
                    UnitBindingsDiag { label: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("binding has unit type `()`")));
                        ;
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this pattern is inferred to be the unit type `()`")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2797#[diag("binding has unit type `()`")]
2798pub(crate) struct UnitBindingsDiag {
2799    #[label("this pattern is inferred to be the unit type `()`")]
2800    pub label: Span,
2801}
2802
2803#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidAsmLabel 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 {
                    InvalidAsmLabel::Named { missing_precise_span: __binding_0 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("avoid using named labels in inline assembly")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only local labels of the form `<number>:` should be used in inline asm")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information")));
                        ;
                        if __binding_0 {
                            diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the label may be declared in the expansion of a macro")));
                        }
                        diag
                    }
                    InvalidAsmLabel::FormatArg {
                        missing_precise_span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("avoid using named labels in inline assembly")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("only local labels of the form `<number>:` should be used in inline asm")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("format arguments may expand to a non-numeric value")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information")));
                        ;
                        if __binding_0 {
                            diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the label may be declared in the expansion of a macro")));
                        }
                        diag
                    }
                    InvalidAsmLabel::Binary {
                        missing_precise_span: __binding_0, span: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("avoid using labels containing only the digits `0` and `1` in inline assembly")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("start numbering with `2` instead")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("an LLVM bug makes these labels ambiguous with a binary literal number on x86")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("see <https://github.com/llvm/llvm-project/issues/99547> for more information")));
                        ;
                        if __binding_0 {
                            diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the label may be declared in the expansion of a macro")));
                        }
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use a different label that doesn't start with `0` or `1`")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2804pub(crate) enum InvalidAsmLabel {
2805    #[diag("avoid using named labels in inline assembly")]
2806    #[help("only local labels of the form `<number>:` should be used in inline asm")]
2807    #[note(
2808        "see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information"
2809    )]
2810    Named {
2811        #[note("the label may be declared in the expansion of a macro")]
2812        missing_precise_span: bool,
2813    },
2814    #[diag("avoid using named labels in inline assembly")]
2815    #[help("only local labels of the form `<number>:` should be used in inline asm")]
2816    #[note("format arguments may expand to a non-numeric value")]
2817    #[note(
2818        "see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information"
2819    )]
2820    FormatArg {
2821        #[note("the label may be declared in the expansion of a macro")]
2822        missing_precise_span: bool,
2823    },
2824    #[diag("avoid using labels containing only the digits `0` and `1` in inline assembly")]
2825    #[help("start numbering with `2` instead")]
2826    #[note("an LLVM bug makes these labels ambiguous with a binary literal number on x86")]
2827    #[note("see <https://github.com/llvm/llvm-project/issues/99547> for more information")]
2828    Binary {
2829        #[note("the label may be declared in the expansion of a macro")]
2830        missing_precise_span: bool,
2831        // hack to get a label on the whole span, must match the emitted span
2832        #[label("use a different label that doesn't start with `0` or `1`")]
2833        span: Span,
2834    },
2835}
2836
2837#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            RefOfMutStatic<'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 {
                    RefOfMutStatic {
                        span: __binding_0,
                        sugg: __binding_1,
                        shared_label: __binding_2,
                        shared_note: __binding_3,
                        mut_note: __binding_4,
                        interior_mutability_help: __binding_5,
                        interior_mutability_sugg: __binding_6 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("creating a {$shared_label}reference to mutable static")));
                        ;
                        diag.arg("shared_label", __binding_2);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$shared_label}reference to mutable static")));
                        if let Some(__binding_1) = __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        if __binding_3 {
                            diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives")));
                        }
                        if __binding_4 {
                            diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives")));
                        }
                        if __binding_5 {
                            diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use a type that relies on \"interior mutability\" instead; to read more on this, visit <https://doc.rust-lang.org/reference/interior-mutability.html>")));
                        }
                        if let Some(__binding_6) = __binding_6 {
                            diag.subdiagnostic(__binding_6);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2838#[diag("creating a {$shared_label}reference to mutable static")]
2839pub(crate) struct RefOfMutStatic<'a> {
2840    #[label("{$shared_label}reference to mutable static")]
2841    pub span: Span,
2842    #[subdiagnostic]
2843    pub sugg: Option<MutRefSugg>,
2844    pub shared_label: &'a str,
2845    #[note(
2846        "shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives"
2847    )]
2848    pub shared_note: bool,
2849    #[note(
2850        "mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives"
2851    )]
2852    pub mut_note: bool,
2853    #[help(
2854        "use a type that relies on \"interior mutability\" instead; to read more on this, visit <https://doc.rust-lang.org/reference/interior-mutability.html>"
2855    )]
2856    pub interior_mutability_help: bool,
2857    #[subdiagnostic]
2858    pub interior_mutability_sugg: Option<StaticMutRefsInteriorMutabilitySugg>,
2859}
2860
2861#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for MutRefSugg {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    MutRefSugg::Shared { span: __binding_0 } => {
                        let mut suggestions = Vec::new();
                        let __code_95 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("&raw const "))
                                });
                        suggestions.push((__binding_0, __code_95));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `&raw const` instead to create a raw pointer")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    MutRefSugg::Mut { span: __binding_0 } => {
                        let mut suggestions = Vec::new();
                        let __code_96 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("&raw mut "))
                                });
                        suggestions.push((__binding_0, __code_96));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `&raw mut` instead to create a raw pointer")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
2862pub(crate) enum MutRefSugg {
2863    #[multipart_suggestion(
2864        "use `&raw const` instead to create a raw pointer",
2865        style = "verbose",
2866        applicability = "maybe-incorrect"
2867    )]
2868    Shared {
2869        #[suggestion_part(code = "&raw const ")]
2870        span: Span,
2871    },
2872    #[multipart_suggestion(
2873        "use `&raw mut` instead to create a raw pointer",
2874        style = "verbose",
2875        applicability = "maybe-incorrect"
2876    )]
2877    Mut {
2878        #[suggestion_part(code = "&raw mut ")]
2879        span: Span,
2880    },
2881}
2882
2883#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for
            StaticMutRefsInteriorMutabilitySugg {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    StaticMutRefsInteriorMutabilitySugg { span: __binding_0 } =>
                        {
                        let __code_97 =
                            [::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("this type already provides \"interior mutability\", so its binding doesn't need to be declared as mutable when borrowed with a shared reference")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_97, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
2884#[suggestion(
2885    "this type already provides \"interior mutability\", so its binding doesn't need to be declared as mutable when borrowed with a shared reference",
2886    style = "verbose",
2887    applicability = "maybe-incorrect",
2888    code = ""
2889)]
2890pub(crate) struct StaticMutRefsInteriorMutabilitySugg {
2891    #[primary_span]
2892    pub span: Span,
2893}
2894
2895#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnqualifiedLocalImportsDiag 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 {
                    UnqualifiedLocalImportsDiag => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`use` of a local item without leading `self::`, `super::`, or `crate::`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2896#[diag("`use` of a local item without leading `self::`, `super::`, or `crate::`")]
2897pub(crate) struct UnqualifiedLocalImportsDiag;
2898
2899#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            FunctionCastsAsIntegerDiag<'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 {
                    FunctionCastsAsIntegerDiag { sugg: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("direct cast of function item into an integer")));
                        ;
                        diag.subdiagnostic(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2900#[diag("direct cast of function item into an integer")]
2901pub(crate) struct FunctionCastsAsIntegerDiag<'tcx> {
2902    #[subdiagnostic]
2903    pub(crate) sugg: FunctionCastsAsIntegerSugg<'tcx>,
2904}
2905
2906#[derive(const _: () =
    {
        impl<'tcx> rustc_errors::Subdiagnostic for
            FunctionCastsAsIntegerSugg<'tcx> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    FunctionCastsAsIntegerSugg {
                        suggestion: __binding_0, cast_to_ty: __binding_1 } => {
                        let __code_98 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(" as *const ()"))
                                            })].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("first cast to a pointer `as *const ()`")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_98, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
2907#[suggestion(
2908    "first cast to a pointer `as *const ()`",
2909    code = " as *const ()",
2910    applicability = "machine-applicable",
2911    style = "verbose"
2912)]
2913pub(crate) struct FunctionCastsAsIntegerSugg<'tcx> {
2914    #[primary_span]
2915    pub suggestion: Span,
2916    pub cast_to_ty: Ty<'tcx>,
2917}
2918
2919#[derive(#[automatically_derived]
impl ::core::fmt::Debug for MismatchedLifetimeSyntaxes {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "MismatchedLifetimeSyntaxes", "inputs", &self.inputs, "outputs",
            &self.outputs, "suggestions", &&self.suggestions)
    }
}Debug)]
2920pub(crate) struct MismatchedLifetimeSyntaxes {
2921    pub inputs: LifetimeSyntaxCategories<Vec<Span>>,
2922    pub outputs: LifetimeSyntaxCategories<Vec<Span>>,
2923
2924    pub suggestions: Vec<MismatchedLifetimeSyntaxesSuggestion>,
2925}
2926
2927impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for MismatchedLifetimeSyntaxes {
2928    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
2929        let counts = self.inputs.len() + self.outputs.len();
2930        let message = match counts {
2931            LifetimeSyntaxCategories { hidden: 0, elided: 0, named: 0 } => {
2932                {
    ::core::panicking::panic_fmt(format_args!("No lifetime mismatch detected"));
}panic!("No lifetime mismatch detected")
2933            }
2934
2935            LifetimeSyntaxCategories { hidden: _, elided: _, named: 0 } => {
2936                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("hiding a lifetime that's elided elsewhere is confusing"))msg!("hiding a lifetime that's elided elsewhere is confusing")
2937            }
2938
2939            LifetimeSyntaxCategories { hidden: _, elided: 0, named: _ } => {
2940                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("hiding a lifetime that's named elsewhere is confusing"))msg!("hiding a lifetime that's named elsewhere is confusing")
2941            }
2942
2943            LifetimeSyntaxCategories { hidden: 0, elided: _, named: _ } => {
2944                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("eliding a lifetime that's named elsewhere is confusing"))msg!("eliding a lifetime that's named elsewhere is confusing")
2945            }
2946
2947            LifetimeSyntaxCategories { hidden: _, elided: _, named: _ } => {
2948                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("hiding or eliding a lifetime that's named elsewhere is confusing"))msg!("hiding or eliding a lifetime that's named elsewhere is confusing")
2949            }
2950        };
2951        let mut diag = Diag::new(dcx, level, message);
2952
2953        for s in self.inputs.hidden {
2954            diag.span_label(s, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lifetime is hidden here"))msg!("the lifetime is hidden here"));
2955        }
2956        for s in self.inputs.elided {
2957            diag.span_label(s, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lifetime is elided here"))msg!("the lifetime is elided here"));
2958        }
2959        for s in self.inputs.named {
2960            diag.span_label(s, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lifetime is named here"))msg!("the lifetime is named here"));
2961        }
2962
2963        let mut hidden_output_counts: FxIndexMap<Span, usize> = FxIndexMap::default();
2964        for s in self.outputs.hidden {
2965            *hidden_output_counts.entry(s).or_insert(0) += 1;
2966        }
2967        for (span, count) in hidden_output_counts {
2968            let label = rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the same {$count ->\n                    [one] lifetime\n                    *[other] lifetimes\n                } {$count ->\n                    [one] is\n                    *[other] are\n                } hidden here"))msg!(
2969                "the same {$count ->
2970                    [one] lifetime
2971                    *[other] lifetimes
2972                } {$count ->
2973                    [one] is
2974                    *[other] are
2975                } hidden here"
2976            )
2977            .arg("count", count)
2978            .format();
2979            diag.span_label(span, label);
2980        }
2981        for s in self.outputs.elided {
2982            diag.span_label(s, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the same lifetime is elided here"))msg!("the same lifetime is elided here"));
2983        }
2984        for s in self.outputs.named {
2985            diag.span_label(s, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the same lifetime is named here"))msg!("the same lifetime is named here"));
2986        }
2987
2988        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the same lifetime is referred to in inconsistent ways, making the signature confusing"))msg!(
2989            "the same lifetime is referred to in inconsistent ways, making the signature confusing"
2990        ));
2991
2992        let mut suggestions = self.suggestions.into_iter();
2993        if let Some(s) = suggestions.next() {
2994            diag.subdiagnostic(s);
2995
2996            for mut s in suggestions {
2997                s.make_optional_alternative();
2998                diag.subdiagnostic(s);
2999            }
3000        }
3001        diag
3002    }
3003}
3004
3005#[derive(#[automatically_derived]
impl ::core::fmt::Debug for MismatchedLifetimeSyntaxesSuggestion {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            MismatchedLifetimeSyntaxesSuggestion::Implicit {
                suggestions: __self_0, optional_alternative: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "Implicit", "suggestions", __self_0, "optional_alternative",
                    &__self_1),
            MismatchedLifetimeSyntaxesSuggestion::Mixed {
                implicit_suggestions: __self_0,
                explicit_anonymous_suggestions: __self_1,
                optional_alternative: __self_2 } =>
                ::core::fmt::Formatter::debug_struct_field3_finish(f, "Mixed",
                    "implicit_suggestions", __self_0,
                    "explicit_anonymous_suggestions", __self_1,
                    "optional_alternative", &__self_2),
            MismatchedLifetimeSyntaxesSuggestion::Explicit {
                lifetime_name: __self_0,
                suggestions: __self_1,
                optional_alternative: __self_2 } =>
                ::core::fmt::Formatter::debug_struct_field3_finish(f,
                    "Explicit", "lifetime_name", __self_0, "suggestions",
                    __self_1, "optional_alternative", &__self_2),
        }
    }
}Debug)]
3006pub(crate) enum MismatchedLifetimeSyntaxesSuggestion {
3007    Implicit {
3008        suggestions: Vec<Span>,
3009        optional_alternative: bool,
3010    },
3011
3012    Mixed {
3013        implicit_suggestions: Vec<Span>,
3014        explicit_anonymous_suggestions: Vec<(Span, String)>,
3015        optional_alternative: bool,
3016    },
3017
3018    Explicit {
3019        lifetime_name: String,
3020        suggestions: Vec<(Span, String)>,
3021        optional_alternative: bool,
3022    },
3023}
3024
3025impl MismatchedLifetimeSyntaxesSuggestion {
3026    fn make_optional_alternative(&mut self) {
3027        use MismatchedLifetimeSyntaxesSuggestion::*;
3028
3029        let optional_alternative = match self {
3030            Implicit { optional_alternative, .. }
3031            | Mixed { optional_alternative, .. }
3032            | Explicit { optional_alternative, .. } => optional_alternative,
3033        };
3034
3035        *optional_alternative = true;
3036    }
3037}
3038
3039impl Subdiagnostic for MismatchedLifetimeSyntaxesSuggestion {
3040    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
3041        use MismatchedLifetimeSyntaxesSuggestion::*;
3042
3043        let style = |optional_alternative| {
3044            if optional_alternative {
3045                SuggestionStyle::CompletelyHidden
3046            } else {
3047                SuggestionStyle::ShowAlways
3048            }
3049        };
3050
3051        let applicability = |optional_alternative| {
3052            // `cargo fix` can't handle more than one fix for the same issue,
3053            // so hide alternative suggestions from it by marking them as maybe-incorrect
3054            if optional_alternative {
3055                Applicability::MaybeIncorrect
3056            } else {
3057                Applicability::MachineApplicable
3058            }
3059        };
3060
3061        match self {
3062            Implicit { suggestions, optional_alternative } => {
3063                let suggestions = suggestions.into_iter().map(|s| (s, String::new())).collect();
3064                diag.multipart_suggestion_with_style(
3065                    rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the lifetime name from references"))msg!("remove the lifetime name from references"),
3066                    suggestions,
3067                    applicability(optional_alternative),
3068                    style(optional_alternative),
3069                );
3070            }
3071
3072            Mixed {
3073                implicit_suggestions,
3074                explicit_anonymous_suggestions,
3075                optional_alternative,
3076            } => {
3077                let message = if implicit_suggestions.is_empty() {
3078                    rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `'_` for type paths"))msg!("use `'_` for type paths")
3079                } else {
3080                    rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the lifetime name from references and use `'_` for type paths"))msg!("remove the lifetime name from references and use `'_` for type paths")
3081                };
3082
3083                let implicit_suggestions =
3084                    implicit_suggestions.into_iter().map(|s| (s, String::new()));
3085
3086                let suggestions =
3087                    implicit_suggestions.chain(explicit_anonymous_suggestions).collect();
3088
3089                diag.multipart_suggestion_with_style(
3090                    message,
3091                    suggestions,
3092                    applicability(optional_alternative),
3093                    style(optional_alternative),
3094                );
3095            }
3096
3097            Explicit { lifetime_name, suggestions, optional_alternative } => {
3098                let msg = rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consistently use `{$lifetime_name}`"))msg!("consistently use `{$lifetime_name}`")
3099                    .arg("lifetime_name", lifetime_name)
3100                    .format();
3101                diag.multipart_suggestion_with_style(
3102                    msg,
3103                    suggestions,
3104                    applicability(optional_alternative),
3105                    style(optional_alternative),
3106                );
3107            }
3108        }
3109    }
3110}
3111
3112#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            EqInternalMethodImplemented 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 {
                    EqInternalMethodImplemented => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`Eq::assert_receiver_is_total_eq` should never be implemented by hand")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this method was used to add checks to the `Eq` derive macro")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
3113#[diag("`Eq::assert_receiver_is_total_eq` should never be implemented by hand")]
3114#[note("this method was used to add checks to the `Eq` derive macro")]
3115pub(crate) struct EqInternalMethodImplemented;
3116
3117#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            ImplicitProvenanceCastsInt2Ptr<'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 {
                    ImplicitProvenanceCastsInt2Ptr {
                        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("cast from `{$expr_ty}` to `{$cast_ty}` implicitly relies on exposed provenance")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if conforming to strict provenance is not possible, use `std::ptr::with_exposed_provenance()`")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, visit <https://doc.rust-lang.org/std/ptr/index.html#provenance>")));
                        ;
                        diag.arg("expr_ty", __binding_0);
                        diag.arg("cast_ty", __binding_1);
                        if let Some(__binding_2) = __binding_2 {
                            diag.subdiagnostic(__binding_2);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
3118#[diag("cast from `{$expr_ty}` to `{$cast_ty}` implicitly relies on exposed provenance")]
3119#[help(
3120    "if conforming to strict provenance is not possible, use `std::ptr::with_exposed_provenance()`"
3121)]
3122#[note("for more information, visit <https://doc.rust-lang.org/std/ptr/index.html#provenance>")]
3123pub(crate) struct ImplicitProvenanceCastsInt2Ptr<'tcx> {
3124    pub expr_ty: Ty<'tcx>,
3125    pub cast_ty: Ty<'tcx>,
3126    #[subdiagnostic]
3127    pub sugg: Option<Int2PtrSuggestion>,
3128}
3129
3130#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for Int2PtrSuggestion {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    Int2PtrSuggestion { lo: __binding_0, hi: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_99 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("(...).with_addr("))
                                });
                        let __code_100 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        suggestions.push((__binding_0, __code_99));
                        suggestions.push((__binding_1, __code_100));
                        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 the address of a valid pointer in the same allocation")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::HasPlaceholders,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
3131#[multipart_suggestion(
3132    "use `.with_addr()` to adjust the address of a valid pointer in the same allocation",
3133    applicability = "has-placeholders"
3134)]
3135pub(crate) struct Int2PtrSuggestion {
3136    #[suggestion_part(code = "(...).with_addr(")]
3137    pub lo: Span,
3138    #[suggestion_part(code = ")")]
3139    pub hi: Span,
3140}
3141
3142#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            ImplicitProvenanceCastsPtr2Int<'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 {
                    ImplicitProvenanceCastsPtr2Int {
                        cast_from_ty: __binding_0,
                        cast_to_ty: __binding_1,
                        sugg: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cast from `{$cast_from_ty}` to `{$cast_to_ty}` implicitly exposes pointer provenance")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if conforming to strict provenance is not possible, use `.expose_provenance()`")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("for more information, visit <https://doc.rust-lang.org/std/ptr/index.html#provenance>")));
                        ;
                        diag.arg("cast_from_ty", __binding_0);
                        diag.arg("cast_to_ty", __binding_1);
                        if let Some(__binding_2) = __binding_2 {
                            diag.subdiagnostic(__binding_2);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
3143#[diag("cast from `{$cast_from_ty}` to `{$cast_to_ty}` implicitly exposes pointer provenance")]
3144#[help("if conforming to strict provenance is not possible, use `.expose_provenance()`")]
3145#[note("for more information, visit <https://doc.rust-lang.org/std/ptr/index.html#provenance>")]
3146pub(crate) struct ImplicitProvenanceCastsPtr2Int<'tcx> {
3147    pub cast_from_ty: Ty<'tcx>,
3148    pub cast_to_ty: Ty<'tcx>,
3149    #[subdiagnostic]
3150    pub sugg: Option<Ptr2IntSuggestion<'tcx>>,
3151}
3152
3153#[derive(const _: () =
    {
        impl<'tcx> rustc_errors::Subdiagnostic for Ptr2IntSuggestion<'tcx> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    Ptr2IntSuggestion::NeedsParensCast {
                        expr_span: __binding_0,
                        cast_span: __binding_1,
                        cast_to_ty: __binding_2 } => {
                        let mut suggestions = Vec::new();
                        let __code_101 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("("))
                                });
                        let __code_102 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(").addr() as {0}",
                                            __binding_2))
                                });
                        suggestions.push((__binding_0, __code_101));
                        suggestions.push((__binding_1, __code_102));
                        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);
                    }
                    Ptr2IntSuggestion::NeedsParens {
                        expr_span: __binding_0, cast_span: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_103 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("("))
                                });
                        let __code_104 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(").addr()"))
                                });
                        suggestions.push((__binding_0, __code_103));
                        suggestions.push((__binding_1, __code_104));
                        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);
                    }
                    Ptr2IntSuggestion::NeedsCast {
                        cast_span: __binding_0, cast_to_ty: __binding_1 } => {
                        let __code_105 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(".addr() as {0}",
                                                        __binding_1))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use `.addr()` to obtain the address of a pointer")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_105, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    Ptr2IntSuggestion::Other { cast_span: __binding_0 } => {
                        let __code_106 =
                            [::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_106, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
3154pub(crate) enum Ptr2IntSuggestion<'tcx> {
3155    #[multipart_suggestion(
3156        "use `.addr()` to obtain the address of a pointer",
3157        applicability = "maybe-incorrect"
3158    )]
3159    NeedsParensCast {
3160        #[suggestion_part(code = "(")]
3161        expr_span: Span,
3162        #[suggestion_part(code = ").addr() as {cast_to_ty}")]
3163        cast_span: Span,
3164        cast_to_ty: Ty<'tcx>,
3165    },
3166    #[multipart_suggestion(
3167        "use `.addr()` to obtain the address of a pointer",
3168        applicability = "maybe-incorrect"
3169    )]
3170    NeedsParens {
3171        #[suggestion_part(code = "(")]
3172        expr_span: Span,
3173        #[suggestion_part(code = ").addr()")]
3174        cast_span: Span,
3175    },
3176    #[suggestion(
3177        "use `.addr()` to obtain the address of a pointer",
3178        code = ".addr() as {cast_to_ty}",
3179        applicability = "maybe-incorrect"
3180    )]
3181    NeedsCast {
3182        #[primary_span]
3183        cast_span: Span,
3184        cast_to_ty: Ty<'tcx>,
3185    },
3186    #[suggestion(
3187        "use `.addr()` to obtain the address of a pointer",
3188        code = ".addr()",
3189        applicability = "maybe-incorrect"
3190    )]
3191    Other {
3192        #[primary_span]
3193        cast_span: Span,
3194    },
3195}
3196
3197#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            RawBorrowViaReference<'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 {
                    RawBorrowViaReference { suggestion: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("creating an intermediate reference implies aliasing requirements even when immediately cast to a raw pointers")));
                        ;
                        diag.subdiagnostic(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
3198#[diag(
3199    "creating an intermediate reference implies aliasing requirements even when immediately cast to a raw pointers"
3200)]
3201pub(crate) struct RawBorrowViaReference<'a> {
3202    #[subdiagnostic]
3203    pub suggestion: RawBorrowViaReferenceSuggestion<'a>,
3204}
3205
3206#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for
            RawBorrowViaReferenceSuggestion<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    RawBorrowViaReferenceSuggestion::Spanful {
                        left: __binding_0, right: __binding_1, mutbl: __binding_2 }
                        => {
                        let mut suggestions = Vec::new();
                        let __code_107 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("&raw {0} ", __binding_2))
                                });
                        let __code_108 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(""))
                                });
                        suggestions.push((__binding_0, __code_107));
                        suggestions.push((__binding_1, __code_108));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("mutbl".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 `&raw {$mutbl}` for a safer and more explicit raw pointer")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    RawBorrowViaReferenceSuggestion::Spanless {
                        mutbl: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("mutbl".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("consider using `&raw {$mutbl}` for a safer and more explicit raw pointer")),
                                &sub_args);
                        diag.help(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
3207pub(crate) enum RawBorrowViaReferenceSuggestion<'a> {
3208    #[multipart_suggestion(
3209        "consider using `&raw {$mutbl}` for a safer and more explicit raw pointer",
3210        applicability = "machine-applicable"
3211    )]
3212    Spanful {
3213        #[suggestion_part(code = "&raw {mutbl} ")]
3214        left: Span,
3215        #[suggestion_part(code = "")]
3216        right: Span,
3217        mutbl: &'a str,
3218    },
3219    #[help("consider using `&raw {$mutbl}` for a safer and more explicit raw pointer")]
3220    Spanless { mutbl: &'a str },
3221}