Skip to main content

rustc_session/
errors.rs

1use std::num::{NonZero, ParseIntError};
2
3use rustc_ast::token;
4use rustc_ast::util::literal::LitError;
5use rustc_errors::codes::*;
6use rustc_errors::{
7    Diag, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, ErrorGuaranteed, Level,
8    MultiSpan, StashKey,
9};
10use rustc_feature::{GateIssue, find_feature_issue};
11use rustc_macros::{Diagnostic, Subdiagnostic};
12use rustc_span::{Span, Symbol, sym};
13use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTuple};
14
15use crate::Session;
16use crate::lint::builtin::UNSTABLE_SYNTAX_PRE_EXPANSION;
17use crate::parse::ParseSess;
18
19/// Construct a diagnostic for a language feature error due to the given `span`.
20/// The `feature`'s `Symbol` is the one you used in `unstable.rs` and `rustc_span::symbol`.
21#[track_caller]
22pub fn feature_err(
23    sess: &Session,
24    feature: Symbol,
25    span: impl Into<MultiSpan>,
26    explain: impl Into<DiagMessage>,
27) -> Diag<'_> {
28    feature_err_issue(sess, feature, span, GateIssue::Language, explain)
29}
30
31/// Construct a diagnostic for a feature gate error.
32///
33/// This variant allows you to control whether it is a library or language feature.
34/// Almost always, you want to use this for a language feature. If so, prefer `feature_err`.
35#[track_caller]
36pub fn feature_err_issue(
37    sess: &Session,
38    feature: Symbol,
39    span: impl Into<MultiSpan>,
40    issue: GateIssue,
41    explain: impl Into<DiagMessage>,
42) -> Diag<'_> {
43    let span = span.into();
44
45    // Cancel an earlier warning for this same error, if it exists.
46    if let Some(span) = span.primary_span()
47        && let Some(err) = sess.dcx().steal_non_err(span, StashKey::EarlySyntaxWarning)
48    {
49        err.cancel()
50    }
51
52    let mut err = sess.dcx().create_err(FeatureGateError { span, explain: explain.into() });
53    add_feature_diagnostics_for_issue(&mut err, sess, feature, issue, false, None);
54    err
55}
56
57/// Construct a future incompatibility diagnostic for a feature gate.
58///
59/// This diagnostic is only a warning and *does not cause compilation to fail*.
60#[track_caller]
61pub fn feature_warn(sess: &Session, feature: Symbol, span: Span, explain: &'static str) {
62    feature_warn_issue(sess, feature, span, GateIssue::Language, explain);
63}
64
65/// Construct a future incompatibility diagnostic for a feature gate.
66///
67/// This diagnostic is only a warning and *does not cause compilation to fail*.
68///
69/// This variant allows you to control whether it is a library or language feature.
70/// Almost always, you want to use this for a language feature. If so, prefer `feature_warn`.
71#[track_caller]
72pub fn feature_warn_issue(
73    sess: &Session,
74    feature: Symbol,
75    span: Span,
76    issue: GateIssue,
77    explain: &'static str,
78) {
79    let mut err = sess.dcx().struct_span_warn(span, explain);
80    add_feature_diagnostics_for_issue(&mut err, sess, feature, issue, false, None);
81
82    // Decorate this as a future-incompatibility lint as in rustc_middle::lint::lint_level
83    let lint = UNSTABLE_SYNTAX_PRE_EXPANSION;
84    let future_incompatible = lint.future_incompatible.as_ref().unwrap();
85    err.is_lint(lint.name_lower(), /* has_future_breakage */ false);
86    err.warn(lint.desc);
87    err.note(::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("for more information, see {0}",
                future_incompatible.reason.reference()))
    })format!("for more information, see {}", future_incompatible.reason.reference()));
