Apply suggestions from code review
Co-authored-by: Waffle Maybe <waffle.lapkin@gmail.com>
This commit is contained in:
parent
b94cfefc86
commit
79bdd24d6e
3 changed files with 9 additions and 10 deletions
|
@ -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!(
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue