Skip to main content

rustc_codegen_llvm/
errors.rs

1use std::ffi::CString;
2use std::path::Path;
3
4use rustc_data_structures::small_c_str::SmallCStr;
5use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, inline_fluent};
6use rustc_macros::Diagnostic;
7use rustc_span::Span;
8
9#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            SymbolAlreadyDefined<'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 {
                    SymbolAlreadyDefined {
                        span: __binding_0, symbol_name: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("symbol `{$symbol_name}` is already defined")));
                        ;
                        diag.arg("symbol_name", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
10#[diag("symbol `{$symbol_name}` is already defined")]
11pub(crate) struct SymbolAlreadyDefined<'a> {
12    #[primary_span]
13    pub span: Span,
14    pub symbol_name: &'a str,
15}
16
17#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SanitizerMemtagRequiresMte 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 {
                    SanitizerMemtagRequiresMte => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsanitizer=memtag` requires `-Ctarget-feature=+mte`")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
18#[diag("`-Zsanitizer=memtag` requires `-Ctarget-feature=+mte`")]
19pub(crate) struct SanitizerMemtagRequiresMte;
20
21pub(crate) struct ParseTargetMachineConfig<'a>(pub LlvmError<'a>);
22
23impl<G: EmissionGuarantee> Diagnostic<'_, G> for ParseTargetMachineConfig<'_> {
24    fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
25        let diag: Diag<'_, G> = self.0.into_diag(dcx, level);
26        let (message, _) = diag.messages.first().expect("`LlvmError` with no message");
27        let message = dcx.eagerly_translate_to_string(message.clone(), diag.args.iter());
28        Diag::new(
29            dcx,
30            level,
31            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to parse target machine config to target machine: {$error}"))inline_fluent!("failed to parse target machine config to target machine: {$error}"),
32        )
33        .with_arg("error", message)
34    }
35}
36
37#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            AutoDiffComponentUnavailable 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 {
                    AutoDiffComponentUnavailable { err: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to load our autodiff backend: {$err}")));
                        ;
                        diag.arg("err", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
38#[diag("failed to load our autodiff backend: {$err}")]
39pub(crate) struct AutoDiffComponentUnavailable {
40    pub err: String,
41}
42
43#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            AutoDiffComponentMissing 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 {
                    AutoDiffComponentMissing { err: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("autodiff backend not found in the sysroot: {$err}")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("it will be distributed via rustup in the future")));
                        ;
                        diag.arg("err", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
44#[diag("autodiff backend not found in the sysroot: {$err}")]
45#[note("it will be distributed via rustup in the future")]
46pub(crate) struct AutoDiffComponentMissing {
47    pub err: String,
48}
49
50#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            AutoDiffWithoutLto 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 {
                    AutoDiffWithoutLto => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using the autodiff feature requires setting `lto=\"fat\"` in your Cargo.toml")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
51#[diag("using the autodiff feature requires setting `lto=\"fat\"` in your Cargo.toml")]
52pub(crate) struct AutoDiffWithoutLto;
53
54#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            AutoDiffWithoutEnable 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 {
                    AutoDiffWithoutEnable => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using the autodiff feature requires -Z autodiff=Enable")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
55#[diag("using the autodiff feature requires -Z autodiff=Enable")]
56pub(crate) struct AutoDiffWithoutEnable;
57
58#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            OffloadWithoutEnable 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 {
                    OffloadWithoutEnable => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using the offload feature requires -Z offload=<Device or Host=/absolute/path/to/host.out>")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
59#[diag("using the offload feature requires -Z offload=<Device or Host=/absolute/path/to/host.out>")]
60pub(crate) struct OffloadWithoutEnable;
61
62#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            OffloadWithoutFatLTO 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 {
                    OffloadWithoutFatLTO => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using the offload feature requires -C lto=fat")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
63#[diag("using the offload feature requires -C lto=fat")]
64pub(crate) struct OffloadWithoutFatLTO;
65
66#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            OffloadWithoutAbsPath 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 {
                    OffloadWithoutAbsPath => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using the `-Z offload=Host=/absolute/path/to/host.out` flag requires an absolute path")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
