Skip to content

Commit eb99a89

Browse files
committed
Ensure we never accidentally serialize an ErrorGuaranteed
1 parent fd9ef69 commit eb99a89

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

compiler/rustc_span/src/lib.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -2244,7 +2244,7 @@ where
22442244

22452245
/// Useful type to use with `Result<>` indicate that an error has already
22462246
/// been reported to the user, so no need to continue checking.
2247-
#[derive(Clone, Copy, Debug, Encodable, Decodable, Hash, PartialEq, Eq, PartialOrd, Ord)]
2247+
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
22482248
#[derive(HashStable_Generic)]
22492249
pub struct ErrorGuaranteed(());
22502250

@@ -2256,3 +2256,20 @@ impl ErrorGuaranteed {
22562256
ErrorGuaranteed(())
22572257
}
22582258
}
2259+
2260+
impl<E: rustc_serialize::Encoder> Encodable<E> for ErrorGuaranteed {
2261+
#[inline]
2262+
fn encode(&self, _e: &mut E) {
2263+
panic!(
2264+
"should never serialize an `ErrorGuaranteed`, as we do not write metadata or incremental caches in case errors occurred"
2265+
)
2266+
}
2267+
}
2268+
impl<D: rustc_serialize::Decoder> Decodable<D> for ErrorGuaranteed {
2269+
#[inline]
2270+
fn decode(_d: &mut D) -> ErrorGuaranteed {
2271+
panic!(
2272+
"`ErrorGuaranteed` should never have been serialized to metadata or incremental caches"
2273+
)
2274+
}
2275+
}

0 commit comments

Comments
 (0)