Refactor byteorder to std in rustc_middle
Use std::io::{Read, Write} and {to, from}_{le, be}_bytes methods in order to remove byteorder from librustc_middle's dependency graph.
This commit is contained in:
parent
c3364780d2
commit
b97d4131fe
@ -3722,7 +3722,6 @@ name = "rustc_middle"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"byteorder",
|
||||
"chalk-ir",
|
||||
"measureme",
|
||||
"polonius-engine",
|
||||
|
@ -26,7 +26,6 @@ rustc_index = { path = "../rustc_index" }
|
||||
rustc_serialize = { path = "../rustc_serialize" }
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_span = { path = "../rustc_span" }
|
||||
byteorder = { version = "1.3" }
|
||||
chalk-ir = "0.21.0"
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
measureme = "0.7.1"
|
||||
|
@ -98,10 +98,10 @@ mod value;
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt;
|
||||
use std::io;
|
||||
use std::io::{Read, Write};
|
||||
use std::num::NonZeroU32;
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
|
||||
use byteorder::{BigEndian, LittleEndian, ReadBytesExt, WriteBytesExt};
|
||||
use rustc_ast::LitKind;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::sync::{HashMapExt, Lock};
|
||||
@ -561,18 +561,20 @@ pub fn write_target_uint(
|
||||
mut target: &mut [u8],
|
||||
data: u128,
|
||||
) -> Result<(), io::Error> {
|
||||
let len = target.len();
|
||||
match endianness {
|
||||
Endian::Little => target.write_uint128::<LittleEndian>(data, len),
|
||||
Endian::Big => target.write_uint128::<BigEndian>(data, len),
|
||||
}
|
||||
Endian::Little => target.write(&data.to_le_bytes())?,
|
||||
Endian::Big => target.write(&data.to_be_bytes())?,
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn read_target_uint(endianness: Endian, mut source: &[u8]) -> Result<u128, io::Error> {
|
||||
let mut buf = [0; 16];
|
||||
source.read(&mut buf)?;
|
||||
match endianness {
|
||||
Endian::Little => source.read_uint128::<LittleEndian>(source.len()),
|
||||
Endian::Big => source.read_uint128::<BigEndian>(source.len()),
|
||||
Endian::Little => Ok(u128::from_le_bytes(buf)),
|
||||
Endian::Big => Ok(u128::from_be_bytes(buf)),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user