Skip to main content

rustc_session/
errors.rs

1use std::num::{NonZero, ParseIntError};
2
3use rustc_ast::token;
4use rustc_ast::util::literal::LitError;
5use rustc_errors::codes::*;
6use rustc_errors::{
7    Diag, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, ErrorGuaranteed, Level,
8    MultiSpan,
9};
10use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
11use rustc_span::{Span, Symbol};
12use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTuple};
13
14use crate::parse::ParseSess;
15
16#[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,
                                crate::fluent_generated::session_apple_deployment_target_invalid);
                        ;
                        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,
                                crate::fluent_generated::session_apple_deployment_target_too_low);
                        ;
                        diag.arg("env_var", __binding_0);
                        diag.arg("version", __binding_1);
                        diag.arg("os_min", __binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
17pub(crate) enum AppleDeploymentTarget {
18    #[diag(session_apple_deployment_target_invalid)]
19    Invalid { env_var: &'static str, error: ParseIntError },
20    #[diag(session_apple_deployment_target_too_low)]
21    TooLow { env_var: &'static str, version: String, os_min: String },
22}
23
24pub(crate) struct FeatureGateError {
25    pub(crate) span: MultiSpan,
26    pub(crate) explain: DiagMessage,
27}
28
29impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for FeatureGateError {
30    #[track_caller]
31    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
32        Diag::new(dcx, level, self.explain).with_span(self.span).with_code(E0658)
33    }
34}
35
36#[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 } => {
                        diag.store_args();
                        diag.arg("n", __binding_0);
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::session_feature_diagnostic_for_issue);
                        diag.note(__message);
                        diag.restore_args();
                    }
                }
            }
        }
    };Subdiagnostic)]
37#[note(session_feature_diagnostic_for_issue)]
38pub(crate) struct FeatureDiagnosticForIssue {
39    pub(crate) n: NonZero<u32>,
40}
41
42#[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 } => {
                        diag.store_args();
                        diag.arg("date", __binding_0);
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::session_feature_suggest_upgrade_compiler);
                        diag.note(__message);
                        diag.restore_args();
                    }
                }
            }
        }
    };Subdiagnostic)]
43#[note(session_feature_suggest_upgrade_compiler)]
44pub(crate) struct SuggestUpgradeCompiler {
45    date: &'static str,
46}
47
48impl SuggestUpgradeCompiler {
49    pub(crate) fn ui_testing() -> Self {
50        Self { date: "YYYY-MM-DD" }
51    }
52
53    pub(crate) fn new() -> Option<Self> {
54        let date = ::core::option::Option::Some("2026-02-02")option_env!("CFG_VER_DATE")?;
55
56        Some(Self { date })
57    }
58}
59
60#[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 } => {
                        diag.store_args();
                        diag.arg("feature", __binding_0);
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::session_feature_diagnostic_help);
                        diag.help(__message);
                        diag.restore_args();
                    }
                }
            }
        }
    };Subdiagnostic)]
61#[help(session_feature_diagnostic_help)]
62pub(crate) struct FeatureDiagnosticHelp {
63    pub(crate) feature: Symbol,
64}
65
66#[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();
                        diag.store_args();
                        diag.arg("feature", __binding_0);
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::session_feature_diagnostic_suggestion);
                        diag.span_suggestions_with_style(__binding_1, __message,
                            __code_0, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag.restore_args();
                    }
                }
            }
        }
    };Subdiagnostic)]
67#[suggestion(
68    session_feature_diagnostic_suggestion,
69    applicability = "maybe-incorrect",
70    code = "#![feature({feature})]\n"
71)]
72pub struct FeatureDiagnosticSuggestion {
73    pub feature: Symbol,
74    #[primary_span]
75    pub span: Span,
76}
77
78#[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 } => {
                        diag.store_args();
                        diag.arg("feature", __binding_0);
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::session_cli_feature_diagnostic_help);
                        diag.help(__message);
                        diag.restore_args();
                    }
                }
            }
        }
    };Subdiagnostic)]