88
89    // A later feature_err call can steal and cancel this warning.
90    err.stash(span, StashKey::EarlySyntaxWarning);
91}
92
93/// Adds the diagnostics for a feature to an existing error.
94/// Must be a language feature!
95pub fn add_feature_diagnostics<G: EmissionGuarantee>(
96    err: &mut Diag<'_, G>,
97    sess: &Session,
98    feature: Symbol,
99) {
100    add_feature_diagnostics_for_issue(err, sess, feature, GateIssue::Language, false, None);
101}
102
103/// Adds the diagnostics for a feature to an existing error.
104///
105/// This variant allows you to control whether it is a library or language feature.
106/// Almost always, you want to use this for a language feature. If so, prefer
107/// `add_feature_diagnostics`.
108pub fn add_feature_diagnostics_for_issue<G: EmissionGuarantee>(
109    err: &mut Diag<'_, G>,
110    sess: &Session,
111    feature: Symbol,
112    issue: GateIssue,
113    feature_from_cli: bool,
114    inject_span: Option<Span>,
115) {
116    if let Some(n) = find_feature_issue(feature, issue) {
117        err.subdiagnostic(FeatureDiagnosticForIssue { n });
118    }
119
120    // #23973: do not suggest `#![feature(...)]` if we are in beta/stable
121    if sess.unstable_features.is_nightly_build() {
122        if feature_from_cli {
123            err.subdiagnostic(CliFeatureDiagnosticHelp { feature });
124        } else if let Some(span) = inject_span {
125            err.subdiagnostic(FeatureDiagnosticSuggestion { feature, span });
126        } else {
127            err.subdiagnostic(FeatureDiagnosticHelp { feature });
128        }
129        if feature == sym::rustc_attrs {
130            // We're unlikely to stabilize something out of `rustc_attrs`
131            // without at least renaming it, so pointing out how old
132            // the compiler is will do little good.
133        } else if sess.opts.unstable_opts.ui_testing {
134            err.subdiagnostic(SuggestUpgradeCompiler::ui_testing());
135        } else if let Some(suggestion) = SuggestUpgradeCompiler::new() {
136            err.subdiagnostic(suggestion);
137        }
138    }
139}
140
141/// This is only used by unstable_feature_bound as it does not have issue number information for now.
142/// This is basically the same as `feature_err_issue`
143/// but without the feature issue note. If we can do a lookup for issue number from feature name,
144/// then we should directly use `feature_err_issue` for ambiguity error of
145/// `#[unstable_feature_bound]`.
146#[track_caller]
147pub fn feature_err_unstable_feature_bound(
148    sess: &Session,
149    feature: Symbol,
150    span: impl Into<MultiSpan>,
151    explain: impl Into<DiagMessage>,
152) -> Diag<'_> {
153    let span = span.into();
154
155    // Cancel an earlier warning for this same error, if it exists.
156    if let Some(span) = span.primary_span() {
157        if let Some(err) = sess.dcx().steal_non_err(span, StashKey::EarlySyntaxWarning) {
158            err.cancel()
159        }
160    }
161
162    let mut err = sess.dcx().create_err(FeatureGateError { span, explain: explain.into() });
163
164    // #23973: do not suggest `#![feature(...)]` if we are in beta/stable
165    if sess.unstable_features.is_nightly_build() {
166        err.subdiagnostic(FeatureDiagnosticHelp { feature });
167
168        if feature == sym::rustc_attrs {
169            // We're unlikely to stabilize something out of `rustc_attrs`
170            // without at least renaming it, so pointing out how old
171            // the compiler is will do little good.
172        } else if sess.opts.unstable_opts.ui_testing {
173            err.subdiagnostic(SuggestUpgradeCompiler::ui_testing());
174        } else if let Some(suggestion) = SuggestUpgradeCompiler::new() {
175            err.subdiagnostic(suggestion);
176        }
177    }
178    err
179}
180
181#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            AppleDeploymentTarget where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    AppleDeploymentTarget::Invalid {
                        env_var: __binding_0, error: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to parse deployment target specified in {$env_var}: {$error}")));
                        ;
                        diag.arg("env_var", __binding_0);
                        diag.arg("error", __binding_1);
                        diag
                    }
                    AppleDeploymentTarget::TooLow {
                        env_var: __binding_0,
                        version: __binding_1,
                        os_min: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("deployment target in {$env_var} was set to {$version}, but the minimum supported by `rustc` is {$os_min}")));
                        ;
                        diag.arg("env_var", __binding_0);
                        diag.arg("version", __binding_1);
                        diag.arg("os_min", __binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
182pub(crate) enum AppleDeploymentTarget {
183    #[diag("failed to parse deployment target specified in {$env_var}: {$error}")]
184    Invalid { env_var: &'static str, error: ParseIntError },
185    #[diag(
186        "deployment target in {$env_var} was set to {$version}, but the minimum supported by `rustc` is {$os_min}"
187    )]
188    TooLow { env_var: &'static str, version: String, os_min: String },
189}
190
191pub(crate) struct FeatureGateError {
192    pub(crate) span: MultiSpan,
193    pub(crate) explain: DiagMessage,
194}
195
196impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for FeatureGateError {
197    #[track_caller]
198    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
199        Diag::new(dcx, level, self.explain).with_span(self.span).with_code(E0658)
200    }
201}
202
203#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for FeatureDiagnosticForIssue {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    FeatureDiagnosticForIssue { 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)]
204#[note("see issue #{$n} <https://github.com/rust-lang/rust/issues/{$n}> for more information")]
205pub(crate) struct FeatureDiagnosticForIssue {
206    pub(crate) n: NonZero<u32>,
207}
208
209#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for SuggestUpgradeCompiler {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    SuggestUpgradeCompiler { date: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("date".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("this compiler was built on {$date}; consider upgrading it if it is out of date")),
                                &sub_args);
                        diag.note(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
210#[note("this compiler was built on {$date}; consider upgrading it if it is out of date")]
211pub(crate) struct SuggestUpgradeCompiler {
212    date: &'static str,
213}
214
215impl SuggestUpgradeCompiler {
216    pub(crate) fn ui_testing() -> Self {
217        Self { date: "YYYY-MM-DD" }
218    }
219
220    pub(crate) fn new() -> Option<Self> {
221        let date = ::core::option::Option::Some("2026-05-04")option_env!("CFG_VER_DATE")?;
222
223        Some(Self { date })
224    }
225}
226
227#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for FeatureDiagnosticHelp {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    FeatureDiagnosticHelp { feature: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("feature".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("add `#![feature({$feature})]` to the crate attributes to enable")),
                                &sub_args);
                        diag.help(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
228#[help("add `#![feature({$feature})]` to the crate attributes to enable")]
229pub(crate) struct FeatureDiagnosticHelp {
230    pub(crate) feature: Symbol,
231}
232
233#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for FeatureDiagnosticSuggestion {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    FeatureDiagnosticSuggestion {
                        feature: __binding_0, span: __binding_1 } => {
                        let __code_0 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("#![feature({0})]\n",
                                                        __binding_0))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("feature".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("add `#![feature({$feature})]` to the crate attributes to enable")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_1, __message,
                            __code_0, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
234#[suggestion(
235    "add `#![feature({$feature})]` to the crate attributes to enable",
236    applicability = "maybe-incorrect",
237    code = "#![feature({feature})]\n"
238)]
239pub(crate) struct FeatureDiagnosticSuggestion {
240    pub feature: Symbol,
241    #[primary_span]
242    pub span: Span,
243}
244
245#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for CliFeatureDiagnosticHelp {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    CliFeatureDiagnosticHelp { feature: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("feature".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("add `-Zcrate-attr=\"feature({$feature})\"` to the command-line options to enable")),
                                &sub_args);
                        diag.help(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
246#[help("add `-Zcrate-attr=\"feature({$feature})\"` to the command-line options to enable")]
247pub(crate) struct CliFeatureDiagnosticHelp {
248    pub(crate) feature: Symbol,
249}
250
251#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            NotCircumventFeature where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    NotCircumventFeature => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zunleash-the-miri-inside-of-you` may not be used to circumvent feature gates, except when testing error paths in the CTFE engine")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
252#[diag(
253    "`-Zunleash-the-miri-inside-of-you` may not be used to circumvent feature gates, except when testing error paths in the CTFE engine"
254)]
255pub(crate) struct NotCircumventFeature;
256
257#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            LinkerPluginToWindowsNotSupported where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    LinkerPluginToWindowsNotSupported => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("linker plugin based LTO is not supported together with `-C prefer-dynamic` when targeting Windows-like targets")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
258#[diag(
259    "linker plugin based LTO is not supported together with `-C prefer-dynamic` when targeting Windows-like targets"
260)]
261pub(crate) struct LinkerPluginToWindowsNotSupported;
262
263#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            ProfileUseFileDoesNotExist<'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 {
                    ProfileUseFileDoesNotExist { path: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("file `{$path}` passed to `-C profile-use` does not exist")));
                        ;
                        diag.arg("path", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
264#[diag("file `{$path}` passed to `-C profile-use` does not exist")]
265pub(crate) struct ProfileUseFileDoesNotExist<'a> {
266    pub(crate) path: &'a std::path::Path,
267}
268
269#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            ProfileSampleUseFileDoesNotExist<'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 {
                    ProfileSampleUseFileDoesNotExist { path: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("file `{$path}` passed to `-C profile-sample-use` does not exist")));
                        ;
                        diag.arg("path", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
270#[diag("file `{$path}` passed to `-C profile-sample-use` does not exist")]
271pub(crate) struct ProfileSampleUseFileDoesNotExist<'a> {
272    pub(crate) path: &'a std::path::Path,
273}
274
275#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            TargetRequiresUnwindTables where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    TargetRequiresUnwindTables => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("target requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
276#[diag("target requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`")]
277pub(crate) struct TargetRequiresUnwindTables;
278
279#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InstrumentationNotSupported where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    InstrumentationNotSupported { us: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$us} instrumentation is not supported for this target")));
                        ;
                        diag.arg("us", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
280#[diag("{$us} instrumentation is not supported for this target")]
281pub(crate) struct InstrumentationNotSupported {
282    pub(crate) us: String,
283}
284
285#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SanitizerNotSupported where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SanitizerNotSupported { us: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$us} sanitizer is not supported for this target")));
                        ;
                        diag.arg("us", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
286#[diag("{$us} sanitizer is not supported for this target")]
287pub(crate) struct SanitizerNotSupported {
288    pub(crate) us: String,
289}
290
291#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SanitizersNotSupported where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SanitizersNotSupported { us: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$us} sanitizers are not supported for this target")));
                        ;
                        diag.arg("us", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
292#[diag("{$us} sanitizers are not supported for this target")]
293pub(crate) struct SanitizersNotSupported {
294    pub(crate) us: String,
295}
296
297#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            CannotMixAndMatchSanitizers where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    CannotMixAndMatchSanitizers {
                        first: __binding_0, second: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsanitizer={$first}` is incompatible with `-Zsanitizer={$second}`")));
                        ;
                        diag.arg("first", __binding_0);
                        diag.arg("second", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
298#[diag("`-Zsanitizer={$first}` is incompatible with `-Zsanitizer={$second}`")]
299pub(crate) struct CannotMixAndMatchSanitizers {
300    pub(crate) first: String,
301    pub(crate) second: String,
302}
303
304#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            CannotEnableCrtStaticLinux where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    CannotEnableCrtStaticLinux => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("sanitizer is incompatible with statically linked libc, disable it using `-C target-feature=-crt-static`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
305#[diag(
306    "sanitizer is incompatible with statically linked libc, disable it using `-C target-feature=-crt-static`"
307)]
308pub(crate) struct CannotEnableCrtStaticLinux;
309
310#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SanitizerCfiRequiresLto where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SanitizerCfiRequiresLto => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
311#[diag("`-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto`")]
312pub(crate) struct SanitizerCfiRequiresLto;
313
314#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SanitizerCfiRequiresSingleCodegenUnit where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SanitizerCfiRequiresSingleCodegenUnit => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
315#[diag("`-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1`")]
316pub(crate) struct SanitizerCfiRequiresSingleCodegenUnit;
317
318#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SanitizerCfiCanonicalJumpTablesRequiresCfi where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SanitizerCfiCanonicalJumpTablesRequiresCfi => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
319#[diag("`-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi`")]
320pub(crate) struct SanitizerCfiCanonicalJumpTablesRequiresCfi;
321
322#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SanitizerCfiGeneralizePointersRequiresCfi where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SanitizerCfiGeneralizePointersRequiresCfi => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
323#[diag("`-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`")]
324pub(crate) struct SanitizerCfiGeneralizePointersRequiresCfi;
325
326#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SanitizerCfiNormalizeIntegersRequiresCfi where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SanitizerCfiNormalizeIntegersRequiresCfi => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
327#[diag("`-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`")]
328pub(crate) struct SanitizerCfiNormalizeIntegersRequiresCfi;
329
330#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SanitizerKcfiArityRequiresKcfi where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SanitizerKcfiArityRequiresKcfi => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsanitizer-kcfi-arity` requires `-Zsanitizer=kcfi`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
331#[diag("`-Zsanitizer-kcfi-arity` requires `-Zsanitizer=kcfi`")]
332pub(crate) struct SanitizerKcfiArityRequiresKcfi;
333
334#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SanitizerKcfiRequiresPanicAbort where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SanitizerKcfiRequiresPanicAbort => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Z sanitizer=kcfi` requires `-C panic=abort`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
335#[diag("`-Z sanitizer=kcfi` requires `-C panic=abort`")]
336pub(crate) struct SanitizerKcfiRequiresPanicAbort;
337
338#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SplitLtoUnitRequiresLto where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SplitLtoUnitRequiresLto => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsplit-lto-unit` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
339#[diag("`-Zsplit-lto-unit` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto`")]
340pub(crate) struct SplitLtoUnitRequiresLto;
341
342#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnstableVirtualFunctionElimination where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnstableVirtualFunctionElimination => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zvirtual-function-elimination` requires `-Clto`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
343#[diag("`-Zvirtual-function-elimination` requires `-Clto`")]
344pub(crate) struct UnstableVirtualFunctionElimination;
345
346#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnsupportedDwarfVersion where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnsupportedDwarfVersion { dwarf_version: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("requested DWARF version {$dwarf_version} is not supported")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("supported DWARF versions are 2, 3, 4 and 5")));
                        ;
                        diag.arg("dwarf_version", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
347#[diag("requested DWARF version {$dwarf_version} is not supported")]
348#[help("supported DWARF versions are 2, 3, 4 and 5")]
349pub(crate) struct UnsupportedDwarfVersion {
350    pub(crate) dwarf_version: u32,
351}
352
353#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            EmbedSourceInsufficientDwarfVersion where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    EmbedSourceInsufficientDwarfVersion {
                        dwarf_version: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zembed-source=y` requires at least `-Z dwarf-version=5` but DWARF version is {$dwarf_version}")));
                        ;
                        diag.arg("dwarf_version", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
354#[diag(
355    "`-Zembed-source=y` requires at least `-Z dwarf-version=5` but DWARF version is {$dwarf_version}"
356)]
357pub(crate) struct EmbedSourceInsufficientDwarfVersion {
358    pub(crate) dwarf_version: u32,
359}
360
361#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            EmbedSourceRequiresDebugInfo where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    EmbedSourceRequiresDebugInfo => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zembed-source=y` requires debug information to be enabled")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
362#[diag("`-Zembed-source=y` requires debug information to be enabled")]
363pub(crate) struct EmbedSourceRequiresDebugInfo;
364
365#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            StackProtectorNotSupportedForTarget<'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 {
                    StackProtectorNotSupportedForTarget {
                        stack_protector: __binding_0, target_triple: __binding_1 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Z stack-protector={$stack_protector}` is not supported for target {$target_triple} and will be ignored")));
                        ;
                        diag.arg("stack_protector", __binding_0);
                        diag.arg("target_triple", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
366#[diag(
367    "`-Z stack-protector={$stack_protector}` is not supported for target {$target_triple} and will be ignored"
368)]
369pub(crate) struct StackProtectorNotSupportedForTarget<'a> {
370    pub(crate) stack_protector: StackProtector,
371    pub(crate) target_triple: &'a TargetTuple,
372}
373
374#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            SmallDataThresholdNotSupportedForTarget<'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 {
                    SmallDataThresholdNotSupportedForTarget {
                        target_triple: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Z small-data-threshold` is not supported for target {$target_triple} and will be ignored")));
                        ;
                        diag.arg("target_triple", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
375#[diag(
376    "`-Z small-data-threshold` is not supported for target {$target_triple} and will be ignored"
377)]
378pub(crate) struct SmallDataThresholdNotSupportedForTarget<'a> {
379    pub(crate) target_triple: &'a TargetTuple,
380}
381
382#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BranchProtectionRequiresAArch64 where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    BranchProtectionRequiresAArch64 => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zbranch-protection` is only supported on aarch64")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
383#[diag("`-Zbranch-protection` is only supported on aarch64")]
384pub(crate) struct BranchProtectionRequiresAArch64;
385
386#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SplitDebugInfoUnstablePlatform where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SplitDebugInfoUnstablePlatform { debuginfo: __binding_0 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Csplit-debuginfo={$debuginfo}` is unstable on this platform")));
                        ;
                        diag.arg("debuginfo", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
387#[diag("`-Csplit-debuginfo={$debuginfo}` is unstable on this platform")]
388pub(crate) struct SplitDebugInfoUnstablePlatform {
389    pub(crate) debuginfo: SplitDebuginfo,
390}
391
392#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            FileIsNotWriteable<'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 {
                    FileIsNotWriteable { file: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("output file {$file} is not writeable -- check its permissions")));
                        ;
                        diag.arg("file", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
393#[diag("output file {$file} is not writeable -- check its permissions")]
394pub(crate) struct FileIsNotWriteable<'a> {
395    pub(crate) file: &'a std::path::Path,
396}
397
398#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            FileWriteFail<'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 {
                    FileWriteFail { path: __binding_0, err: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to write `{$path}` due to error `{$err}`")));
                        ;
                        diag.arg("path", __binding_0);
                        diag.arg("err", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
399#[diag("failed to write `{$path}` due to error `{$err}`")]
400pub(crate) struct FileWriteFail<'a> {
401    pub(crate) path: &'a std::path::Path,
402    pub(crate) err: String,
403}
404
405#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for CrateNameEmpty
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    CrateNameEmpty { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("crate name must not be empty")));
                        ;
                        if let Some(__binding_0) = __binding_0 {
                            diag.span(__binding_0);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
406#[diag("crate name must not be empty")]
407pub(crate) struct CrateNameEmpty {
408    #[primary_span]
409    pub(crate) span: Option<Span>,
410}
411
412#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidCharacterInCrateName where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    InvalidCharacterInCrateName {
                        span: __binding_0,
                        character: __binding_1,
                        crate_name: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid character {$character} in crate name: `{$crate_name}`")));
                        ;
                        diag.arg("character", __binding_1);
                        diag.arg("crate_name", __binding_2);
                        if let Some(__binding_0) = __binding_0 {
                            diag.span(__binding_0);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
413#[diag("invalid character {$character} in crate name: `{$crate_name}`")]
414pub(crate) struct InvalidCharacterInCrateName {
415    #[primary_span]
416    pub(crate) span: Option<Span>,
417    pub(crate) character: char,
418    pub(crate) crate_name: Symbol,
419}
420
421#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for ExprParenthesesNeeded {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ExprParenthesesNeeded {
                        left: __binding_0, right: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_1 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("("))
                                });
                        let __code_2 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        suggestions.push((__binding_0, __code_1));
                        suggestions.push((__binding_1, __code_2));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("parentheses are required to parse this as an expression")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
422#[multipart_suggestion(
423    "parentheses are required to parse this as an expression",
424    applicability = "machine-applicable"
425)]
426pub struct ExprParenthesesNeeded {
427    #[suggestion_part(code = "(")]
428    left: Span,
429    #[suggestion_part(code = ")")]
430    right: Span,
431}
432
433impl ExprParenthesesNeeded {
434    pub fn surrounding(s: Span) -> Self {
435        ExprParenthesesNeeded { left: s.shrink_to_lo(), right: s.shrink_to_hi() }
436    }
437}
438
439#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SkippingConstChecks where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SkippingConstChecks { unleashed_features: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("skipping const checks")));
                        ;
                        for __binding_0 in __binding_0 {
                            diag.subdiagnostic(__binding_0);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
440#[diag("skipping const checks")]
441pub(crate) struct SkippingConstChecks {
442    #[subdiagnostic]
443    pub(crate) unleashed_features: Vec<UnleashedFeatureHelp>,
444}
445
446#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for UnleashedFeatureHelp {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    UnleashedFeatureHelp::Named {
                        span: __binding_0, gate: __binding_1 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("gate".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("skipping check for `{$gate}` feature")),
                                &sub_args);
                        diag.span_help(__binding_0, __message);
                    }
                    UnleashedFeatureHelp::Unnamed { 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("skipping check that does not even have a feature gate")),
                                &sub_args);
                        diag.span_help(__binding_0, __message);
                    }
                }
            }
        }
    };Subdiagnostic)]
