about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-10-27 19:46:06 +0200
committerGitHub <noreply@github.com>2023-10-27 19:46:06 +0200
commitdf8852a93453cd1ce7449a08db2ad7e265d4ef3f (patch)
tree7b624a9833ea77d3f776c2501eff2e2390758b98
parent9d6d5d48948945debca5a693f6030246f7bb2baf (diff)
parentf4a9d29c50de93c3320867a4f63c9e36eee43d3b (diff)
downloadrust-df8852a93453cd1ce7449a08db2ad7e265d4ef3f.tar.gz
rust-df8852a93453cd1ce7449a08db2ad7e265d4ef3f.zip
Rollup merge of #116834 - nnethercote:rustc_symbol_mangling, r=davidtwco
Remove `rustc_symbol_mangling/messages.ftl`.

It contains a single message that (a) doesn't contain any natural language, and (b) is only used in tests.

r? `@davidtwco`
-rw-r--r--Cargo.lock2
-rw-r--r--compiler/rustc_driver_impl/src/lib.rs1
-rw-r--r--compiler/rustc_symbol_mangling/Cargo.toml2
-rw-r--r--compiler/rustc_symbol_mangling/messages.ftl1
-rw-r--r--compiler/rustc_symbol_mangling/src/errors.rs40
-rw-r--r--compiler/rustc_symbol_mangling/src/lib.rs4
6 files changed, 26 insertions, 24 deletions
diff --git a/Cargo.lock b/Cargo.lock
index ff21d5f8c08..aca76c9c495 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4557,9 +4557,7 @@ dependencies = [
  "rustc-demangle",
  "rustc_data_structures",
  "rustc_errors",
- "rustc_fluent_macro",
  "rustc_hir",
- "rustc_macros",
  "rustc_middle",
  "rustc_session",
  "rustc_span",
diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs
index 331843ab051..c6c8fd22f4e 100644
--- a/compiler/rustc_driver_impl/src/lib.rs
+++ b/compiler/rustc_driver_impl/src/lib.rs
@@ -136,7 +136,6 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
     rustc_query_system::DEFAULT_LOCALE_RESOURCE,
     rustc_resolve::DEFAULT_LOCALE_RESOURCE,
     rustc_session::DEFAULT_LOCALE_RESOURCE,
-    rustc_symbol_mangling::DEFAULT_LOCALE_RESOURCE,
     rustc_trait_selection::DEFAULT_LOCALE_RESOURCE,
     rustc_ty_utils::DEFAULT_LOCALE_RESOURCE,
     // tidy-alphabetical-end
diff --git a/compiler/rustc_symbol_mangling/Cargo.toml b/compiler/rustc_symbol_mangling/Cargo.toml
index 052ef8bb94c..d53bc5b6a8e 100644
--- a/compiler/rustc_symbol_mangling/Cargo.toml
+++ b/compiler/rustc_symbol_mangling/Cargo.toml
@@ -15,9 +15,7 @@ twox-hash = "1.6.3"
 rustc_span = { path = "../rustc_span" }
 rustc_middle = { path = "../rustc_middle" }
 rustc_hir = { path = "../rustc_hir" }
-rustc_fluent_macro = { path = "../rustc_fluent_macro" }
 rustc_target = { path = "../rustc_target" }
 rustc_data_structures = { path = "../rustc_data_structures" }
 rustc_session = { path = "../rustc_session" }
-rustc_macros = { path = "../rustc_macros" }
 rustc_errors = { path = "../rustc_errors" }
diff --git a/compiler/rustc_symbol_mangling/messages.ftl b/compiler/rustc_symbol_mangling/messages.ftl
deleted file mode 100644
index b7d48280f46..00000000000
--- a/compiler/rustc_symbol_mangling/messages.ftl
+++ /dev/null
@@ -1 +0,0 @@
-symbol_mangling_test_output = {$kind}({$content})
diff --git a/compiler/rustc_symbol_mangling/src/errors.rs b/compiler/rustc_symbol_mangling/src/errors.rs
index f4d0751f753..2e081e55531 100644
--- a/compiler/rustc_symbol_mangling/src/errors.rs
+++ b/compiler/rustc_symbol_mangling/src/errors.rs
@@ -1,18 +1,32 @@
 //! Errors emitted by symbol_mangling.
 
-use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
-use rustc_macros::Diagnostic;
+use rustc_errors::{ErrorGuaranteed, IntoDiagnostic};
 use rustc_span::Span;
+use std::fmt;
 
-#[derive(Diagnostic)]
-#[diag(symbol_mangling_test_output)]
 pub struct TestOutput {
-    #[primary_span]
     pub span: Span,
     pub kind: Kind,
     pub content: String,
 }
 
+// This diagnostic doesn't need translation because (a) it doesn't contain any
+// natural language, and (b) it's only used in tests. So we construct it
+// manually and avoid the fluent machinery.
+impl IntoDiagnostic<'_> for TestOutput {
+    fn into_diagnostic(
+        self,
+        handler: &'_ rustc_errors::Handler,
+    ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
+        let TestOutput { span, kind, content } = self;
+
+        #[allow(rustc::untranslatable_diagnostic)]
+        let mut diag = handler.struct_err(format!("{kind}({content})"));
+        diag.set_span(span);
+        diag
+    }
+}
+
 pub enum Kind {
     SymbolName,
     Demangling,
@@ -20,15 +34,13 @@ pub enum Kind {
     DefPath,
 }
 
-impl IntoDiagnosticArg for Kind {
-    fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
-        let kind = match self {
-            Kind::SymbolName => "symbol-name",
-            Kind::Demangling => "demangling",
-            Kind::DemanglingAlt => "demangling-alt",
-            Kind::DefPath => "def-path",
+impl fmt::Display for Kind {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        match self {
+            Kind::SymbolName => write!(f, "symbol-name"),
+            Kind::Demangling => write!(f, "demangling"),
+            Kind::DemanglingAlt => write!(f, "demangling-alt"),
+            Kind::DefPath => write!(f, "def-path"),
         }
-        .into();
-        DiagnosticArgValue::Str(kind)
     }
 }
diff --git a/compiler/rustc_symbol_mangling/src/lib.rs b/compiler/rustc_symbol_mangling/src/lib.rs
index 7b4ab67a24d..14dd8b4e56f 100644
--- a/compiler/rustc_symbol_mangling/src/lib.rs
+++ b/compiler/rustc_symbol_mangling/src/lib.rs
@@ -103,8 +103,6 @@ extern crate rustc_middle;
 #[macro_use]
 extern crate tracing;
 
-use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
-use rustc_fluent_macro::fluent_messages;
 use rustc_hir::def::DefKind;
 use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
 use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
@@ -121,8 +119,6 @@ pub mod errors;
 pub mod test;
 pub mod typeid;
 
-fluent_messages! { "../messages.ftl" }
-
 /// This function computes the symbol name for the given `instance` and the
 /// given instantiating crate. That is, if you know that instance X is
 /// instantiated in crate Y, this is the symbol name this instance would have.