From 3029e9e9e476337b9e2c71de669e87839bb19ed5 Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Thu, 23 Apr 2020 18:32:41 +0200 Subject: [PATCH] Add note about padding Co-authored-by: Mark-Simulacrum --- src/libcore/hash/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index 14ca0826733..4f66b00b279 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -570,8 +570,9 @@ mod impls { fn hash_slice(data: &[$ty], state: &mut H) { let newlen = data.len() * mem::size_of::<$ty>(); let ptr = data.as_ptr() as *const u8; - // SAFETY: `ptr` is valid and aligned, the new slice only spans - // across `data` and is never mutated, and its total size is the + // SAFETY: `ptr` is valid and aligned, as this macro is only used + // for numeric primitives which have no padding. The new slice only + // spans across `data` and is never mutated, and its total size is the // same as the original `data` so it can't be over `isize::MAX`. state.write(unsafe { slice::from_raw_parts(ptr, newlen) }) }