Skip to content

Commit 34097b2

Browse files
committed
fix tidy
1 parent ede7bc0 commit 34097b2

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

library/core/src/ffi/c_str.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ impl CStr {
331331
match nul_pos {
332332
Some(nul_pos) => {
333333
// FIXME(const-hack) replace with range index
334+
// SAFETY: nul_pos + 1 <= bytes.len()
334335
let subslice = unsafe { crate::slice::from_raw_parts(bytes.as_ptr(), nul_pos + 1) };
335336
// SAFETY: We know there is a nul byte at nul_pos, so this slice
336337
// (ending at the nul byte) is a well-formed C string.

library/core/src/slice/memchr.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ const fn memchr_aligned(x: u8, text: &[u8]) -> Option<usize> {
8585
// FIXME(const-hack, fee1-dead): replace with min
8686
offset = if offset < len { offset } else { len };
8787
// FIXME(const-hack, fee1-dead): replace with range slicing
88+
// SAFETY: offset is within bounds
8889
let slice = unsafe { super::from_raw_parts(text.as_ptr(), offset) };
8990
if let Some(index) = memchr_naive(x, slice) {
9091
return Some(index);
@@ -113,6 +114,7 @@ const fn memchr_aligned(x: u8, text: &[u8]) -> Option<usize> {
113114
// Find the byte after the point the body loop stopped.
114115
// FIXME(const-hack): Use `?` instead.
115116
// FIXME(const-hack, fee1-dead): use range slicing
117+
// SAFETY: offset is within bounds
116118
let slice = unsafe { super::from_raw_parts(text.as_ptr().add(offset), text.len() - offset) };
117119
if let Some(i) = memchr_naive(x, slice) { Some(offset + i) } else { None }
118120
}

0 commit comments

Comments
 (0)