about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-06-26 10:52:57 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-06-26 16:01:44 +0000
commit5988078aa20bf642bc1bbab15a45ac5cb74e77e2 (patch)
tree0b8a07c5f03b72422c1ff961bb6ec4491ed2007f /compiler/rustc_errors/src
parent79ac8982ca24e25b592b06ef636050f5a5a81bde (diff)
downloadrust-5988078aa20bf642bc1bbab15a45ac5cb74e77e2.tar.gz
rust-5988078aa20bf642bc1bbab15a45ac5cb74e77e2.zip
Restrict diagnostic context lifetime of InferCtxt to itself instead of TyCtxt
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/diagnostic.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs
index e580910af77..0231665b64c 100644
--- a/compiler/rustc_errors/src/diagnostic.rs
+++ b/compiler/rustc_errors/src/diagnostic.rs
@@ -582,6 +582,11 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
         Self::new_diagnostic(dcx, DiagInner::new(level, message))
     }
 
+    /// Allow moving diagnostics between different error tainting contexts
+    pub fn with_dcx(mut self, dcx: DiagCtxtHandle<'_>) -> Diag<'_, G> {
+        Diag { dcx, diag: self.diag.take(), _marker: PhantomData }
+    }
+
     /// Creates a new `Diag` with an already constructed diagnostic.
     #[track_caller]
     pub(crate) fn new_diagnostic(dcx: DiagCtxtHandle<'a>, diag: DiagInner) -> Self {