79#[help(session_cli_feature_diagnostic_help)]
80pub(crate) struct CliFeatureDiagnosticHelp {
81    pub(crate) feature: Symbol,
82}
83
84#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            MustBeNameOfAssociatedFunction where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    MustBeNameOfAssociatedFunction { span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                crate::fluent_generated::session_must_be_name_of_associated_function);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
85#[diag(session_must_be_name_of_associated_function)]
86pub struct MustBeNameOfAssociatedFunction {
87    #[primary_span]
88    pub span: Span,
89}
90
91#[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,
                                crate::fluent_generated::session_not_circumvent_feature);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
92#[diag(session_not_circumvent_feature)]
93pub(crate) struct NotCircumventFeature;
94
95#[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,
                                crate::fluent_generated::session_linker_plugin_lto_windows_not_supported);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
96#[diag(session_linker_plugin_lto_windows_not_supported)]
97pub(crate) struct LinkerPluginToWindowsNotSupported;
98
99#[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,
                                crate::fluent_generated::session_profile_use_file_does_not_exist);
                        ;
                        diag.arg("path", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
100#[diag(session_profile_use_file_does_not_exist)]
101pub(crate) struct ProfileUseFileDoesNotExist<'a> {
102    pub(crate) path: &'a std::path::Path,
103}
104
105#[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,
                                crate::fluent_generated::session_profile_sample_use_file_does_not_exist);
                        ;
                        diag.arg("path", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
106#[diag(session_profile_sample_use_file_does_not_exist)]
107pub(crate) struct ProfileSampleUseFileDoesNotExist<'a> {
108    pub(crate) path: &'a std::path::Path,
109}
110
111#[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,
                                crate::fluent_generated::session_target_requires_unwind_tables);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
112#[diag(session_target_requires_unwind_tables)]
113pub(crate) struct TargetRequiresUnwindTables;
114
115#[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,
                                crate::fluent_generated::session_instrumentation_not_supported);
                        ;
                        diag.arg("us", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
116#[diag(session_instrumentation_not_supported)]
117pub(crate) struct InstrumentationNotSupported {
118    pub(crate) us: String,
119}
120
121#[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,
                                crate::fluent_generated::session_sanitizer_not_supported);
                        ;
                        diag.arg("us", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
122#[diag(session_sanitizer_not_supported)]
123pub(crate) struct SanitizerNotSupported {
124    pub(crate) us: String,
125}
126
127#[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,
                                crate::fluent_generated::session_sanitizers_not_supported);
                        ;
                        diag.arg("us", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
128#[diag(session_sanitizers_not_supported)]
129pub(crate) struct SanitizersNotSupported {
130    pub(crate) us: String,
131}
132
133#[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,
                                crate::fluent_generated::session_cannot_mix_and_match_sanitizers);
                        ;
                        diag.arg("first", __binding_0);
                        diag.arg("second", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
134#[diag(session_cannot_mix_and_match_sanitizers)]
135pub(crate) struct CannotMixAndMatchSanitizers {
136    pub(crate) first: String,
137    pub(crate) second: String,
138}
139
140#[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,
                                crate::fluent_generated::session_cannot_enable_crt_static_linux);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
141#[diag(session_cannot_enable_crt_static_linux)]
142pub(crate) struct CannotEnableCrtStaticLinux;
143
144#[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,
                                crate::fluent_generated::session_sanitizer_cfi_requires_lto);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
145#[diag(session_sanitizer_cfi_requires_lto)]
146pub(crate) struct SanitizerCfiRequiresLto;
147
148#[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,
                                crate::fluent_generated::session_sanitizer_cfi_requires_single_codegen_unit);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
149#[diag(session_sanitizer_cfi_requires_single_codegen_unit)]
150pub(crate) struct SanitizerCfiRequiresSingleCodegenUnit;
151
152#[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,
                                crate::fluent_generated::session_sanitizer_cfi_canonical_jump_tables_requires_cfi);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
153#[diag(session_sanitizer_cfi_canonical_jump_tables_requires_cfi)]
154pub(crate) struct SanitizerCfiCanonicalJumpTablesRequiresCfi;
155
156#[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,
                                crate::fluent_generated::session_sanitizer_cfi_generalize_pointers_requires_cfi);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