67#[diag("using the `-Z offload=Host=/absolute/path/to/host.out` flag requires an absolute path")]
68pub(crate) struct OffloadWithoutAbsPath;
69
70#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            OffloadWrongFileName 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 {
                    OffloadWrongFileName => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("using the `-Z offload=Host=/absolute/path/to/host.out` flag must point to a `host.out` file")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
71#[diag(
72    "using the `-Z offload=Host=/absolute/path/to/host.out` flag must point to a `host.out` file"
73)]
74pub(crate) struct OffloadWrongFileName;
75
76#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            OffloadNonexistingPath 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 {
                    OffloadNonexistingPath => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the given path/file to `host.out` does not exist. Did you forget to run the device compilation first?")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
77#[diag(
78    "the given path/file to `host.out` does not exist. Did you forget to run the device compilation first?"
79)]
80pub(crate) struct OffloadNonexistingPath;
81
82#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            OffloadBundleImagesFailed 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 {
                    OffloadBundleImagesFailed => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to BundleImages failed, `host.out` was not created")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
83#[diag("call to BundleImages failed, `host.out` was not created")]
84pub(crate) struct OffloadBundleImagesFailed;
85
86#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            OffloadEmbedFailed 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 {
                    OffloadEmbedFailed => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("call to EmbedBufferInModule failed, `host.o` was not created")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
