Skip to content

Commit 9241997

Browse files
committed
fix review notes
Signed-off-by: onur-ozkan <[email protected]>
1 parent 835d4b2 commit 9241997

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2200,12 +2200,10 @@ impl<D: Decoder> Decodable<D> for EncodedMetadata {
22002200
let len = d.read_usize();
22012201
let mmap = if len > 0 {
22022202
let mut mmap = MmapMut::map_anon(len).unwrap();
2203-
let mut num_bytes = 0;
22042203
for _ in 0..len {
2205-
num_bytes += (&mut mmap[..]).write(&[d.read_u8()]).unwrap();
2204+
(&mut mmap[..]).write_all(&[d.read_u8()]).unwrap();
22062205
}
22072206
mmap.flush().unwrap();
2208-
debug_assert!(len == num_bytes);
22092207
Some(mmap.make_read_only().unwrap())
22102208
} else {
22112209
None

compiler/rustc_middle/src/mir/interpret/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -671,11 +671,11 @@ pub fn read_target_uint(endianness: Endian, mut source: &[u8]) -> Result<u128, i
671671
// So we do not read exactly 16 bytes into the u128, just the "payload".
672672
let uint = match endianness {
673673
Endian::Little => {
674-
let _ = source.read(&mut buf)?;
674+
source.read_exact(&mut buf)?;
675675
Ok(u128::from_le_bytes(buf))
676676
}
677677
Endian::Big => {
678-
let _ = source.read(&mut buf[16 - source.len()..])?;
678+
source.read_exact(&mut buf[16 - source.len()..])?;
679679
Ok(u128::from_be_bytes(buf))
680680
}
681681
};

compiler/stable_mir/src/mir/alloc.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ pub(crate) fn read_target_uint(mut bytes: &[u8]) -> Result<u128, Error> {
5757
let mut buf = [0u8; std::mem::size_of::<u128>()];
5858
match MachineInfo::target_endianess() {
5959
Endian::Little => {
60-
let _ = bytes.read(&mut buf)?;
60+
bytes.read_exact(&mut buf)?;
6161
Ok(u128::from_le_bytes(buf))
6262
}
6363
Endian::Big => {
64-
let _ = bytes.read(&mut buf[16 - bytes.len()..])?;
64+
bytes.read_exact(&mut buf[16 - bytes.len()..])?;
6565
Ok(u128::from_be_bytes(buf))
6666
}
6767
}
@@ -72,11 +72,11 @@ pub(crate) fn read_target_int(mut bytes: &[u8]) -> Result<i128, Error> {
7272
let mut buf = [0u8; std::mem::size_of::<i128>()];
7373
match MachineInfo::target_endianess() {
7474
Endian::Little => {
75-
let _ = bytes.read(&mut buf)?;
75+
bytes.read_exact(&mut buf)?;
7676
Ok(i128::from_le_bytes(buf))
7777
}
7878
Endian::Big => {
79-
let _ = bytes.read(&mut buf[16 - bytes.len()..])?;
79+
bytes.read_exact(&mut buf[16 - bytes.len()..])?;
8080
Ok(i128::from_be_bytes(buf))
8181
}
8282
}

0 commit comments

Comments
 (0)