2022-08-26 17:01:22 +00:00
|
|
|
use std::borrow::Cow;
|
|
|
|
|
2022-08-25 13:42:20 +00:00
|
|
|
use rustc_errors::fluent;
|
2022-08-25 13:34:30 +00:00
|
|
|
use rustc_errors::DiagnosticBuilder;
|
2022-08-26 19:27:17 +00:00
|
|
|
use rustc_errors::ErrorGuaranteed;
|
2022-10-30 13:33:27 +00:00
|
|
|
use rustc_errors::Handler;
|
|
|
|
use rustc_errors::IntoDiagnostic;
|
|
|
|
use rustc_macros::{Diagnostic, Subdiagnostic};
|
2022-08-25 21:30:17 +00:00
|
|
|
use rustc_span::Span;
|
2022-08-25 13:34:30 +00:00
|
|
|
|
2022-08-25 16:36:15 +00:00
|
|
|
pub(crate) enum UnknownCTargetFeature<'a> {
|
|
|
|
UnknownFeaturePrefix { feature: &'a str },
|
|
|
|
UnknownFeature { feature: &'a str, rust_feature: Option<&'a str> },
|
2022-08-25 13:34:30 +00:00
|
|
|
}
|
|
|
|
|
2022-10-30 13:33:27 +00:00
|
|
|
impl IntoDiagnostic<'_, ()> for UnknownCTargetFeature<'_> {
|
|
|
|
fn into_diagnostic(self, sess: &'_ Handler) -> DiagnosticBuilder<'_, ()> {
|
2022-08-25 13:34:30 +00:00
|
|
|
match self {
|
|
|
|
UnknownCTargetFeature::UnknownFeaturePrefix { feature } => {
|
2022-10-30 13:33:27 +00:00
|
|
|
let mut diag = sess.struct_warn(fluent::codegen_llvm_unknown_ctarget_feature);
|
2022-08-25 13:34:30 +00:00
|
|
|
diag.set_arg("feature", feature);
|
2022-10-30 13:33:27 +00:00
|
|
|
diag.note(fluent::codegen_llvm_unknown_feature_prefix);
|
2022-08-25 13:34:30 +00:00
|
|
|
diag
|
|
|
|
}
|
|
|
|
UnknownCTargetFeature::UnknownFeature { feature, rust_feature } => {
|
2022-10-30 13:33:27 +00:00
|
|
|
let mut diag = sess.struct_warn(fluent::codegen_llvm_unknown_ctarget_feature);
|
2022-08-25 13:34:30 +00:00
|
|
|
diag.set_arg("feature", feature);
|
2022-10-30 13:33:27 +00:00
|
|
|
diag.note(fluent::codegen_llvm_unknown_feature);
|
2022-08-25 13:34:30 +00:00
|
|
|
if let Some(rust_feature) = rust_feature {
|
2022-10-30 13:33:27 +00:00
|
|
|
diag.help(fluent::codegen_llvm_rust_feature);
|
2022-08-25 13:34:30 +00:00
|
|
|
diag.set_arg("rust_feature", rust_feature);
|
|
|
|
} else {
|
2022-10-30 13:33:27 +00:00
|
|
|
diag.note(fluent::codegen_llvm_unknown_feature_fill_request);
|
2022-08-25 13:34:30 +00:00
|
|
|
}
|
|
|
|
diag
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-08-25 13:42:20 +00:00
|
|
|
}
|
2022-08-25 19:01:36 +00:00
|
|
|
|
2022-10-30 13:33:27 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_llvm_error_creating_import_library)]
|
2022-08-25 19:01:36 +00:00
|
|
|
pub(crate) struct ErrorCreatingImportLibrary<'a> {
|
|
|
|
pub lib_name: &'a str,
|
|
|
|
pub error: String,
|
|
|
|
}
|
2022-08-25 21:08:18 +00:00
|
|
|
|
2022-10-30 13:33:27 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_llvm_instrument_coverage_requires_llvm_12)]
|
2022-08-25 21:08:18 +00:00
|
|
|
pub(crate) struct InstrumentCoverageRequiresLLVM12;
|
2022-08-25 21:30:17 +00:00
|
|
|
|
2022-10-30 13:33:27 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_llvm_symbol_already_defined)]
|
2022-08-25 21:30:17 +00:00
|
|
|
pub(crate) struct SymbolAlreadyDefined<'a> {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub symbol_name: &'a str,
|
|
|
|
}
|
2022-08-25 22:03:53 +00:00
|
|
|
|
2022-10-30 13:33:27 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_llvm_branch_protection_requires_aarch64)]
|
2022-08-25 22:03:53 +00:00
|
|
|
pub(crate) struct BranchProtectionRequiresAArch64;
|
2022-08-26 08:14:15 +00:00
|
|
|
|
2022-10-30 13:33:27 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_llvm_layout_size_overflow)]
|
2022-08-26 08:14:15 +00:00
|
|
|
pub(crate) struct LayoutSizeOverflow {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub error: String,
|
|
|
|
}
|
2022-08-26 08:30:43 +00:00
|
|
|
|
2022-10-30 13:33:27 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_llvm_invalid_minimum_alignment)]
|
2022-08-26 08:30:43 +00:00
|
|
|
pub(crate) struct InvalidMinimumAlignment {
|
2022-08-26 08:40:48 +00:00
|
|
|
pub err: String,
|
|
|
|
}
|
|
|
|
|
2022-10-30 13:33:27 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_llvm_linkage_const_or_mut_type)]
|
2022-08-26 08:40:48 +00:00
|
|
|
pub(crate) struct LinkageConstOrMutType {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-08-26 08:30:43 +00:00
|
|
|
}
|
2022-08-26 10:19:10 +00:00
|
|
|
|
2022-10-30 13:33:27 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_llvm_sanitizer_memtag_requires_mte)]
|
2022-08-26 10:19:10 +00:00
|
|
|
pub(crate) struct SanitizerMemtagRequiresMte;
|
2022-08-26 12:11:47 +00:00
|
|
|
|
2022-10-30 13:33:27 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_llvm_archive_build_failure)]
|
2022-08-26 12:11:47 +00:00
|
|
|
pub(crate) struct ArchiveBuildFailure {
|
|
|
|
pub error: std::io::Error,
|
|
|
|
}
|
2022-08-26 12:17:15 +00:00
|
|
|
|
2022-10-30 13:33:27 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_llvm_error_writing_def_file)]
|
2022-08-26 12:17:15 +00:00
|
|
|
pub(crate) struct ErrorWritingDEFFile {
|
|
|
|
pub error: std::io::Error,
|
|
|
|
}
|
2022-08-26 12:29:33 +00:00
|
|
|
|
2022-10-30 13:33:27 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_llvm_error_calling_dlltool)]
|
2022-08-26 12:29:33 +00:00
|
|
|
pub(crate) struct ErrorCallingDllTool {
|
|
|
|
pub error: std::io::Error,
|
|
|
|
}
|
2022-08-26 17:01:22 +00:00
|
|
|
|
2022-10-30 13:33:27 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_llvm_dlltool_fail_import_library)]
|
2022-08-26 17:01:22 +00:00
|
|
|
pub(crate) struct DlltoolFailImportLibrary<'a> {
|
|
|
|
pub stdout: Cow<'a, str>,
|
|
|
|
pub stderr: Cow<'a, str>,
|
|
|
|
}
|
2022-08-26 17:42:29 +00:00
|
|
|
|
2022-10-30 13:33:27 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_llvm_unknown_archive_kind)]
|
2022-08-26 17:42:29 +00:00
|
|
|
pub(crate) struct UnknownArchiveKind<'a> {
|
|
|
|
pub kind: &'a str,
|
|
|
|
}
|
2022-08-26 19:27:17 +00:00
|
|
|
|
2022-10-30 15:07:04 +00: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,
|
|
|
|
}
|
|
|
|
|
2022-08-26 19:27:17 +00:00
|
|
|
pub(crate) struct TargetFeatureDisableOrEnable<'a> {
|
|
|
|
pub features: &'a [&'a str],
|
|
|
|
pub span: Option<Span>,
|
|
|
|
}
|
|
|
|
|
2022-10-30 13:33:27 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[help(codegen_llvm_missing_features)]
|
2022-08-26 19:27:17 +00:00
|
|
|
pub(crate) struct MissingFeatures;
|
|
|
|
|
2022-10-30 13:33:27 +00:00
|
|
|
impl IntoDiagnostic<'_, ErrorGuaranteed> for TargetFeatureDisableOrEnable<'_> {
|
|
|
|
fn into_diagnostic(self, sess: &'_ Handler) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
2022-08-26 19:27:17 +00:00
|
|
|
let mut diag = if let Some(span) = self.span {
|
2022-10-30 13:33:27 +00:00
|
|
|
let mut diag = sess.struct_err(fluent::codegen_llvm_target_feature_disable_or_enable);
|
2022-08-26 19:27:17 +00:00
|
|
|
diag.set_span(span);
|
|
|
|
diag
|
|
|
|
} else {
|
2022-10-30 13:33:27 +00:00
|
|
|
sess.struct_err(fluent::codegen_llvm_target_feature_disable_or_enable)
|
2022-08-26 19:27:17 +00:00
|
|
|
};
|
|
|
|
diag.set_arg("features", self.features.join(", "));
|
|
|
|
diag
|
|
|
|
}
|
|
|
|
}
|