3 use rustc_errors::fluent;
4 use rustc_errors::DiagnosticBuilder;
5 use rustc_errors::ErrorGuaranteed;
6 use rustc_errors::Handler;
7 use rustc_errors::IntoDiagnostic;
8 use rustc_macros::{Diagnostic, Subdiagnostic};
12 #[diag(codegen_llvm_unknown_ctarget_feature_prefix)]
14 pub(crate) struct UnknownCTargetFeaturePrefix<'a> {
19 #[diag(codegen_llvm_unknown_ctarget_feature)]
21 pub(crate) struct UnknownCTargetFeature<'a> {
24 pub rust_feature: PossibleFeature<'a>,
27 #[derive(Subdiagnostic)]
28 pub(crate) enum PossibleFeature<'a> {
29 #[help(possible_feature)]
30 Some { rust_feature: &'a str },
31 #[help(consider_filing_feature_request)]
36 #[diag(codegen_llvm_error_creating_import_library)]
37 pub(crate) struct ErrorCreatingImportLibrary<'a> {
38 pub lib_name: &'a str,
43 #[diag(codegen_llvm_instrument_coverage_requires_llvm_12)]
44 pub(crate) struct InstrumentCoverageRequiresLLVM12;
47 #[diag(codegen_llvm_symbol_already_defined)]
48 pub(crate) struct SymbolAlreadyDefined<'a> {
51 pub symbol_name: &'a str,
55 #[diag(codegen_llvm_branch_protection_requires_aarch64)]
56 pub(crate) struct BranchProtectionRequiresAArch64;
59 #[diag(codegen_llvm_invalid_minimum_alignment)]
60 pub(crate) struct InvalidMinimumAlignment {
65 #[diag(codegen_llvm_sanitizer_memtag_requires_mte)]
66 pub(crate) struct SanitizerMemtagRequiresMte;
69 #[diag(codegen_llvm_error_writing_def_file)]
70 pub(crate) struct ErrorWritingDEFFile {
71 pub error: std::io::Error,
75 #[diag(codegen_llvm_error_calling_dlltool)]
76 pub(crate) struct ErrorCallingDllTool {
77 pub error: std::io::Error,
81 #[diag(codegen_llvm_dlltool_fail_import_library)]
82 pub(crate) struct DlltoolFailImportLibrary<'a> {
83 pub stdout: Cow<'a, str>,
84 pub stderr: Cow<'a, str>,
88 #[diag(codegen_llvm_dynamic_linking_with_lto)]
90 pub(crate) struct DynamicLinkingWithLTO;
93 #[diag(codegen_llvm_fail_parsing_target_machine_config_to_target_machine)]
94 pub(crate) struct FailParsingTargetMachineConfigToTargetMachine {
98 pub(crate) struct TargetFeatureDisableOrEnable<'a> {
99 pub features: &'a [&'a str],
100 pub span: Option<Span>,
101 pub missing_features: Option<MissingFeatures>,
104 #[derive(Subdiagnostic)]
105 #[help(codegen_llvm_missing_features)]
106 pub(crate) struct MissingFeatures;
108 impl IntoDiagnostic<'_, ErrorGuaranteed> for TargetFeatureDisableOrEnable<'_> {
109 fn into_diagnostic(self, sess: &'_ Handler) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
110 let mut diag = sess.struct_err(fluent::codegen_llvm_target_feature_disable_or_enable);
111 if let Some(span) = self.span {
114 if let Some(missing_features) = self.missing_features {
115 diag.subdiagnostic(missing_features);
117 diag.set_arg("features", self.features.join(", "));