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        // Reuse the formatted primary message from `LlvmError` without emitting it.
28        let diag: Diag<'_, ()> = self.0.into_diag(dcx, level);
29        let (message, _) = diag.messages.first().expect("`LlvmError` with no message");
30        let message = format_diag_message(message, &diag.args).into_owned();
31        diag.cancel();
32
33        Diag::new(
34            dcx,
35            level,
36            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}"),
37        )
38        .with_arg("error", message)
39    }
40}
41
42#[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)]
43#[diag("failed to load our autodiff backend: {$err}")]
44pub(crate) struct AutoDiffComponentUnavailable {
45    pub err: String,
46}
47
48#[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)]
49#[diag("autodiff backend not found in the sysroot: {$err}")]
50#[note("it will be distributed via rustup in the future")]
51pub(crate) struct AutoDiffComponentMissing {
52    pub err: String,
53}
54
55#[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)]
56#[diag("using the autodiff feature requires setting `lto=\"fat\"` in your Cargo.toml")]
57pub(crate) struct AutoDiffWithoutLto;
58
59#[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)]
60#[diag("using the autodiff feature requires -Z autodiff=Enable")]
61pub(crate) struct AutoDiffWithoutEnable;
62
63#[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/device.bin>")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
64#[diag(
65    "using the offload feature requires -Z offload=<Device or Host=/absolute/path/to/device.bin>"
66)]
67pub(crate) struct OffloadWithoutEnable;
68
69#[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)]
70#[diag("using the offload feature requires -C lto=fat")]
71pub(crate) struct OffloadWithoutFatLTO;
72
73#[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/device.bin` flag requires an absolute path")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
74#[diag("using the `-Z offload=Host=/absolute/path/to/device.bin` flag requires an absolute path")]
75pub(crate) struct OffloadWithoutAbsPath;
76
77#[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/device.bin` flag must point to a `device.bin` file")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
78#[diag(
79    "using the `-Z offload=Host=/absolute/path/to/device.bin` flag must point to a `device.bin` file"
80)]
81pub(crate) struct OffloadWrongFileName;
82
83#[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 `device.bin` does not exist. Did you forget to run the device compilation first?")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
84#[diag(
85    "the given path/file to `device.bin` does not exist. Did you forget to run the device compilation first?"
86)]
87pub(crate) struct OffloadNonexistingPath;
88
89#[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, `device.bin` was not created")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
90#[diag("call to BundleImages failed, `device.bin` was not created")]
91pub(crate) struct OffloadBundleImagesFailed;
92
93#[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)]
94#[diag("call to EmbedBufferInModule failed, `host.o` was not created")]
95pub(crate) struct OffloadEmbedFailed;
96
97#[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)]
98#[diag("failed to get bitcode from object file for LTO ({$err})")]
99pub(crate) struct LtoBitcodeFromRlib {
100    pub err: String,
101}
102
103#[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)]
104pub(crate) enum LlvmError<'a> {
105    #[diag("could not write output to {$path}")]
106    WriteOutput { path: &'a Path },
107    #[diag("could not create LLVM TargetMachine for triple: {$triple}")]
108    CreateTargetMachine { triple: SmallCStr },
109    #[diag("failed to run LLVM passes")]
110    RunLlvmPasses,
111    #[diag("failed to write LLVM IR to {$path}")]
112    WriteIr { path: &'a Path },
113    #[diag("failed to prepare thin LTO context")]
114    PrepareThinLtoContext,
115    #[diag("failed to load bitcode of module \"{$name}\"")]
116    LoadBitcode { name: CString },
117    #[diag("error while writing ThinLTO key data: {$err}")]
118    WriteThinLtoKey { err: std::io::Error },
119    #[diag("failed to prepare thin LTO module")]
120    PrepareThinLtoModule,
121    #[diag("failed to parse bitcode for LTO module")]
122    ParseBitcode,
123}
124
125pub(crate) struct WithLlvmError<'a>(pub LlvmError<'a>, pub String);
126
127impl<G: EmissionGuarantee> Diagnostic<'_, G> for WithLlvmError<'_> {
128    fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
129        use LlvmError::*;
130        let msg_with_llvm_err = match &self.0 {
131            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}"),
132            CreateTargetMachine { .. } => {
133                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}")
134            }
135            RunLlvmPasses => rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("failed to run LLVM passes: {$llvm_err}"))msg!("failed to run LLVM passes: {$llvm_err}"),
136            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}"),
137            PrepareThinLtoContext => {
138                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}")
139            }
140            LoadBitcode { .. } => {
141                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}")
142            }
143            WriteThinLtoKey { .. } => {
144                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}")
145            }
146            PrepareThinLtoModule => {
147                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}")
148            }
149            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}"),
150        };
151        self.0
152            .into_diag(dcx, level)
153            .with_primary_message(msg_with_llvm_err)
154            .with_arg("llvm_err", self.1)
155    }
156}
157
158#[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)]
159#[diag("{$filename}:{$line}:{$column} {$pass_name} ({$kind}): {$message}")]
160pub(crate) struct FromLlvmOptimizationDiag<'a> {
161    pub filename: &'a str,
162    pub line: std::ffi::c_uint,
163    pub column: std::ffi::c_uint,
164    pub pass_name: &'a str,
165    pub kind: &'a str,
166    pub message: &'a str,
167}
168
169#[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)]
170#[diag("{$message}")]
171pub(crate) struct FromLlvmDiag {
172    pub message: String,
173}
174
175#[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)]
176#[diag("failed to write bytecode to {$path}: {$err}")]
177pub(crate) struct WriteBytecode<'a> {
178    pub path: &'a Path,
179    pub err: std::io::Error,
180}
181
182#[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)]
183#[diag("failed to copy bitcode to object file: {$err}")]
184pub(crate) struct CopyBitcode {
185    pub err: std::io::Error,
186}
187
188#[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)]
189#[diag(
190    "unsupported debuginfo compression algorithm {$algorithm} - will fall back to uncompressed debuginfo"
191)]
192pub(crate) struct UnsupportedCompression {
193    pub algorithm: &'static str,
194}
195
196#[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)]
197#[diag(
198    "data-layout for target `{$rustc_target}`, `{$rustc_layout}`, differs from LLVM target's `{$llvm_target}` default layout, `{$llvm_layout}`"
199)]
200pub(crate) struct MismatchedDataLayout<'a> {
201    pub rustc_target: &'a str,
202    pub rustc_layout: &'a str,
203    pub llvm_target: &'a str,
204    pub llvm_layout: &'a str,
205}
206
207#[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)]
208#[diag("the `-Zfixed-x18` flag is not supported on the `{$arch}` architecture")]
209pub(crate) struct FixedX18InvalidArch<'a> {
210    pub arch: &'a str,
211}
212
213#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            PackedStackBackchainNeedsSoftfloat 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 {
                    PackedStackBackchainNeedsSoftfloat => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`-Zpacked-stack` is incompatible with `backchain` target feature")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("enabling both `-Zpacked-stack` and the `backchain` target feature is incompatible with the default s390x ABI. Switch to s390x-unknown-none-softfloat if you need both attributes")));
                        ;
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
214#[diag("`-Zpacked-stack` is incompatible with `backchain` target feature")]
215#[note(
216    "enabling both `-Zpacked-stack` and the `backchain` target feature is incompatible with the default s390x ABI. Switch to s390x-unknown-none-softfloat if you need both attributes"
217)]
218pub(crate) struct PackedStackBackchainNeedsSoftfloat;
219
220#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            IntrinsicSignatureMismatch<'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 {
                    IntrinsicSignatureMismatch {
                        name: __binding_0,
                        llvm_fn_ty: __binding_1,
                        rust_fn_ty: __binding_2,
                        span: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("intrinsic signature mismatch for `{$name}`: expected signature `{$llvm_fn_ty}`, found `{$rust_fn_ty}`")));
                        ;
                        diag.arg("name", __binding_0);
                        diag.arg("llvm_fn_ty", __binding_1);
                        diag.arg("rust_fn_ty", __binding_2);
                        diag.span(__binding_3);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
