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