Skip to content

Commit edefcb2

Browse files
committed
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 rust-lang#42239
1 parent f89d8d1 commit edefcb2

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

src/librustc/ich/fingerprint.rs

+1-19
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc_serialize::{Encodable, Decodable, Encoder, Decoder};
1211
use rustc_data_structures::stable_hasher;
1312
use std::mem;
1413
use std::slice;
1514

16-
#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15+
#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Clone, Copy, RustcEncodable, RustcDecodable)]
1716
pub struct Fingerprint(u64, u64);
1817

1918
impl Fingerprint {
@@ -37,23 +36,6 @@ impl Fingerprint {
3736
}
3837
}
3938

40-
impl Encodable for Fingerprint {
41-
#[inline]
42-
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
43-
s.emit_u64(self.0.to_le())?;
44-
s.emit_u64(self.1.to_le())
45-
}
46-
}
47-
48-
impl Decodable for Fingerprint {
49-
#[inline]
50-
fn decode<D: Decoder>(d: &mut D) -> Result<Fingerprint, D::Error> {
51-
let _0 = u64::from_le(d.read_u64()?);
52-
let _1 = u64::from_le(d.read_u64()?);
53-
Ok(Fingerprint(_0, _1))
54-
}
55-
}
56-
5739
impl ::std::fmt::Display for Fingerprint {
5840
fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
5941
write!(formatter, "{:x}-{:x}", self.0, self.1)

0 commit comments

Comments
 (0)