Skip to content

Commit 3029e9e

Browse files
Add note about padding
Co-authored-by: Mark-Simulacrum <mark.simulacrum@gmail.com>
1 parent b84f981 commit 3029e9e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/libcore/hash/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,9 @@ mod impls {
570570
fn hash_slice<H: Hasher>(data: &[$ty], state: &mut H) {
571571
let newlen = data.len() * mem::size_of::<$ty>();
572572
let ptr = data.as_ptr() as *const u8;
573-
// SAFETY: `ptr` is valid and aligned, the new slice only spans
574-
// across `data` and is never mutated, and its total size is the
573+
// SAFETY: `ptr` is valid and aligned, as this macro is only used
574+
// for numeric primitives which have no padding. The new slice only
575+
// spans across `data` and is never mutated, and its total size is the
575576
// same as the original `data` so it can't be over `isize::MAX`.
576577
state.write(unsafe { slice::from_raw_parts(ptr, newlen) })
577578
}

0 commit comments

Comments
 (0)