447pub(crate) enum UnleashedFeatureHelp {
448    #[help("skipping check for `{$gate}` feature")]
449    Named {
450        #[primary_span]
451        span: Span,
452        gate: Symbol,
453    },
454    #[help("skipping check that does not even have a feature gate")]
455    Unnamed {
456        #[primary_span]
457        span: Span,
458    },
459}
460
461#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidLiteralSuffix<'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 {
                    InvalidLiteralSuffix {
                        span: __binding_0, kind: __binding_1, suffix: __binding_2 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("suffixes on {$kind} literals are invalid")));
                        ;
                        diag.arg("kind", __binding_1);
                        diag.arg("suffix", __binding_2);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid suffix `{$suffix}`")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
462#[diag("suffixes on {$kind} literals are invalid")]
463struct InvalidLiteralSuffix<'a> {
464    #[primary_span]
465    #[label("invalid suffix `{$suffix}`")]
466    span: Span,
467    // FIXME(#100717)
468    kind: &'a str,
469    suffix: Symbol,
470}
471
472#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidIntLiteralWidth where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    InvalidIntLiteralWidth {
                        span: __binding_0, width: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid width `{$width}` for integer literal")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("valid widths are 8, 16, 32, 64 and 128")));
                        ;
                        diag.arg("width", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
473#[diag("invalid width `{$width}` for integer literal")]
474#[help("valid widths are 8, 16, 32, 64 and 128")]
475struct InvalidIntLiteralWidth {
476    #[primary_span]
477    span: Span,
478    width: String,
479}
480
481#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidNumLiteralBasePrefix where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    InvalidNumLiteralBasePrefix {
                        span: __binding_0, fixed: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid base prefix for number literal")));
                        let __code_3 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_1))
                                            })].into_iter();
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase")));
                        ;
                        diag.arg("fixed", __binding_1);
                        diag.span(__binding_0);
                        diag.span_suggestions_with_style(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try making the prefix lowercase")),
                            __code_3, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
482#[diag("invalid base prefix for number literal")]
483#[note("base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase")]
484struct InvalidNumLiteralBasePrefix {
485    #[primary_span]
486    #[suggestion(
487        "try making the prefix lowercase",
488        applicability = "maybe-incorrect",
489        code = "{fixed}"
490    )]
491    span: Span,
492    fixed: String,
493}
494
495#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidNumLiteralSuffix where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    InvalidNumLiteralSuffix {
                        span: __binding_0, suffix: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid suffix `{$suffix}` for number literal")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)")));
                        ;
                        diag.arg("suffix", __binding_1);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid suffix `{$suffix}`")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
