about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Wood <david.wood@huawei.com>2022-10-03 14:26:29 +0100
committerDavid Wood <david.wood@huawei.com>2022-10-10 14:20:16 +0100
commit113e94369cb72a98648c12c263475821bbff7d9c (patch)
tree390ed56994dd90cdd349f867eeea4270967c06bb
parent291a4736d9300a9be79a5f105c54a06a2a4f1d1b (diff)
downloadrust-113e94369cb72a98648c12c263475821bbff7d9c.tar.gz
rust-113e94369cb72a98648c12c263475821bbff7d9c.zip
query_system: finish migration
Using eager translation, migrate the remaining repeated cycle stack
diagnostic.

Signed-off-by: David Wood <david.wood@huawei.com>
-rw-r--r--compiler/rustc_error_messages/locales/en-US/query_system.ftl2
-rw-r--r--compiler/rustc_query_system/src/error.rs15
-rw-r--r--compiler/rustc_query_system/src/lib.rs2
3 files changed, 7 insertions, 12 deletions
diff --git a/compiler/rustc_error_messages/locales/en-US/query_system.ftl b/compiler/rustc_error_messages/locales/en-US/query_system.ftl
index b914ba52a73..870e824039c 100644
--- a/compiler/rustc_error_messages/locales/en-US/query_system.ftl
+++ b/compiler/rustc_error_messages/locales/en-US/query_system.ftl
@@ -12,6 +12,8 @@ query_system_cycle_usage = cycle used when {$usage}
 
 query_system_cycle_stack_single = ...which immediately requires {$stack_bottom} again
 
+query_system_cycle_stack_middle = ...which requires {$desc}...
+
 query_system_cycle_stack_multiple = ...which again requires {$stack_bottom}, completing the cycle
 
 query_system_cycle_recursive_ty_alias = type aliases cannot be recursive
diff --git a/compiler/rustc_query_system/src/error.rs b/compiler/rustc_query_system/src/error.rs
index debdf9dbf44..1e74e0e2990 100644
--- a/compiler/rustc_query_system/src/error.rs
+++ b/compiler/rustc_query_system/src/error.rs
@@ -1,22 +1,15 @@
-use rustc_errors::{AddToDiagnostic, Diagnostic, SubdiagnosticMessage};
 use rustc_macros::{Diagnostic, Subdiagnostic};
 use rustc_session::Limit;
 use rustc_span::{Span, Symbol};
 
+#[derive(Subdiagnostic)]
+#[note(query_system::cycle_stack_middle)]
 pub struct CycleStack {
+    #[primary_span]
     pub span: Span,
     pub desc: String,
 }
 
-impl AddToDiagnostic for CycleStack {
-    fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F)
-    where
-        F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
-    {
-        diag.span_note(self.span, &format!("...which requires {}...", self.desc));
-    }
-}
-
 #[derive(Copy, Clone)]
 pub enum HandleCycleError {
     Error,
@@ -56,7 +49,7 @@ pub struct Cycle {
     #[primary_span]
     pub span: Span,
     pub stack_bottom: String,
-    #[subdiagnostic]
+    #[subdiagnostic(eager)]
     pub cycle_stack: Vec<CycleStack>,
     #[subdiagnostic]
     pub stack_count: StackCount,
diff --git a/compiler/rustc_query_system/src/lib.rs b/compiler/rustc_query_system/src/lib.rs
index 8f6da73d1f2..f47760e9ae6 100644
--- a/compiler/rustc_query_system/src/lib.rs
+++ b/compiler/rustc_query_system/src/lib.rs
@@ -4,7 +4,7 @@
 #![feature(min_specialization)]
 #![feature(extern_types)]
 #![allow(rustc::potential_query_instability)]
-// #![deny(rustc::untranslatable_diagnostic)]
+#![deny(rustc::untranslatable_diagnostic)]
 #![deny(rustc::diagnostic_outside_of_impl)]
 
 #[macro_use]