87#[diag("call to EmbedBufferInModule failed, `host.o` was not created")]
88pub(crate) struct OffloadEmbedFailed;
89
90#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            LtoBitcodeFromRlib 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 {
                    LtoBitcodeFromRlib { err: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to get bitcode from object file for LTO ({$err})")));
                        ;
                        diag.arg("err", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
91#[diag("failed to get bitcode from object file for LTO ({$err})")]
92pub(crate) struct LtoBitcodeFromRlib {
93    pub err: String,
94}
95
96#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            LlvmError<'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 {
                    LlvmError::WriteOutput { path: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("could not write output to {$path}")));
                        ;
                        diag.arg("path", __binding_0);
                        diag
                    }
                    LlvmError::CreateTargetMachine { triple: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("could not create LLVM TargetMachine for triple: {$triple}")));
                        ;
                        diag.arg("triple", __binding_0);
                        diag
                    }
                    LlvmError::RunLlvmPasses => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to run LLVM passes")));
                        ;
                        diag
                    }
                    LlvmError::SerializeModule { name: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to serialize module {$name}")));
                        ;
                        diag.arg("name", __binding_0);
                        diag
                    }
                    LlvmError::WriteIr { path: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to write LLVM IR to {$path}")));
                        ;
                        diag.arg("path", __binding_0);
                        diag
                    }
                    LlvmError::PrepareThinLtoContext => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to prepare thin LTO context")));
                        ;
                        diag
                    }
                    LlvmError::LoadBitcode { name: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to load bitcode of module \"{$name}\"")));
                        ;
                        diag.arg("name", __binding_0);
                        diag
                    }
                    LlvmError::WriteThinLtoKey { err: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("error while writing ThinLTO key data: {$err}")));
                        ;
                        diag.arg("err", __binding_0);
                        diag
                    }
                    LlvmError::PrepareThinLtoModule => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to prepare thin LTO module")));
                        ;
                        diag
                    }
                    LlvmError::ParseBitcode => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to parse bitcode for LTO module")));
                        ;
                        diag
                    }
                    LlvmError::PrepareAutoDiff {
                        src: __binding_0, target: __binding_1, error: __binding_2 }
                        => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to prepare autodiff: src: {$src}, target: {$target}, {$error}")));
                        ;
                        diag.arg("src", __binding_0);
                        diag.arg("target", __binding_1);
                        diag.arg("error", __binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
97pub enum LlvmError<'a> {
98    #[diag("could not write output to {$path}")]
99    WriteOutput { path: &'a Path },
100    #[diag("could not create LLVM TargetMachine for triple: {$triple}")]
101    CreateTargetMachine { triple: SmallCStr },
102    #[diag("failed to run LLVM passes")]
103    RunLlvmPasses,
104    #[diag("failed to serialize module {$name}")]
105    SerializeModule { name: &'a str },
106    #[diag("failed to write LLVM IR to {$path}")]
107    WriteIr { path: &'a Path },
108    #[diag("failed to prepare thin LTO context")]
109    PrepareThinLtoContext,
110    #[diag("failed to load bitcode of module \"{$name}\"")]
111    LoadBitcode { name: CString },
112    #[diag("error while writing ThinLTO key data: {$err}")]
113    WriteThinLtoKey { err: std::io::Error },
114    #[diag("failed to prepare thin LTO module")]
115    PrepareThinLtoModule,
116    #[diag("failed to parse bitcode for LTO module")]
117    ParseBitcode,
118    #[diag("failed to prepare autodiff: src: {$src}, target: {$target}, {$error}")]
119    PrepareAutoDiff { src: String, target: String, error: String },
120}
121
122pub(crate) struct WithLlvmError<'a>(pub LlvmError<'a>, pub String);
123
124impl<G: EmissionGuarantee> Diagnostic<'_, G> for WithLlvmError<'_> {
125    fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
126        use LlvmError::*;
127        let msg_with_llvm_err = match &self.0 {
128            WriteOutput { .. } => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("could not write output to {$path}: {$llvm_err}"))inline_fluent!("could not write output to {$path}: {$llvm_err}"),
129            CreateTargetMachine { .. } => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("could not create LLVM TargetMachine for triple: {$triple}: {$llvm_err}"))inline_fluent!(
130                "could not create LLVM TargetMachine for triple: {$triple}: {$llvm_err}"
131            ),
132            RunLlvmPasses => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to run LLVM passes: {$llvm_err}"))inline_fluent!("failed to run LLVM passes: {$llvm_err}"),
133            SerializeModule { .. } => {
134                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to serialize module {$name}: {$llvm_err}"))inline_fluent!("failed to serialize module {$name}: {$llvm_err}")
135            }
136            WriteIr { .. } => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to write LLVM IR to {$path}: {$llvm_err}"))inline_fluent!("failed to write LLVM IR to {$path}: {$llvm_err}"),
137            PrepareThinLtoContext => {
138                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to prepare thin LTO context: {$llvm_err}"))inline_fluent!("failed to prepare thin LTO context: {$llvm_err}")
139            }
140            LoadBitcode { .. } => {
141                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to load bitcode of module \"{$name}\": {$llvm_err}"))inline_fluent!("failed to load bitcode of module \"{$name}\": {$llvm_err}")
142            }
143            WriteThinLtoKey { .. } => {
144                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("error while writing ThinLTO key data: {$err}: {$llvm_err}"))inline_fluent!("error while writing ThinLTO key data: {$err}: {$llvm_err}")
145            }
146            PrepareThinLtoModule => {
147                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to prepare thin LTO module: {$llvm_err}"))inline_fluent!("failed to prepare thin LTO module: {$llvm_err}")
148            }
149            ParseBitcode => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to parse bitcode for LTO module: {$llvm_err}"))inline_fluent!("failed to parse bitcode for LTO module: {$llvm_err}"),
150            PrepareAutoDiff { .. } => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to prepare autodiff: {$llvm_err}, src: {$src}, target: {$target}, {$error}"))inline_fluent!(
151                "failed to prepare autodiff: {$llvm_err}, src: {$src}, target: {$target}, {$error}"
152            ),
153        };
154        self.0
155            .into_diag(dcx, level)
156            .with_primary_message(msg_with_llvm_err)
157            .with_arg("llvm_err", self.1)
158    }
159}
160
161#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            FromLlvmOptimizationDiag<'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 {
                    FromLlvmOptimizationDiag {
                        filename: __binding_0,
                        line: __binding_1,
                        column: __binding_2,
                        pass_name: __binding_3,
                        kind: __binding_4,
                        message: __binding_5 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$filename}:{$line}:{$column} {$pass_name} ({$kind}): {$message}")));
                        ;
                        diag.arg("filename", __binding_0);
                        diag.arg("line", __binding_1);
                        diag.arg("column", __binding_2);
                        diag.arg("pass_name", __binding_3);
                        diag.arg("kind", __binding_4);
                        diag.arg("message", __binding_5);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
