about summary refs log tree commit diff
path: root/compiler/rustc_query_system/src/error.rs
diff options
context:
space:
mode:
authorDavid Wood <david.wood@huawei.com>2022-10-03 14:09:05 +0100
committerDavid Wood <david.wood@huawei.com>2022-10-10 14:20:16 +0100
commitb4ac26289f17a5779d4318fb63436d94aebbf5ea (patch)
treefce3d4cf2f0940a396eb8aed0626dfe2a22bbe9e /compiler/rustc_query_system/src/error.rs
parent508d7e6d26bd636081c96ee6ed61f833917343ea (diff)
downloadrust-b4ac26289f17a5779d4318fb63436d94aebbf5ea.tar.gz
rust-b4ac26289f17a5779d4318fb63436d94aebbf5ea.zip
errors: `AddToDiagnostic::add_to_diagnostic_with`
`AddToDiagnostic::add_to_diagnostic_with` is similar to the previous
`AddToDiagnostic::add_to_diagnostic` but takes a function that can be
used by the caller to modify diagnostic messages originating from the
subdiagnostic (such as performing translation eagerly).

`add_to_diagnostic` now just calls `add_to_diagnostic_with` with an
empty closure.

Signed-off-by: David Wood <david.wood@huawei.com>
Diffstat (limited to 'compiler/rustc_query_system/src/error.rs')
-rw-r--r--compiler/rustc_query_system/src/error.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/rustc_query_system/src/error.rs b/compiler/rustc_query_system/src/error.rs
index 8602a4cf5ae..debdf9dbf44 100644
--- a/compiler/rustc_query_system/src/error.rs
+++ b/compiler/rustc_query_system/src/error.rs
@@ -1,4 +1,4 @@
-use rustc_errors::AddToDiagnostic;
+use rustc_errors::{AddToDiagnostic, Diagnostic, SubdiagnosticMessage};
 use rustc_macros::{Diagnostic, Subdiagnostic};
 use rustc_session::Limit;
 use rustc_span::{Span, Symbol};
@@ -9,7 +9,10 @@ pub struct CycleStack {
 }
 
 impl AddToDiagnostic for CycleStack {
-    fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
+    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));
     }
 }