Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

147 lines
4.4 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;
use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic};
use rustc_session::SessionDiagnostic;
2022-08-25 23:30:17 +02:00
use rustc_span::Span;
2022-08-25 18:36:15 +02:00
pub(crate) enum UnknownCTargetFeature<'a> {
UnknownFeaturePrefix { feature: &'a str },
UnknownFeature { feature: &'a str, rust_feature: Option<&'a str> },
}
impl SessionDiagnostic<'_, ()> for UnknownCTargetFeature<'_> {
2022-08-25 15:42:20 +02:00
fn into_diagnostic(
self,
sess: &'_ rustc_session::parse::ParseSess,
) -> DiagnosticBuilder<'_, ()> {
match self {
UnknownCTargetFeature::UnknownFeaturePrefix { feature } => {
let mut diag = sess.struct_warn(fluent::codegen_llvm::unknown_ctarget_feature);
diag.set_arg("feature", feature);
diag.note(fluent::codegen_llvm::unknown_feature_prefix);
diag
}
UnknownCTargetFeature::UnknownFeature { feature, rust_feature } => {
let mut diag = sess.struct_warn(fluent::codegen_llvm::unknown_ctarget_feature);
diag.set_arg("feature", feature);
diag.note(fluent::codegen_llvm::unknown_feature);
if let Some(rust_feature) = rust_feature {
diag.help(fluent::codegen_llvm::rust_feature);
diag.set_arg("rust_feature", rust_feature);
} else {
diag.note(fluent::codegen_llvm::unknown_feature_fill_request);
}
diag
}
}
}
2022-08-25 15:42:20 +02:00
}
2022-08-25 21:01:36 +02:00
#[derive(SessionDiagnostic)]
#[diag(codegen_llvm::error_creating_import_library)]
pub(crate) struct ErrorCreatingImportLibrary<'a> {
pub lib_name: &'a str,
pub error: String,
}
#[derive(SessionDiagnostic)]
#[diag(codegen_llvm::instrument_coverage_requires_llvm_12)]
pub(crate) struct InstrumentCoverageRequiresLLVM12;
2022-08-25 23:30:17 +02:00
#[derive(SessionDiagnostic)]
2022-08-25 23:47:11 +02:00
#[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
#[derive(SessionDiagnostic)]
#[diag(codegen_llvm::branch_protection_requires_aarch64)]
pub(crate) struct BranchProtectionRequiresAArch64;
2022-08-26 10:14:15 +02:00
#[derive(SessionDiagnostic)]
#[diag(codegen_llvm::layout_size_overflow)]
pub(crate) struct LayoutSizeOverflow {
#[primary_span]
pub span: Span,
pub error: String,
}
2022-08-26 10:30:43 +02:00
#[derive(SessionDiagnostic)]
#[diag(codegen_llvm::invalid_minimum_alignment)]
pub(crate) struct InvalidMinimumAlignment {
2022-08-26 10:40:48 +02:00
pub err: String,
}
#[derive(SessionDiagnostic)]
#[diag(codegen_llvm::linkage_const_or_mut_type)]
pub(crate) struct LinkageConstOrMutType {
#[primary_span]
pub span: Span,
2022-08-26 10:30:43 +02:00
}
2022-08-26 12:19:10 +02:00
#[derive(SessionDiagnostic)]
#[diag(codegen_llvm::sanitizer_memtag_requires_mte)]
pub(crate) struct SanitizerMemtagRequiresMte;
2022-08-26 14:11:47 +02:00
#[derive(SessionDiagnostic)]
#[diag(codegen_llvm::archive_build_failure)]
pub(crate) struct ArchiveBuildFailure {
pub error: std::io::Error,
}
2022-08-26 14:17:15 +02:00
#[derive(SessionDiagnostic)]
#[diag(codegen_llvm::error_writing_def_file)]
pub(crate) struct ErrorWritingDEFFile {
pub error: std::io::Error,
}
2022-08-26 14:29:33 +02:00
#[derive(SessionDiagnostic)]
#[diag(codegen_llvm::error_calling_dlltool)]
pub(crate) struct ErrorCallingDllTool {
pub error: std::io::Error,
}
#[derive(SessionDiagnostic)]
#[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
#[derive(SessionDiagnostic)]
#[diag(codegen_llvm::unknown_archive_kind)]
pub(crate) struct UnknownArchiveKind<'a> {
pub kind: &'a str,
}
pub(crate) struct TargetFeatureDisableOrEnable<'a> {
pub features: &'a [&'a str],
pub span: Option<Span>,
}
#[derive(SessionSubdiagnostic)]
#[help(codegen_llvm::missing_features)]
pub(crate) struct MissingFeatures;
impl SessionDiagnostic<'_, ErrorGuaranteed> for TargetFeatureDisableOrEnable<'_> {
fn into_diagnostic(
self,
sess: &'_ rustc_session::parse::ParseSess,
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut diag = if let Some(span) = self.span {
let mut diag = sess.struct_err(fluent::codegen_llvm::target_feature_disable_or_enable);
diag.set_span(span);
diag
} else {
sess.struct_err(fluent::codegen_llvm::target_feature_disable_or_enable)
};
diag.set_arg("features", self.features.join(", "));
diag
}
}