162#[diag("{$filename}:{$line}:{$column} {$pass_name} ({$kind}): {$message}")]
163pub(crate) struct FromLlvmOptimizationDiag<'a> {
164    pub filename: &'a str,
165    pub line: std::ffi::c_uint,
166    pub column: std::ffi::c_uint,
167    pub pass_name: &'a str,
168    pub kind: &'a str,
169    pub message: &'a str,
170}
171
172#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for FromLlvmDiag
            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 {
                    FromLlvmDiag { message: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$message}")));
                        ;
                        diag.arg("message", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
173#[diag("{$message}")]
174pub(crate) struct FromLlvmDiag {
175    pub message: String,
176}
177
178#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            WriteBytecode<'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 {
                    WriteBytecode { 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 bytecode to {$path}: {$err}")));
                        ;
                        diag.arg("path", __binding_0);
                        diag.arg("err", __binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
179#[diag("failed to write bytecode to {$path}: {$err}")]
180pub(crate) struct WriteBytecode<'a> {
181    pub path: &'a Path,
182    pub err: std::io::Error,
183}
184
185#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for CopyBitcode
            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 {
                    CopyBitcode { err: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to copy bitcode to object file: {$err}")));
                        ;
                        diag.arg("err", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
186#[diag("failed to copy bitcode to object file: {$err}")]
187pub(crate) struct CopyBitcode {
188    pub err: std::io::Error,
189}
190
191#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            UnknownCompression 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 {
                    UnknownCompression { algorithm: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown debuginfo compression algorithm {$algorithm} - will fall back to uncompressed debuginfo")));
                        ;
                        diag.arg("algorithm", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
192#[diag(
193    "unknown debuginfo compression algorithm {$algorithm} - will fall back to uncompressed debuginfo"
194)]
195pub(crate) struct UnknownCompression {
196    pub algorithm: &'static str,
197}
198
199#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            MismatchedDataLayout<'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 {
                    MismatchedDataLayout {
                        rustc_target: __binding_0,
                        rustc_layout: __binding_1,
                        llvm_target: __binding_2,
                        llvm_layout: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("data-layout for target `{$rustc_target}`, `{$rustc_layout}`, differs from LLVM target's `{$llvm_target}` default layout, `{$llvm_layout}`")));
                        ;
                        diag.arg("rustc_target", __binding_0);
                        diag.arg("rustc_layout", __binding_1);
                        diag.arg("llvm_target", __binding_2);
                        diag.arg("llvm_layout", __binding_3);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
200#[diag(
201    "data-layout for target `{$rustc_target}`, `{$rustc_layout}`, differs from LLVM target's `{$llvm_target}` default layout, `{$llvm_layout}`"
202)]
203pub(crate) struct MismatchedDataLayout<'a> {
204    pub rustc_target: &'a str,
205    pub rustc_layout: &'a str,
206    pub llvm_target: &'a str,
207    pub llvm_layout: &'a str,
208}
209
210#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            FixedX18InvalidArch<'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 {
                    FixedX18InvalidArch { arch: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the `-Zfixed-x18` flag is not supported on the `{$arch}` architecture")));
                        ;
                        diag.arg("arch", __binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
211#[diag("the `-Zfixed-x18` flag is not supported on the `{$arch}` architecture")]
212pub(crate) struct FixedX18InvalidArch<'a> {
213    pub arch: &'a str,
214}
215
216#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            SanitizerKcfiArityRequiresLLVM2100 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 {
                    SanitizerKcfiArityRequiresLLVM2100 => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
217#[diag("`-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later")]
218pub(crate) struct SanitizerKcfiArityRequiresLLVM2100;