157#[diag(session_sanitizer_cfi_generalize_pointers_requires_cfi)]
158pub(crate) struct SanitizerCfiGeneralizePointersRequiresCfi;
159
160#[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,
                                crate::fluent_generated::session_sanitizer_cfi_normalize_integers_requires_cfi);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
161#[diag(session_sanitizer_cfi_normalize_integers_requires_cfi)]
162pub(crate) struct SanitizerCfiNormalizeIntegersRequiresCfi;
163
164#[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,
                                crate::fluent_generated::session_sanitizer_kcfi_arity_requires_kcfi);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
165#[diag(session_sanitizer_kcfi_arity_requires_kcfi)]
166pub(crate) struct SanitizerKcfiArityRequiresKcfi;
167
168#[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,
                                crate::fluent_generated::session_sanitizer_kcfi_requires_panic_abort);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
169#[diag(session_sanitizer_kcfi_requires_panic_abort)]
170pub(crate) struct SanitizerKcfiRequiresPanicAbort;
171
172#[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,
                                crate::fluent_generated::session_split_lto_unit_requires_lto);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
173#[diag(session_split_lto_unit_requires_lto)]
174pub(crate) struct SplitLtoUnitRequiresLto;
175
176#[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,
                                crate::fluent_generated::session_unstable_virtual_function_elimination);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
177#[diag(session_unstable_virtual_function_elimination)]
178pub(crate) struct UnstableVirtualFunctionElimination;
179
180#[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,
                                crate::fluent_generated::session_unsupported_dwarf_version);
                        diag.help(crate::fluent_generated::session_unsupported_dwarf_version_help);
                        ;
                        diag.arg("dwarf_version", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
181#[diag(session_unsupported_dwarf_version)]
182#[help(session_unsupported_dwarf_version_help)]
183pub(crate) struct UnsupportedDwarfVersion {
184    pub(crate) dwarf_version: u32,
185}
186
187#[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,
                                crate::fluent_generated::session_embed_source_insufficient_dwarf_version);
                        ;
                        diag.arg("dwarf_version", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
188#[diag(session_embed_source_insufficient_dwarf_version)]
189pub(crate) struct EmbedSourceInsufficientDwarfVersion {
190    pub(crate) dwarf_version: u32,
191}
192
193#[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,
                                crate::fluent_generated::session_embed_source_requires_debug_info);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
194#[diag(session_embed_source_requires_debug_info)]
195pub(crate) struct EmbedSourceRequiresDebugInfo;
196
197#[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,
                                crate::fluent_generated::session_target_stack_protector_not_supported);
                        ;
                        diag.arg("stack_protector", __binding_0);
                        diag.arg("target_triple", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
198#[diag(session_target_stack_protector_not_supported)]
199pub(crate) struct StackProtectorNotSupportedForTarget<'a> {
200    pub(crate) stack_protector: StackProtector,
201    pub(crate) target_triple: &'a TargetTuple,
202}
203
204#[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,
                                crate::fluent_generated::session_target_small_data_threshold_not_supported);
                        ;
                        diag.arg("target_triple", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
205#[diag(session_target_small_data_threshold_not_supported)]
206pub(crate) struct SmallDataThresholdNotSupportedForTarget<'a> {
207    pub(crate) target_triple: &'a TargetTuple,
208}
209
210#[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,
                                crate::fluent_generated::session_branch_protection_requires_aarch64);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
