2024-03-06 00:02:56 +00:00
|
|
|
use rustc_errors::{Diag, DiagCtxt, Diagnostic, EmissionGuarantee, Level};
|
2023-10-09 19:53:34 +00:00
|
|
|
use rustc_macros::{Diagnostic, Subdiagnostic};
|
2023-07-20 04:20:00 +00:00
|
|
|
use rustc_span::Span;
|
2022-09-01 05:02:35 +00:00
|
|
|
|
2023-10-09 19:53:34 +00:00
|
|
|
use crate::fluent_generated as fluent;
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_gcc_unknown_ctarget_feature_prefix)]
|
|
|
|
#[note]
|
|
|
|
pub(crate) struct UnknownCTargetFeaturePrefix<'a> {
|
|
|
|
pub feature: &'a str,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_gcc_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(codegen_gcc_possible_feature)]
|
|
|
|
Some { rust_feature: &'a str },
|
|
|
|
#[help(codegen_gcc_consider_filing_feature_request)]
|
|
|
|
None,
|
|
|
|
}
|
|
|
|
|
2022-09-24 18:05:37 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(codegen_gcc_lto_not_supported)]
|
2022-09-01 05:03:05 +00:00
|
|
|
pub(crate) struct LTONotSupported;
|
2022-08-27 03:50:37 +00:00
|
|
|
|
2022-09-24 18:05:37 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(codegen_gcc_unwinding_inline_asm)]
|
2022-08-27 03:44:44 +00:00
|
|
|
pub(crate) struct UnwindingInlineAsm {
|
|
|
|
#[primary_span]
|
2022-05-28 10:43:51 +00:00
|
|
|
pub span: Span,
|
2022-08-27 03:44:44 +00:00
|
|
|
}
|
2023-03-05 17:03:19 +00:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_gcc_invalid_minimum_alignment)]
|
|
|
|
pub(crate) struct InvalidMinimumAlignment {
|
|
|
|
pub err: String,
|
|
|
|
}
|
2023-03-05 17:31:16 +00:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_gcc_tied_target_features)]
|
|
|
|
#[help]
|
|
|
|
pub(crate) struct TiedTargetFeatures {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub features: String,
|
|
|
|
}
|
2023-10-09 19:53:34 +00:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_gcc_copy_bitcode)]
|
|
|
|
pub(crate) struct CopyBitcode {
|
|
|
|
pub err: std::io::Error,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_gcc_dynamic_linking_with_lto)]
|
|
|
|
#[note]
|
|
|
|
pub(crate) struct DynamicLinkingWithLTO;
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_gcc_lto_disallowed)]
|
|
|
|
pub(crate) struct LtoDisallowed;
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_gcc_lto_dylib)]
|
|
|
|
pub(crate) struct LtoDylib;
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(codegen_gcc_lto_bitcode_from_rlib)]
|
|
|
|
pub(crate) struct LtoBitcodeFromRlib {
|
|
|
|
pub gcc_err: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) struct TargetFeatureDisableOrEnable<'a> {
|
|
|
|
pub features: &'a [&'a str],
|
|
|
|
pub span: Option<Span>,
|
|
|
|
pub missing_features: Option<MissingFeatures>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[help(codegen_gcc_missing_features)]
|
|
|
|
pub(crate) struct MissingFeatures;
|
|
|
|
|
2024-03-06 00:02:56 +00:00
|
|
|
impl<G: EmissionGuarantee> Diagnostic<'_, G> for TargetFeatureDisableOrEnable<'_> {
|
|
|
|
fn into_diag(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> {
|
2024-02-22 23:20:45 +00:00
|
|
|
let mut diag = Diag::new(dcx, level, fluent::codegen_gcc_target_feature_disable_or_enable);
|
2023-10-09 19:53:34 +00:00
|
|
|
if let Some(span) = self.span {
|
2023-12-23 22:08:41 +00:00
|
|
|
diag.span(span);
|
2023-10-09 19:53:34 +00:00
|
|
|
};
|
|
|
|
if let Some(missing_features) = self.missing_features {
|
2024-02-14 14:17:27 +00:00
|
|
|
diag.subdiagnostic(dcx, missing_features);
|
2023-10-09 19:53:34 +00:00
|
|
|
}
|
2023-12-23 22:08:41 +00:00
|
|
|
diag.arg("features", self.features.join(", "));
|
2023-10-09 19:53:34 +00:00
|
|
|
diag
|
|
|
|
}
|
|
|
|
}
|