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