496#[diag("invalid suffix `{$suffix}` for number literal")]
497#[help("the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)")]
498struct InvalidNumLiteralSuffix {
499    #[primary_span]
500    #[label("invalid suffix `{$suffix}`")]
501    span: Span,
502    suffix: String,
503}
504
505#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidFloatLiteralWidth where G: rustc_errors::EmissionGuarantee
            {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    InvalidFloatLiteralWidth {
                        span: __binding_0, width: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid width `{$width}` for float literal")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("valid widths are 32 and 64")));
                        ;
                        diag.arg("width", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
506#[diag("invalid width `{$width}` for float literal")]
507#[help("valid widths are 32 and 64")]
508struct InvalidFloatLiteralWidth {
509    #[primary_span]
510    span: Span,
511    width: String,
512}
513
514#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidFloatLiteralSuffix where G: rustc_errors::EmissionGuarantee
            {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    InvalidFloatLiteralSuffix {
                        span: __binding_0, suffix: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid suffix `{$suffix}` for float literal")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("valid suffixes are `f32` and `f64`")));
                        ;
                        diag.arg("suffix", __binding_1);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("invalid suffix `{$suffix}`")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
515#[diag("invalid suffix `{$suffix}` for float literal")]
516#[help("valid suffixes are `f32` and `f64`")]
517struct InvalidFloatLiteralSuffix {
518    #[primary_span]
519    #[label("invalid suffix `{$suffix}`")]
520    span: Span,
521    suffix: String,
522}
523
524#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            IntLiteralTooLarge where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    IntLiteralTooLarge { span: __binding_0, limit: __binding_1 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("integer literal is too large")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("value exceeds limit of `{$limit}`")));
                        ;
                        diag.arg("limit", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
525#[diag("integer literal is too large")]
526#[note("value exceeds limit of `{$limit}`")]
527struct IntLiteralTooLarge {
528    #[primary_span]
529    span: Span,
530    limit: String,
531}
532
533#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            HexadecimalFloatLiteralNotSupported where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    HexadecimalFloatLiteralNotSupported { span: __binding_0 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("hexadecimal float literal is not supported")));
                        ;
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not supported")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
534#[diag("hexadecimal float literal is not supported")]
535struct HexadecimalFloatLiteralNotSupported {
536    #[primary_span]
537    #[label("not supported")]
538    span: Span,
539}
540
541#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            OctalFloatLiteralNotSupported where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    OctalFloatLiteralNotSupported { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("octal float literal is not supported")));
                        ;
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not supported")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
542#[diag("octal float literal is not supported")]
543struct OctalFloatLiteralNotSupported {
544    #[primary_span]
545    #[label("not supported")]
546    span: Span,
547}
548
549#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            BinaryFloatLiteralNotSupported where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    BinaryFloatLiteralNotSupported { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("binary float literal is not supported")));
                        ;
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("not supported")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
550#[diag("binary float literal is not supported")]
551struct BinaryFloatLiteralNotSupported {
552    #[primary_span]
553    #[label("not supported")]
554    span: Span,
555}
556
557pub fn report_lit_error(
558    psess: &ParseSess,
559    err: LitError,
560    lit: token::Lit,
561    span: Span,
562) -> ErrorGuaranteed {
563    create_lit_error(psess, err, lit, span).emit()
564}
565
566pub fn create_lit_error(psess: &ParseSess, err: LitError, lit: token::Lit, span: Span) -> Diag<'_> {
567    // Checks if `s` looks like i32 or u1234 etc.
568    fn looks_like_width_suffix(first_chars: &[char], s: &str) -> bool {
569        s.len() > 1 && s.starts_with(first_chars) && s[1..].chars().all(|c| c.is_ascii_digit())
570    }
571
572    // Try to lowercase the prefix if the prefix and suffix are valid.
573    fn fix_base_capitalisation(prefix: &str, suffix: &str) -> Option<String> {
574        let mut chars = suffix.chars();
575
576        let base_char = chars.next().unwrap();
577        let base = match base_char {
578            'B' => 2,
579            'O' => 8,
580            'X' => 16,
581            _ => return None,
582        };
583
584        // check that the suffix contains only base-appropriate characters
585        let valid = prefix == "0"
586            && chars
587                .filter(|c| *c != '_')
588                .take_while(|c| *c != 'i' && *c != 'u')
589                .all(|c| c.to_digit(base).is_some());
590
591        valid.then(|| ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("0{0}{1}",
                base_char.to_ascii_lowercase(), &suffix[1..]))
    })format!("0{}{}", base_char.to_ascii_lowercase(), &suffix[1..]))
592    }
593
594    let dcx = psess.dcx();
595    match err {
596        LitError::InvalidSuffix(suffix) => {
597            dcx.create_err(InvalidLiteralSuffix { span, kind: lit.kind.descr(), suffix })
598        }
599        LitError::InvalidIntSuffix(suffix) => {
600            let suf = suffix.as_str();
601            if looks_like_width_suffix(&['i', 'u'], suf) {
602                // If it looks like a width, try to be helpful.
603                dcx.create_err(InvalidIntLiteralWidth { span, width: suf[1..].into() })
604            } else if let Some(fixed) = fix_base_capitalisation(lit.symbol.as_str(), suf) {
605                dcx.create_err(InvalidNumLiteralBasePrefix { span, fixed })
606            } else {
607                dcx.create_err(InvalidNumLiteralSuffix { span, suffix: suf.to_string() })
608            }
609        }
610        LitError::InvalidFloatSuffix(suffix) => {
611            let suf = suffix.as_str();
612            if looks_like_width_suffix(&['f'], suf) {
613                // If it looks like a width, try to be helpful.
614                dcx.create_err(InvalidFloatLiteralWidth { span, width: suf[1..].to_string() })
615            } else {
616                dcx.create_err(InvalidFloatLiteralSuffix { span, suffix: suf.to_string() })
617            }
618        }
619        LitError::NonDecimalFloat(base) => match base {
620            16 => dcx.create_err(HexadecimalFloatLiteralNotSupported { span }),
621            8 => dcx.create_err(OctalFloatLiteralNotSupported { span }),
622            2 => dcx.create_err(BinaryFloatLiteralNotSupported { span }),
623            _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
624        },
625        LitError::IntTooLarge(base) => {
626            let max = u128::MAX;
627            let limit = match base {
628                2 => ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0:#b}", max))
    })format!("{max:#b}"),
629                8 => ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0:#o}", max))
    })format!("{max:#o}"),
630                16 => ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0:#x}", max))
    })format!("{max:#x}"),