211#[diag(session_branch_protection_requires_aarch64)]
212pub(crate) struct BranchProtectionRequiresAArch64;
213
214#[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,
                                crate::fluent_generated::session_split_debuginfo_unstable_platform);
                        ;
                        diag.arg("debuginfo", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
215#[diag(session_split_debuginfo_unstable_platform)]
216pub(crate) struct SplitDebugInfoUnstablePlatform {
217    pub(crate) debuginfo: SplitDebuginfo,
218}
219
220#[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,
                                crate::fluent_generated::session_file_is_not_writeable);
                        ;
                        diag.arg("file", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
221#[diag(session_file_is_not_writeable)]
222pub(crate) struct FileIsNotWriteable<'a> {
223    pub(crate) file: &'a std::path::Path,
224}
225
226#[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,
                                crate::fluent_generated::session_file_write_fail);
                        ;
                        diag.arg("path", __binding_0);
                        diag.arg("err", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
227#[diag(session_file_write_fail)]
228pub(crate) struct FileWriteFail<'a> {
229    pub(crate) path: &'a std::path::Path,
230    pub(crate) err: String,
231}
232
233#[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,
                                crate::fluent_generated::session_crate_name_empty);
                        ;
                        if let Some(__binding_0) = __binding_0 {
                            diag.span(__binding_0);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
234#[diag(session_crate_name_empty)]
235pub(crate) struct CrateNameEmpty {
236    #[primary_span]
237    pub(crate) span: Option<Span>,
238}
239
240#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InvalidCharacterInCrateName where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    InvalidCharacterInCrateName {
                        span: __binding_0,
                        character: __binding_1,
                        crate_name: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                crate::fluent_generated::session_invalid_character_in_crate_name);
                        ;
                        diag.arg("character", __binding_1);
                        diag.arg("crate_name", __binding_2);
                        if let Some(__binding_0) = __binding_0 {
                            diag.span(__binding_0);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
241#[diag(session_invalid_character_in_crate_name)]
242pub(crate) struct InvalidCharacterInCrateName {
243    #[primary_span]
244    pub(crate) span: Option<Span>,
245    pub(crate) character: char,
246    pub(crate) crate_name: Symbol,
247}
248
249#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for ExprParenthesesNeeded {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ExprParenthesesNeeded {
                        left: __binding_0, right: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_1 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("("))
                                });
                        let __code_2 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        suggestions.push((__binding_0, __code_1));
                        suggestions.push((__binding_1, __code_2));
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::session_expr_parentheses_needed);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag.restore_args();
                    }
                }
            }
        }
    };Subdiagnostic)]
250#[multipart_suggestion(session_expr_parentheses_needed, applicability = "machine-applicable")]
251pub struct ExprParenthesesNeeded {
252    #[suggestion_part(code = "(")]
253    left: Span,
254    #[suggestion_part(code = ")")]
255    right: Span,
256}
257
258impl ExprParenthesesNeeded {
259    pub fn surrounding(s: Span) -> Self {
260        ExprParenthesesNeeded { left: s.shrink_to_lo(), right: s.shrink_to_hi() }
261    }
262}
263
264#[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,
                                crate::fluent_generated::session_skipping_const_checks);
                        ;
                        for __binding_0 in __binding_0 {
                            diag.subdiagnostic(__binding_0);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
265#[diag(session_skipping_const_checks)]
266pub(crate) struct SkippingConstChecks {
267    #[subdiagnostic]
268    pub(crate) unleashed_features: Vec<UnleashedFeatureHelp>,
269}
270
271#[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 } => {
                        diag.store_args();
                        diag.arg("gate", __binding_1);
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::session_unleashed_feature_help_named);
                        diag.span_help(__binding_0, __message);
                        diag.restore_args();
                    }
                    UnleashedFeatureHelp::Unnamed { span: __binding_0 } => {
                        diag.store_args();
                        let __message =
                            diag.eagerly_translate(crate::fluent_generated::session_unleashed_feature_help_unnamed);
                        diag.span_help(__binding_0, __message);
                        diag.restore_args();
                    }
                }
            }
        }
    };Subdiagnostic)]
272pub(crate) enum UnleashedFeatureHelp {
273    #[help(session_unleashed_feature_help_named)]
274    Named {
275        #[primary_span]
276        span: Span,
277        gate: Symbol,
278    },
279    #[help(session_unleashed_feature_help_unnamed)]
280    Unnamed {
281        #[primary_span]
282        span: Span,
283    },
284}
285
286#[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,
                                crate::fluent_generated::session_invalid_literal_suffix);
                        ;
                        diag.arg("kind", __binding_1);
                        diag.arg("suffix", __binding_2);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            crate::fluent_generated::_subdiag::label);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
