Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Waffle Maybe <waffle.lapkin@gmail.com>
  • Loading branch information
saethlin and WaffleLapkin authored Dec 11, 2023
1 parent b94cfef commit 5f26659
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub(super) fn get_metadata_xcoff<'a>(path: &Path, data: &'a [u8]) -> Result<&'a
return Err(format!("Invalid metadata symbol offset: {offset}"));
}
// The offset specifies the location of rustc metadata in the comment section.
// The metadata is preceded by a 4-byte length field.
// The metadata is preceded by a 8-byte length field.
let len = u64::from_le_bytes(info_data[(offset - 8)..offset].try_into().unwrap()) as usize;
if offset + len > (info_data.len() as usize) {
return Err(format!(
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,9 +705,8 @@ impl MetadataBlob {
}

fn root_pos(&self) -> NonZeroUsize {
let slice = &self.blob()[..];
let offset = METADATA_HEADER.len();
let pos_bytes = slice[offset..][..8].try_into().unwrap();
let pos_bytes = self.blob()[offset..][..8].try_into().unwrap();
let pos = u64::from_le_bytes(pos_bytes);
NonZeroUsize::new(pos as usize).unwrap()
}
Expand Down
3 changes: 1 addition & 2 deletions src/tools/rust-analyzer/crates/proc-macro-api/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ pub fn read_version(dylib_path: &AbsPath) -> io::Result<String> {
// 1 byte for length of version string
// so 13 or 17 bytes in total, and we should check the last of those bytes
// to know the length
let mut bytes_before_version = vec![0u8; bytes_before_version];
uncompressed.read_exact(&mut bytes_before_version)?;
uncompressed.read_exact(&mut [0u8; 17][..bytes_before_version)?;
let length = *bytes_before_version.last().unwrap();

let mut version_string_utf8 = vec![0u8; length as usize];
Expand Down

0 comments on commit 5f26659

Please sign in to comment.