631                _ => ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0}", max))
    })format!("{max}"),
632            };
633            dcx.create_err(IntLiteralTooLarge { span, limit })
634        }
635    }
636}
637
638#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            IncompatibleLinkerFlavor where G: rustc_errors::EmissionGuarantee
            {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    IncompatibleLinkerFlavor {
                        flavor: __binding_0, compatible_list: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("linker flavor `{$flavor}` is incompatible with the current target")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("compatible flavors are: {$compatible_list}")));
                        ;
                        diag.arg("flavor", __binding_0);
                        diag.arg("compatible_list", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
639#[diag("linker flavor `{$flavor}` is incompatible with the current target")]
640#[note("compatible flavors are: {$compatible_list}")]
641pub(crate) struct IncompatibleLinkerFlavor {
642    pub(crate) flavor: &'static str,
643    pub(crate) compatible_list: String,
644}
645
646#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            FunctionReturnRequiresX86OrX8664 where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    FunctionReturnRequiresX86OrX8664 => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zfunction-return` (except `keep`) is only supported on x86 and x86_64")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
647#[diag("`-Zfunction-return` (except `keep`) is only supported on x86 and x86_64")]
648pub(crate) struct FunctionReturnRequiresX86OrX8664;
649
650#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            FunctionReturnThunkExternRequiresNonLargeCodeModel where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    FunctionReturnThunkExternRequiresNonLargeCodeModel => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zfunction-return=thunk-extern` is only supported on non-large code models")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
651#[diag("`-Zfunction-return=thunk-extern` is only supported on non-large code models")]
652pub(crate) struct FunctionReturnThunkExternRequiresNonLargeCodeModel;
653
654#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            IndirectBranchCsPrefixRequiresX86OrX8664 where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    IndirectBranchCsPrefixRequiresX86OrX8664 => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zindirect-branch-cs-prefix` is only supported on x86 and x86_64")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
655#[diag("`-Zindirect-branch-cs-prefix` is only supported on x86 and x86_64")]
656pub(crate) struct IndirectBranchCsPrefixRequiresX86OrX8664;
657
658#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnsupportedRegparm where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnsupportedRegparm { regparm: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zregparm={$regparm}` is unsupported (valid values 0-3)")));
                        ;
                        diag.arg("regparm", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
659#[diag("`-Zregparm={$regparm}` is unsupported (valid values 0-3)")]
660pub(crate) struct UnsupportedRegparm {
661    pub(crate) regparm: u32,
662}
663
664#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnsupportedRegparmArch where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnsupportedRegparmArch => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zregparm=N` is only supported on x86")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
665#[diag("`-Zregparm=N` is only supported on x86")]
666pub(crate) struct UnsupportedRegparmArch;
667
668#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnsupportedRegStructReturnArch where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnsupportedRegStructReturnArch => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zreg-struct-return` is only supported on x86")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
669#[diag("`-Zreg-struct-return` is only supported on x86")]
670pub(crate) struct UnsupportedRegStructReturnArch;
671
672#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            FailedToCreateProfiler where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    FailedToCreateProfiler { err: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to create profiler: {$err}")));
                        ;
                        diag.arg("err", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
673#[diag("failed to create profiler: {$err}")]
674pub(crate) struct FailedToCreateProfiler {
675    pub(crate) err: String,
676}
677
678#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnexpectedBuiltinCfg where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnexpectedBuiltinCfg {
                        cfg: __binding_0,
                        cfg_name: __binding_1,
                        controlled_by: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unexpected `--cfg {$cfg}` flag")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("config `{$cfg_name}` is only supposed to be controlled by `{$controlled_by}`")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("manually setting a built-in cfg can and does create incoherent behaviors")));
                        ;
                        diag.arg("cfg", __binding_0);
                        diag.arg("cfg_name", __binding_1);
                        diag.arg("controlled_by", __binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
679#[diag("unexpected `--cfg {$cfg}` flag")]
680#[note("config `{$cfg_name}` is only supposed to be controlled by `{$controlled_by}`")]
681#[note("manually setting a built-in cfg can and does create incoherent behaviors")]
682pub(crate) struct UnexpectedBuiltinCfg {
683    pub(crate) cfg: String,
684    pub(crate) cfg_name: Symbol,
685    pub(crate) controlled_by: &'static str,
686}
687
688#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ThinLtoNotSupportedByBackend where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ThinLtoNotSupportedByBackend => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("ThinLTO is not supported by the codegen backend, using fat LTO instead")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
689#[diag("ThinLTO is not supported by the codegen backend, using fat LTO instead")]
690pub(crate) struct ThinLtoNotSupportedByBackend;
691
692#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnsupportedPackedStack where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnsupportedPackedStack => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zpacked-stack` is only supported on s390x")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
693#[diag("`-Zpacked-stack` is only supported on s390x")]
694pub(crate) struct UnsupportedPackedStack;