287#[diag(session_invalid_literal_suffix)]
288struct InvalidLiteralSuffix<'a> {
289    #[primary_span]
290    #[label]
291    span: Span,
292    // FIXME(#100717)
293    kind: &'a str,
294    suffix: Symbol,
295}
296
297#[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,
                                crate::fluent_generated::session_invalid_int_literal_width);
                        diag.help(crate::fluent_generated::_subdiag::help);
                        ;
                        diag.arg("width", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
298#[diag(session_invalid_int_literal_width)]
299#[help]
300struct InvalidIntLiteralWidth {
301    #[primary_span]
302    span: Span,
303    width: String,
304}
305
306#[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,
                                crate::fluent_generated::session_invalid_num_literal_base_prefix);
                        let __code_3 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_1))
                                            })].into_iter();
                        diag.note(crate::fluent_generated::_subdiag::note);
                        ;
                        diag.arg("fixed", __binding_1);
                        diag.span(__binding_0);
                        diag.span_suggestions_with_style(__binding_0,
                            crate::fluent_generated::_subdiag::suggestion, __code_3,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
307#[diag(session_invalid_num_literal_base_prefix)]
308#[note]
309struct InvalidNumLiteralBasePrefix {
310    #[primary_span]
311    #[suggestion(applicability = "maybe-incorrect", code = "{fixed}")]
312    span: Span,
313    fixed: String,
314}
315
316#[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,
                                crate::fluent_generated::session_invalid_num_literal_suffix);
                        diag.help(crate::fluent_generated::_subdiag::help);
                        ;
                        diag.arg("suffix", __binding_1);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            crate::fluent_generated::_subdiag::label);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
317#[diag(session_invalid_num_literal_suffix)]
318#[help]
319struct InvalidNumLiteralSuffix {
320    #[primary_span]
321    #[label]
322    span: Span,
323    suffix: String,
324}
325
326#[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,
                                crate::fluent_generated::session_invalid_float_literal_width);
                        diag.help(crate::fluent_generated::_subdiag::help);
                        ;
                        diag.arg("width", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
327#[diag(session_invalid_float_literal_width)]
328#[help]
329struct InvalidFloatLiteralWidth {
330    #[primary_span]
331    span: Span,
332    width: String,
333}
334
335#[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,
                                crate::fluent_generated::session_invalid_float_literal_suffix);
                        diag.help(crate::fluent_generated::_subdiag::help);
                        ;
                        diag.arg("suffix", __binding_1);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            crate::fluent_generated::_subdiag::label);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
