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