Skip to content

Commit ec79883

Browse files
authored
Rollup merge of rust-lang#97545 - thomcc:sip-comment-safety, r=Dylan-DPC
Reword safety comments in core/hash/sip.rs In https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/Is.20there.20any.20way.20to.20soundly.20do.20a.20masked.20out-of-bounds.20read.3F/near/284329248 it came up that this is using an atypical (and somewhat vague) phrasing of the safety requirement, so this slightly rewords it.
2 parents b50b4e4 + fa0320e commit ec79883

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: core/src/hash/sip.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ macro_rules! compress {
9696
/// `copy_nonoverlapping` to let the compiler generate the most efficient way
9797
/// to load it from a possibly unaligned address.
9898
///
99-
/// Unsafe because: unchecked indexing at i..i+size_of(int_ty)
99+
/// Safety: this performs unchecked indexing of `$buf` at
100+
/// `$i..$i+size_of::<$int_ty>()`, so that must be in-bounds.
100101
macro_rules! load_int_le {
101102
($buf:expr, $i:expr, $int_ty:ident) => {{
102103
debug_assert!($i + mem::size_of::<$int_ty>() <= $buf.len());
@@ -114,7 +115,8 @@ macro_rules! load_int_le {
114115
/// `copy_nonoverlapping` calls that occur (via `load_int_le!`) all have fixed
115116
/// sizes and avoid calling `memcpy`, which is good for speed.
116117
///
117-
/// Unsafe because: unchecked indexing at start..start+len
118+
/// Safety: this performs unchecked indexing of `buf` at `start..start+len`, so
119+
/// that must be in-bounds.
118120
#[inline]
119121
unsafe fn u8to64_le(buf: &[u8], start: usize, len: usize) -> u64 {
120122
debug_assert!(len < 8);

0 commit comments

Comments
 (0)