336#[diag(session_invalid_float_literal_suffix)]
337#[help]
338struct InvalidFloatLiteralSuffix {
339    #[primary_span]
340    #[label]
341    span: Span,
342    suffix: String,
343}
344
345#[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,
                                crate::fluent_generated::session_int_literal_too_large);
                        diag.note(crate::fluent_generated::_subdiag::note);
                        ;
                        diag.arg("limit", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
346#[diag(session_int_literal_too_large)]
347#[note]
348struct IntLiteralTooLarge {
349    #[primary_span]
350    span: Span,
351    limit: String,
352}
353
354#[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,
                                crate::fluent_generated::session_hexadecimal_float_literal_not_supported);
                        ;
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            crate::fluent_generated::session_not_supported);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
355#[diag(session_hexadecimal_float_literal_not_supported)]
356struct HexadecimalFloatLiteralNotSupported {
357    #[primary_span]
358    #[label(session_not_supported)]
359    span: Span,
360}
361
362#[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,
                                crate::fluent_generated::session_octal_float_literal_not_supported);
                        ;
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            crate::fluent_generated::session_not_supported);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
363#[diag(session_octal_float_literal_not_supported)]
364struct OctalFloatLiteralNotSupported {
365    #[primary_span]
366    #[label(session_not_supported)]
367    span: Span,
368}
369
370#[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,
                                crate::fluent_generated::session_binary_float_literal_not_supported);
                        ;
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            crate::fluent_generated::session_not_supported);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
371#[diag(session_binary_float_literal_not_supported)]
372struct BinaryFloatLiteralNotSupported {
373    #[primary_span]
374    #[label(session_not_supported)]
375    span: Span,
376}
377
378pub fn report_lit_error(
379    psess: &ParseSess,
380    err: LitError,
381    lit: token::Lit,
382    span: Span,
383) -> ErrorGuaranteed {
384    create_lit_error(psess, err, lit, span).emit()
385}
386
387pub fn create_lit_error(psess: &ParseSess, err: LitError, lit: token::Lit, span: Span) -> Diag<'_> {
388    // Checks if `s` looks like i32 or u1234 etc.
389    fn looks_like_width_suffix(first_chars: &[char], s: &str) -> bool {
390        s.len() > 1 && s.starts_with(first_chars) && s[1..].chars().all(|c| c.is_ascii_digit())
391    }
392
393    // Try to lowercase the prefix if the prefix and suffix are valid.
394    fn fix_base_capitalisation(prefix: &str, suffix: &str) -> Option<String> {
395        let mut chars = suffix.chars();
396
397        let base_char = chars.next().unwrap();
398        let base = match base_char {
399            'B' => 2,
400            'O' => 8,
401            'X' => 16,
402            _ => return None,
403        };
404
405        // check that the suffix contains only base-appropriate characters
406        let valid = prefix == "0"
407            && chars
408                .filter(|c| *c != '_')
409                .take_while(|c| *c != 'i' && *c != 'u')
410                .all(|c| c.to_digit(base).is_some());
411
412        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..]))
413    }
414
415    let dcx = psess.dcx();
416    match err {
417        LitError::InvalidSuffix(suffix) => {
418            dcx.create_err(InvalidLiteralSuffix { span, kind: lit.kind.descr(), suffix })
419        }
420        LitError::InvalidIntSuffix(suffix) => {
421            let suf = suffix.as_str();
422            if looks_like_width_suffix(&['i', 'u'], suf) {
423                // If it looks like a width, try to be helpful.
424                dcx.create_err(InvalidIntLiteralWidth { span, width: suf[1..].into() })
425            } else if let Some(fixed) = fix_base_capitalisation(lit.symbol.as_str(), suf) {
426                dcx.create_err(InvalidNumLiteralBasePrefix { span, fixed })
427            } else {
428                dcx.create_err(InvalidNumLiteralSuffix { span, suffix: suf.to_string() })
429            }
430        }
431        LitError::InvalidFloatSuffix(suffix) => {
432            let suf = suffix.as_str();
433            if looks_like_width_suffix(&['f'], suf) {
434                // If it looks like a width, try to be helpful.
435                dcx.create_err(InvalidFloatLiteralWidth { span, width: suf[1..].to_string() })
436            } else {
437                dcx.create_err(InvalidFloatLiteralSuffix { span, suffix: suf.to_string() })
438            }
439        }
440        LitError::NonDecimalFloat(base) => match base {
441            16 => dcx.create_err(HexadecimalFloatLiteralNotSupported { span }),
442            8 => dcx.create_err(OctalFloatLiteralNotSupported { span }),
443            2 => dcx.create_err(BinaryFloatLiteralNotSupported { span }),
444            _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
445        },
446        LitError::IntTooLarge(base) => {
447            let max = u128::MAX;
448            let limit = match base {
449                2 => ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0:#b}", max))
    })format!("{max:#b}"),
450                8 => ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0:#o}", max))
    })format!("{max:#o}"),
451                16 => ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0:#x}", max))
    })format!("{max:#x}"),
452                _ => ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0}", max))
    })format!("{max}"),
453            };
454            dcx.create_err(IntLiteralTooLarge { span, limit })
455        }
456    }
457}
458
459#[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,
                                crate::fluent_generated::session_incompatible_linker_flavor);
                        diag.note(crate::fluent_generated::_subdiag::note);
                        ;
                        diag.arg("flavor", __binding_0);
                        diag.arg("compatible_list", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
460#[diag(session_incompatible_linker_flavor)]
461#[note]
462pub(crate) struct IncompatibleLinkerFlavor {
463    pub(crate) flavor: &'static str,
464    pub(crate) compatible_list: String,
465}
466
467#[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,
                                crate::fluent_generated::session_function_return_requires_x86_or_x86_64);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