221#[diag(
222    "intrinsic signature mismatch for `{$name}`: expected signature `{$llvm_fn_ty}`, found `{$rust_fn_ty}`"
223)]
224pub(crate) struct IntrinsicSignatureMismatch<'a> {
225    pub name: &'a str,
226    pub llvm_fn_ty: &'a str,
227    pub rust_fn_ty: &'a str,
228    #[primary_span]
229    pub span: Span,
230}
231
232#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            UnknownIntrinsic<'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 {
                    UnknownIntrinsic { name: __binding_0, span: __binding_1 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unknown LLVM intrinsic `{$name}`")));
                        ;
                        diag.arg("name", __binding_0);
                        diag.span(__binding_1);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
233#[diag("unknown LLVM intrinsic `{$name}`")]
234pub(crate) struct UnknownIntrinsic<'a> {
235    pub name: &'a str,
236    #[primary_span]
237    pub span: Span,
238}
239
240#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            IntrinsicWrongArch<'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 {
                    IntrinsicWrongArch {
                        name: __binding_0,
                        target_arch: __binding_1,
                        span: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("intrinsic `{$name}` cannot be used with target arch `{$target_arch}`")));
                        ;
                        diag.arg("name", __binding_0);
                        diag.arg("target_arch", __binding_1);
                        diag.span(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
241#[diag("intrinsic `{$name}` cannot be used with target arch `{$target_arch}`")]
242pub(crate) struct IntrinsicWrongArch<'a> {
243    pub name: &'a str,
244    pub target_arch: &'a str,
245    #[primary_span]
246    pub span: Span,
247}