117 lines
3.1 KiB
Rust
Raw Normal View History

use std::borrow::Cow;
2022-08-25 15:42:20 +02:00
use rustc_errors::fluent;
use rustc_errors::DiagnosticBuilder;
use rustc_errors::ErrorGuaranteed;
2022-10-30 14:33:27 +01:00
use rustc_errors::Handler;
use rustc_errors::IntoDiagnostic;
use rustc_macros::{Diagnostic, Subdiagnostic};
2022-08-25 23:30:17 +02:00
use rustc_span::Span;
#[derive(Diagnostic)]
#[diag(codegen_llvm_unknown_ctarget_feature_prefix)]
#[note]
pub(crate) struct UnknownCTargetFeaturePrefix<'a> {
pub feature: &'a str,
}
#[derive(Diagnostic)]
#[diag(codegen_llvm_unknown_ctarget_feature)]
#[note]
pub(crate) struct UnknownCTargetFeature<'a> {
pub feature: &'a str,
#[subdiagnostic]
pub rust_feature: PossibleFeature<'a>,
}
#[derive(Subdiagnostic)]
pub(crate) enum PossibleFeature<'a> {
#[help(possible_feature)]
Some { rust_feature: &'a str },
#[help(consider_filing_feature_request)]
None,
2022-08-25 15:42:20 +02:00
}
2022-08-25 21:01:36 +02:00
2022-10-30 14:33:27 +01:00
#[derive(Diagnostic)]
#[diag(codegen_llvm_error_creating_import_library)]
2022-08-25 21:01:36 +02:00
pub(crate) struct ErrorCreatingImportLibrary<'a> {
pub lib_name: &'a str,
pub error: String,
}
2022-10-30 14:33:27 +01:00
#[derive(Diagnostic)]
#[diag(codegen_llvm_instrument_coverage_requires_llvm_12)]
pub(crate) struct InstrumentCoverageRequiresLLVM12;
2022-08-25 23:30:17 +02:00
2022-10-30 14:33:27 +01:00
#[derive(Diagnostic)]
#[diag(codegen_llvm_symbol_already_defined)]
2022-08-25 23:30:17 +02:00
pub(crate) struct SymbolAlreadyDefined<'a> {
#[primary_span]
pub span: Span,
pub symbol_name: &'a str,
}
2022-08-26 00:03:53 +02:00
2022-10-30 14:33:27 +01:00
#[derive(Diagnostic)]
#[diag(codegen_llvm_invalid_minimum_alignment)]
2022-08-26 10:30:43 +02:00
pub(crate) struct InvalidMinimumAlignment {
2022-08-26 10:40:48 +02:00
pub err: String,
}
2022-10-30 14:33:27 +01:00
#[derive(Diagnostic)]
#[diag(codegen_llvm_sanitizer_memtag_requires_mte)]
2022-08-26 12:19:10 +02:00
pub(crate) struct SanitizerMemtagRequiresMte;
2022-08-26 14:11:47 +02:00
2022-10-30 14:33:27 +01:00
#[derive(Diagnostic)]
#[diag(codegen_llvm_error_writing_def_file)]
2022-08-26 14:17:15 +02:00
pub(crate) struct ErrorWritingDEFFile {
pub error: std::io::Error,
}
2022-08-26 14:29:33 +02:00
2022-10-30 14:33:27 +01:00
#[derive(Diagnostic)]
#[diag(codegen_llvm_error_calling_dlltool)]
2022-08-26 14:29:33 +02:00
pub(crate) struct ErrorCallingDllTool {
pub error: std::io::Error,
}
2022-10-30 14:33:27 +01:00
#[derive(Diagnostic)]
#[diag(codegen_llvm_dlltool_fail_import_library)]
pub(crate) struct DlltoolFailImportLibrary<'a> {
pub stdout: Cow<'a, str>,
pub stderr: Cow<'a, str>,
}
2022-08-26 19:42:29 +02:00
2022-10-30 16:07:04 +01:00
#[derive(Diagnostic)]
#[diag(codegen_llvm_dynamic_linking_with_lto)]
#[note]
pub(crate) struct DynamicLinkingWithLTO;
#[derive(Diagnostic)]
#[diag(codegen_llvm_fail_parsing_target_machine_config_to_target_machine)]
pub(crate) struct FailParsingTargetMachineConfigToTargetMachine {
pub error: String,
}
pub(crate) struct TargetFeatureDisableOrEnable<'a> {
pub features: &'a [&'a str],
pub span: Option<Span>,
pub missing_features: Option<MissingFeatures>,
}
2022-10-30 14:33:27 +01:00
#[derive(Subdiagnostic)]
#[help(codegen_llvm_missing_features)]
pub(crate) struct MissingFeatures;
2022-10-30 14:33:27 +01:00
impl IntoDiagnostic<'_, ErrorGuaranteed> for TargetFeatureDisableOrEnable<'_> {
fn into_diagnostic(self, sess: &'_ Handler) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut diag = sess.struct_err(fluent::codegen_llvm_target_feature_disable_or_enable);
if let Some(span) = self.span {
diag.set_span(span);
};
if let Some(missing_features) = self.missing_features {
diag.subdiagnostic(missing_features);
}
diag.set_arg("features", self.features.join(", "));
diag
}
}