468#[diag(session_function_return_requires_x86_or_x86_64)]
469pub(crate) struct FunctionReturnRequiresX86OrX8664;
470
471#[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,
                                crate::fluent_generated::session_function_return_thunk_extern_requires_non_large_code_model);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
472#[diag(session_function_return_thunk_extern_requires_non_large_code_model)]
473pub(crate) struct FunctionReturnThunkExternRequiresNonLargeCodeModel;
474
475#[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,
                                crate::fluent_generated::session_indirect_branch_cs_prefix_requires_x86_or_x86_64);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
476#[diag(session_indirect_branch_cs_prefix_requires_x86_or_x86_64)]
477pub(crate) struct IndirectBranchCsPrefixRequiresX86OrX8664;
478
479#[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,
                                crate::fluent_generated::session_unsupported_regparm);
                        ;
                        diag.arg("regparm", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
480#[diag(session_unsupported_regparm)]
481pub(crate) struct UnsupportedRegparm {
482    pub(crate) regparm: u32,
483}
484
485#[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,
                                crate::fluent_generated::session_unsupported_regparm_arch);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
486#[diag(session_unsupported_regparm_arch)]
487pub(crate) struct UnsupportedRegparmArch;
488
489#[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,
                                crate::fluent_generated::session_unsupported_reg_struct_return_arch);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
490#[diag(session_unsupported_reg_struct_return_arch)]
491pub(crate) struct UnsupportedRegStructReturnArch;
492
493#[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,
                                crate::fluent_generated::session_failed_to_create_profiler);
                        ;
                        diag.arg("err", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
494#[diag(session_failed_to_create_profiler)]
495pub(crate) struct FailedToCreateProfiler {
496    pub(crate) err: String,
497}
498
499#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SoftFloatIgnored where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SoftFloatIgnored => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                crate::fluent_generated::session_soft_float_ignored);
                        diag.note(crate::fluent_generated::_subdiag::note);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
500#[diag(session_soft_float_ignored)]
501#[note]
502pub(crate) struct SoftFloatIgnored;
503
504#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SoftFloatDeprecated where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    SoftFloatDeprecated => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                crate::fluent_generated::session_soft_float_deprecated);
                        diag.note(crate::fluent_generated::_subdiag::note);
                        diag.note(crate::fluent_generated::session_soft_float_deprecated_issue);
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
505#[diag(session_soft_float_deprecated)]
506#[note]
507#[note(session_soft_float_deprecated_issue)]
508pub(crate) struct SoftFloatDeprecated;
509
510#[derive(const _: () =
    {
        impl<'__a> rustc_errors::LintDiagnostic<'__a, ()> for
            UnexpectedBuiltinCfg {
            #[track_caller]
            fn decorate_lint<'__b>(self,
                diag: &'__b mut rustc_errors::Diag<'__a, ()>) {
                match self {
                    UnexpectedBuiltinCfg {
                        cfg: __binding_0,
                        cfg_name: __binding_1,
                        controlled_by: __binding_2 } => {
                        diag.primary_message(crate::fluent_generated::session_unexpected_builtin_cfg);
                        diag.note(crate::fluent_generated::session_controlled_by);
                        diag.note(crate::fluent_generated::session_incoherent);
                        ;
                        diag.arg("cfg", __binding_0);
                        diag.arg("cfg_name", __binding_1);
                        diag.arg("controlled_by", __binding_2);
                        diag
                    }
                };
            }
        }
    };LintDiagnostic)]
511#[diag(session_unexpected_builtin_cfg)]
512#[note(session_controlled_by)]
513#[note(session_incoherent)]
514pub(crate) struct UnexpectedBuiltinCfg {
515    pub(crate) cfg: String,
516    pub(crate) cfg_name: Symbol,
517    pub(crate) controlled_by: &'static str,
518}