about summary refs log tree commit diff
path: root/compiler/rustc_span
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-10-18 09:51:50 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-10-20 08:46:30 +0000
commiteb99a89bd7037bb5662ba3d16296a4f7a2adaea6 (patch)
treee8e77828e508641f21526c6221c44957ac8ef43c /compiler/rustc_span
parentfd9ef69adf631a96ffad2d777653ae2554909866 (diff)
downloadrust-eb99a89bd7037bb5662ba3d16296a4f7a2adaea6.tar.gz
rust-eb99a89bd7037bb5662ba3d16296a4f7a2adaea6.zip
Ensure we never accidentally serialize an `ErrorGuaranteed`
Diffstat (limited to 'compiler/rustc_span')
-rw-r--r--compiler/rustc_span/src/lib.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs
index 49b4042d148..444dc09c11d 100644
--- a/compiler/rustc_span/src/lib.rs
+++ b/compiler/rustc_span/src/lib.rs
@@ -2244,7 +2244,7 @@ where
 
 /// Useful type to use with `Result<>` indicate that an error has already
 /// been reported to the user, so no need to continue checking.
-#[derive(Clone, Copy, Debug, Encodable, Decodable, Hash, PartialEq, Eq, PartialOrd, Ord)]
+#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
 #[derive(HashStable_Generic)]
 pub struct ErrorGuaranteed(());
 
@@ -2256,3 +2256,20 @@ impl ErrorGuaranteed {
         ErrorGuaranteed(())
     }
 }
+
+impl<E: rustc_serialize::Encoder> Encodable<E> for ErrorGuaranteed {
+    #[inline]
+    fn encode(&self, _e: &mut E) {
+        panic!(
+            "should never serialize an `ErrorGuaranteed`, as we do not write metadata or incremental caches in case errors occurred"
+        )
+    }
+}
+impl<D: rustc_serialize::Decoder> Decodable<D> for ErrorGuaranteed {
+    #[inline]
+    fn decode(_d: &mut D) -> ErrorGuaranteed {
+        panic!(
+            "`ErrorGuaranteed` should never have been serialized to metadata or incremental caches"
+        )
+    }
+}