about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJames Cowgill <james410@cowgill.org.uk>2017-05-31 15:53:35 +0100
committerJames Cowgill <james410@cowgill.org.uk>2017-06-01 10:32:11 +0100
commitedefcb2946c3eb94e8f43ce3a979b4a876d8e11a (patch)
tree798e9d1e8587927b5c8326f53b195a8057db88af
parentf89d8d184490ecb3cf91f7b6bb7296d649f931ba (diff)
downloadrust-edefcb2946c3eb94e8f43ce3a979b4a876d8e11a.tar.gz
rust-edefcb2946c3eb94e8f43ce3a979b4a876d8e11a.zip
Don't byteswap Fingerprints when encoding
Byteswapping Fingerprints when encoding is unnessesary and breaks if
the Fingerprint is later decoded on a machine with different endianness
to the one it was encoded on. Fix by removing the Encodable and
Decodable implementations and use the ones derived from RustcEncodable
and RustcDecodable.

Fixes #42239
-rw-r--r--src/librustc/ich/fingerprint.rs20
1 files changed, 1 insertions, 19 deletions
diff --git a/src/librustc/ich/fingerprint.rs b/src/librustc/ich/fingerprint.rs
index a947f6aeff7..8308c756c05 100644
--- a/src/librustc/ich/fingerprint.rs
+++ b/src/librustc/ich/fingerprint.rs
@@ -8,12 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use rustc_serialize::{Encodable, Decodable, Encoder, Decoder};
 use rustc_data_structures::stable_hasher;
 use std::mem;
 use std::slice;
 
-#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
+#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Clone, Copy, RustcEncodable, RustcDecodable)]
 pub struct Fingerprint(u64, u64);
 
 impl Fingerprint {
@@ -37,23 +36,6 @@ impl Fingerprint {
     }
 }
 
-impl Encodable for Fingerprint {
-    #[inline]
-    fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
-        s.emit_u64(self.0.to_le())?;
-        s.emit_u64(self.1.to_le())
-    }
-}
-
-impl Decodable for Fingerprint {
-    #[inline]
-    fn decode<D: Decoder>(d: &mut D) -> Result<Fingerprint, D::Error> {
-        let _0 = u64::from_le(d.read_u64()?);
-        let _1 = u64::from_le(d.read_u64()?);
-        Ok(Fingerprint(_0, _1))
-    }
-}
-
 impl ::std::fmt::Display for Fingerprint {
     fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
         write!(formatter, "{:x}-{:x}", self.0, self.1)