about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/errors.rs
diff options
context:
space:
mode:
authorSLASHLogin <loginmlgxd@gmail.com>2022-08-26 21:27:17 +0200
committerSLASHLogin <loginmlgxd@gmail.com>2022-11-09 14:56:21 +0100
commit185ef7b6de0dcdd32af43fd75efa41fd128cbaad (patch)
treeafa86983a15ad6263b67a8584fe20169c13912b5 /compiler/rustc_codegen_llvm/src/errors.rs
parent33ef16f291b6a43dc57dcb8915bdb4aa736a7936 (diff)
downloadrust-185ef7b6de0dcdd32af43fd75efa41fd128cbaad.tar.gz
rust-185ef7b6de0dcdd32af43fd75efa41fd128cbaad.zip
Port `MissingFeatures` and `TargetFeatureDisableOrEnable`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/errors.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/errors.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/errors.rs b/compiler/rustc_codegen_llvm/src/errors.rs
index 1fe88cc2482..cd53ac4532a 100644
--- a/compiler/rustc_codegen_llvm/src/errors.rs
+++ b/compiler/rustc_codegen_llvm/src/errors.rs
@@ -2,7 +2,8 @@ use std::borrow::Cow;
 
 use rustc_errors::fluent;
 use rustc_errors::DiagnosticBuilder;
-use rustc_macros::SessionDiagnostic;
+use rustc_errors::ErrorGuaranteed;
+use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic};
 use rustc_session::SessionDiagnostic;
 use rustc_span::Span;
 
@@ -117,3 +118,29 @@ pub(crate) struct DlltoolFailImportLibrary<'a> {
 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
+    }
+}