Skip to main content

rustc_session/
diagnostics.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-09-12")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
            CannotEnableCrtStaticPointerAuth where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    CannotEnableCrtStaticPointerAuth => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("pointer authentication requires dynamic linking. Statically linked libc is incompatible, disable it using `-C target-feature=-crt-static`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
315#[diag(
316    "pointer authentication requires dynamic linking. Statically linked libc is incompatible, disable it using `-C target-feature=-crt-static`"
317)]
318pub(crate) struct CannotEnableCrtStaticPointerAuth;
319
320#[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)]
321#[diag("`-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto`")]
322pub(crate) struct SanitizerCfiRequiresLto;
323
324#[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)]
325#[diag("`-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1`")]
326pub(crate) struct SanitizerCfiRequiresSingleCodegenUnit;
327
328#[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)]
329#[diag("`-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi`")]
330pub(crate) struct SanitizerCfiCanonicalJumpTablesRequiresCfi;
331
332#[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)]
333#[diag("`-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`")]
334pub(crate) struct SanitizerCfiGeneralizePointersRequiresCfi;
335
336#[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)]
337#[diag("`-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi`")]
338pub(crate) struct SanitizerCfiNormalizeIntegersRequiresCfi;
339
340#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SanitizerCfiRecoverRequiresCfi where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SanitizerCfiRecoverRequiresCfi => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsanitizer-cfi-recover` requires `-Zsanitizer=cfi`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
341#[diag("`-Zsanitizer-cfi-recover` requires `-Zsanitizer=cfi`")]
342pub(crate) struct SanitizerCfiRecoverRequiresCfi;
343
344#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SanitizerCfiDiagRequiresCfi where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SanitizerCfiDiagRequiresCfi => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsanitizer-cfi-diag` requires `-Zsanitizer=cfi`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
345#[diag("`-Zsanitizer-cfi-diag` requires `-Zsanitizer=cfi`")]
346pub(crate) struct SanitizerCfiDiagRequiresCfi;
347
348#[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)]
349#[diag("`-Zsanitizer-kcfi-arity` requires `-Zsanitizer=kcfi`")]
350pub(crate) struct SanitizerKcfiArityRequiresKcfi;
351
352#[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)]
353#[diag("`-Z sanitizer=kcfi` requires `-C panic=abort`")]
354pub(crate) struct SanitizerKcfiRequiresPanicAbort;
355
356#[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)]
357#[diag("`-Zsplit-lto-unit` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto`")]
358pub(crate) struct SplitLtoUnitRequiresLto;
359
360#[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)]
361#[diag("`-Zvirtual-function-elimination` requires `-Clto`")]
362pub(crate) struct UnstableVirtualFunctionElimination;
363
364#[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)]
365#[diag("requested DWARF version {$dwarf_version} is not supported")]
366#[help("supported DWARF versions are 2, 3, 4 and 5")]
367pub(crate) struct UnsupportedDwarfVersion {
368    pub(crate) dwarf_version: u32,
369}
370
371#[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)]
372#[diag(
373    "`-Zembed-source=y` requires at least `-Z dwarf-version=5` but DWARF version is {$dwarf_version}"
374)]
375pub(crate) struct EmbedSourceInsufficientDwarfVersion {
376    pub(crate) dwarf_version: u32,
377}
378
379#[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)]
380#[diag("`-Zembed-source=y` requires debug information to be enabled")]
381pub(crate) struct EmbedSourceRequiresDebugInfo;
382
383#[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)]
384#[diag(
385    "`-Z stack-protector={$stack_protector}` is not supported for target {$target_triple} and will be ignored"
386)]
387pub(crate) struct StackProtectorNotSupportedForTarget<'a> {
388    pub(crate) stack_protector: StackProtector,
389    pub(crate) target_triple: &'a TargetTuple,
390}
391
392#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            PointerAuthenticationTypeDiscriminationNotSupportedForTarget<'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 {
                    PointerAuthenticationTypeDiscriminationNotSupportedForTarget {
                        target_triple: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("function pointer type discrimination is not supported")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
393#[diag("function pointer type discrimination is not supported")]
394pub(crate) struct PointerAuthenticationTypeDiscriminationNotSupportedForTarget<'a> {
395    pub(crate) target_triple: &'a TargetTuple,
396}
397
398#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            PointerAuthenticationNotSupportedForTarget<'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 {
                    PointerAuthenticationNotSupportedForTarget {
                        target_triple: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Z pointer-authentication` is not supported for target {$target_triple} and will be ignored")));
                        ;
                        diag.arg("target_triple", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
399#[diag(
400    "`-Z pointer-authentication` is not supported for target {$target_triple} and will be ignored"
401)]
402pub(crate) struct PointerAuthenticationNotSupportedForTarget<'a> {
403    pub(crate) target_triple: &'a TargetTuple,
404}
405
406#[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)]
407#[diag(
408    "`-Z small-data-threshold` is not supported for target {$target_triple} and will be ignored"
409)]
410pub(crate) struct SmallDataThresholdNotSupportedForTarget<'a> {
411    pub(crate) target_triple: &'a TargetTuple,
412}
413
414#[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)]
415#[diag("`-Zbranch-protection` is only supported on aarch64")]
416pub(crate) struct BranchProtectionRequiresAArch64;
417
418#[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)]
419#[diag("`-Csplit-debuginfo={$debuginfo}` is unstable on this platform")]
420pub(crate) struct SplitDebugInfoUnstablePlatform {
421    pub(crate) debuginfo: SplitDebuginfo,
422}
423
424#[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)]
425#[diag("output file {$file} is not writeable -- check its permissions")]
426pub(crate) struct FileIsNotWriteable<'a> {
427    pub(crate) file: &'a std::path::Path,
428}
429
430#[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)]
431#[diag("failed to write `{$path}` due to error `{$err}`")]
432pub(crate) struct FileWriteFail<'a> {
433    pub(crate) path: &'a std::path::Path,
434    pub(crate) err: String,
435}
436
437#[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)]
438#[diag("crate name must not be empty")]
439pub(crate) struct CrateNameEmpty {
440    #[primary_span]
441    pub(crate) span: Option<Span>,
442}
443
444#[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,
                        suggestion: __binding_3 } => {
                        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.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("crate names may only contain alphanumeric characters or underscores")));
                        ;
                        diag.arg("character", __binding_1);
                        diag.arg("crate_name", __binding_2);
                        if let Some(__binding_0) = __binding_0 {
                            diag.span(__binding_0);
                        }
                        if let Some(__binding_3) = __binding_3 {
                            diag.subdiagnostic(__binding_3);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
445#[diag("invalid character {$character} in crate name: `{$crate_name}`")]
446#[note("crate names may only contain alphanumeric characters or underscores")]
447pub(crate) struct InvalidCharacterInCrateName {
448    #[primary_span]
449    pub(crate) span: Option<Span>,
450    pub(crate) character: char,
451    pub(crate) crate_name: Symbol,
452    #[subdiagnostic]
453    pub(crate) suggestion: Option<InvalidCharacterInCrateNameSuggestion>,
454}
455
456#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for
            InvalidCharacterInCrateNameSuggestion {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    InvalidCharacterInCrateNameSuggestion {
                        suggested_name: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("suggested_name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to use `--crate-name={$suggested_name}`")),
                                &sub_args);
                        diag.help(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
457#[help("you might have meant to use `--crate-name={$suggested_name}`")]
458pub(crate) struct InvalidCharacterInCrateNameSuggestion {
459    pub(crate) suggested_name: String,
460}
461
462#[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)]
463#[diag("skipping const checks")]
464pub(crate) struct SkippingConstChecks {
465    #[subdiagnostic]
466    pub(crate) unleashed_features: Vec<UnleashedFeatureHelp>,
467}
468
469#[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)]
470pub(crate) enum UnleashedFeatureHelp {
471    #[help("skipping check for `{$gate}` feature")]
472    Named {
473        #[primary_span]
474        span: Span,
475        gate: Symbol,
476    },
477    #[help("skipping check that does not even have a feature gate")]
478    Unnamed {
479        #[primary_span]
480        span: Span,
481    },
482}
483
484#[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)]
485#[diag("suffixes on {$kind} literals are invalid")]
486struct InvalidLiteralSuffix<'a> {
487    #[primary_span]
488    #[label("invalid suffix `{$suffix}`")]
489    span: Span,
490    // FIXME(#100717)
491    kind: &'a str,
492    suffix: Symbol,
493}
494
495#[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)]
496#[diag("invalid width `{$width}` for integer literal")]
497#[help("valid widths are 8, 16, 32, 64 and 128")]
498struct InvalidIntLiteralWidth {
499    #[primary_span]
500    span: Span,
501    width: String,
502}
503
504#[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_1 =
                            [::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_1, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
505#[diag("invalid base prefix for number literal")]
506#[note("base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase")]
507struct InvalidNumLiteralBasePrefix {
508    #[primary_span]
509    #[suggestion(
510        "try making the prefix lowercase",
511        applicability = "maybe-incorrect",
512        code = "{fixed}"
513    )]
514    span: Span,
515    fixed: String,
516}
517
518#[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)]
519#[diag("invalid suffix `{$suffix}` for number literal")]
520#[help("the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)")]
521struct InvalidNumLiteralSuffix {
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
            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)]
529#[diag("invalid width `{$width}` for float literal")]
530#[help("valid widths are 32 and 64")]
531struct InvalidFloatLiteralWidth {
532    #[primary_span]
533    span: Span,
534    width: String,
535}
536
537#[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)]
538#[diag("invalid suffix `{$suffix}` for float literal")]
539#[help("valid suffixes are `f32` and `f64`")]
540struct InvalidFloatLiteralSuffix {
541    #[primary_span]
542    #[label("invalid suffix `{$suffix}`")]
543    span: Span,
544    suffix: String,
545}
546
547#[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)]
548#[diag("integer literal is too large")]
549#[note("value exceeds limit of `{$limit}`")]
550struct IntLiteralTooLarge {
551    #[primary_span]
552    span: Span,
553    limit: String,
554}
555
556#[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)]
557#[diag("hexadecimal float literal is not supported")]
558struct HexadecimalFloatLiteralNotSupported {
559    #[primary_span]
560    #[label("not supported")]
561    span: Span,
562}
563
564#[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)]
565#[diag("octal float literal is not supported")]
566struct OctalFloatLiteralNotSupported {
567    #[primary_span]
568    #[label("not supported")]
569    span: Span,
570}
571
572#[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)]
573#[diag("binary float literal is not supported")]
574struct BinaryFloatLiteralNotSupported {
575    #[primary_span]
576    #[label("not supported")]
577    span: Span,
578}
579
580pub fn report_lit_error(
581    psess: &ParseSess,
582    err: LitError,
583    lit: token::Lit,
584    span: Span,
585) -> ErrorGuaranteed {
586    create_lit_error(psess, err, lit, span).emit()
587}
588
589pub fn create_lit_error(psess: &ParseSess, err: LitError, lit: token::Lit, span: Span) -> Diag<'_> {
590    // Checks if `s` looks like i32 or u1234 etc.
591    fn looks_like_width_suffix(first_chars: &[char], s: &str) -> bool {
592        s.len() > 1 && s.starts_with(first_chars) && s[1..].chars().all(|c| c.is_ascii_digit())
593    }
594
595    // Try to lowercase the prefix if the prefix and suffix are valid.
596    fn fix_base_capitalisation(prefix: &str, suffix: &str) -> Option<String> {
597        let mut chars = suffix.chars();
598
599        let base_char = chars.next().unwrap();
600        let base = match base_char {
601            'B' => 2,
602            'O' => 8,
603            'X' => 16,
604            _ => return None,
605        };
606
607        // check that the suffix contains only base-appropriate characters
608        let valid = prefix == "0"
609            && chars
610                .filter(|c| *c != '_')
611                .take_while(|c| *c != 'i' && *c != 'u')
612                .all(|c| c.to_digit(base).is_some());
613
614        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..]))
615    }
616
617    let dcx = psess.dcx();
618    match err {
619        LitError::InvalidSuffix(suffix) => {
620            dcx.create_err(InvalidLiteralSuffix { span, kind: lit.kind.descr(), suffix })
621        }
622        LitError::InvalidIntSuffix(suffix) => {
623            let suf = suffix.as_str();
624            if looks_like_width_suffix(&['i', 'u'], suf) {
625                // If it looks like a width, try to be helpful.
626                dcx.create_err(InvalidIntLiteralWidth { span, width: suf[1..].into() })
627            } else if let Some(fixed) = fix_base_capitalisation(lit.symbol.as_str(), suf) {
628                dcx.create_err(InvalidNumLiteralBasePrefix { span, fixed })
629            } else {
630                dcx.create_err(InvalidNumLiteralSuffix { span, suffix: suf.to_string() })
631            }
632        }
633        LitError::InvalidFloatSuffix(suffix) => {
634            let suf = suffix.as_str();
635            if looks_like_width_suffix(&['f'], suf) {
636                // If it looks like a width, try to be helpful.
637                dcx.create_err(InvalidFloatLiteralWidth { span, width: suf[1..].to_string() })
638            } else {
639                dcx.create_err(InvalidFloatLiteralSuffix { span, suffix: suf.to_string() })
640            }
641        }
642        LitError::NonDecimalFloat(base) => match base {
643            16 => dcx.create_err(HexadecimalFloatLiteralNotSupported { span }),
644            8 => dcx.create_err(OctalFloatLiteralNotSupported { span }),
645            2 => dcx.create_err(BinaryFloatLiteralNotSupported { span }),
646            _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
647        },
648        LitError::IntTooLarge(base) => {
649            let max = u128::MAX;
650            let limit = match base {
651                2 => ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0:#b}", max))
    })format!("{max:#b}"),
652                8 => ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0:#o}", max))
    })format!("{max:#o}"),
653                16 => ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0:#x}", max))
    })format!("{max:#x}"),
654                _ => ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0}", max))
    })format!("{max}"),
655            };
656            dcx.create_err(IntLiteralTooLarge { span, limit })
657        }
658    }
659}
660
661#[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)]
662#[diag("linker flavor `{$flavor}` is incompatible with the current target")]
663#[note("compatible flavors are: {$compatible_list}")]
664pub(crate) struct IncompatibleLinkerFlavor {
665    pub(crate) flavor: &'static str,
666    pub(crate) compatible_list: String,
667}
668
669#[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)]
670#[diag("`-Zfunction-return` (except `keep`) is only supported on x86 and x86_64")]
671pub(crate) struct FunctionReturnRequiresX86OrX8664;
672
673#[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)]
674#[diag("`-Zfunction-return=thunk-extern` is only supported on non-large code models")]
675pub(crate) struct FunctionReturnThunkExternRequiresNonLargeCodeModel;
676
677#[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)]
678#[diag("`-Zindirect-branch-cs-prefix` is only supported on x86 and x86_64")]
679pub(crate) struct IndirectBranchCsPrefixRequiresX86OrX8664;
680
681#[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)]
682#[diag("`-Zregparm={$regparm}` is unsupported (valid values 0-3)")]
683pub(crate) struct UnsupportedRegparm {
684    pub(crate) regparm: u32,
685}
686
687#[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)]
688#[diag("`-Zregparm=N` is only supported on x86")]
689pub(crate) struct UnsupportedRegparmArch;
690
691#[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)]
692#[diag("`-Zreg-struct-return` is only supported on x86")]
693pub(crate) struct UnsupportedRegStructReturnArch;
694
695#[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)]
696#[diag("failed to create profiler: {$err}")]
697pub(crate) struct FailedToCreateProfiler {
698    pub(crate) err: String,
699}
700
701#[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)]
702#[diag("unexpected `--cfg {$cfg}` flag")]
703#[note("config `{$cfg_name}` is only supposed to be controlled by `{$controlled_by}`")]
704#[note("manually setting a built-in cfg can and does create incoherent behaviors")]
705pub(crate) struct UnexpectedBuiltinCfg {
706    pub(crate) cfg: String,
707    pub(crate) cfg_name: Symbol,
708    pub(crate) controlled_by: &'static str,
709}
710
711#[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)]
712#[diag("ThinLTO is not supported by the codegen backend, using fat LTO instead")]
713pub(crate) struct ThinLtoNotSupportedByBackend;
714
715#[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)]
716#[diag("`-Zpacked-stack` is only supported on s390x")]
717pub(crate) struct UnsupportedPackedStack;
718
719#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            NativeTargetCpuNotAllowed<'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 {
                    NativeTargetCpuNotAllowed {
                        target_triple: __binding_0, need_explicit_cpu: __binding_1 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Ctarget-cpu=native` is not allowed for target `{$target_triple}`")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this target requires consistent `-Ctarget-cpu` values across all crates")));
                        diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("specify the target CPU explicitly {$need_explicit_cpu ->\n        [false] or leave it blank to use the default\n        *[other] {\"\"}\n    }")));
                        ;
                        diag.arg("target_triple", __binding_0);
                        diag.arg("need_explicit_cpu", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
720#[diag("`-Ctarget-cpu=native` is not allowed for target `{$target_triple}`")]
721#[note("this target requires consistent `-Ctarget-cpu` values across all crates")]
722#[help(
723    "specify the target CPU explicitly {$need_explicit_cpu ->
724        [false] or leave it blank to use the default
725        *[other] {\"\"}
726    }"
727)]
728pub(crate) struct NativeTargetCpuNotAllowed<'a> {
729    pub(crate) target_triple: &'a TargetTuple,
730    pub(crate) need_explicit_cpu: bool,
731}
732
733#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ResolveRelativePath where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ResolveRelativePath { span: __binding_0, path: __binding_1 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot resolve relative path in non-file source `{$path}`")));
                        ;
                        diag.arg("path", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
734#[diag("cannot resolve relative path in non-file source `{$path}`")]
735pub(crate) struct ResolveRelativePath {
736    #[primary_span]
737    pub span: Span,
738    pub path: String,
739}