about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDeadbeef <ent3rm4n@gmail.com>2023-04-16 07:27:28 +0000
committerDeadbeef <ent3rm4n@gmail.com>2023-04-16 07:27:28 +0000
commit34097b2f33aa16bbd4f71f6843b26c9ddfa1a471 (patch)
tree074329d7233dffaa98e79bd1c90126754e995ebf
parentede7bc032a7a447ffce7a4c3fc1b1fc72842386b (diff)
downloadrust-34097b2f33aa16bbd4f71f6843b26c9ddfa1a471.tar.gz
rust-34097b2f33aa16bbd4f71f6843b26c9ddfa1a471.zip
fix tidy
-rw-r--r--library/core/src/ffi/c_str.rs1
-rw-r--r--library/core/src/slice/memchr.rs2
2 files changed, 3 insertions, 0 deletions
diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs
index 9b8bc8d1d21..bd2b2c36c43 100644
--- a/library/core/src/ffi/c_str.rs
+++ b/library/core/src/ffi/c_str.rs
@@ -331,6 +331,7 @@ impl CStr {
         match nul_pos {
             Some(nul_pos) => {
                 // FIXME(const-hack) replace with range index
+                // SAFETY: nul_pos + 1 <= bytes.len()
                 let subslice = unsafe { crate::slice::from_raw_parts(bytes.as_ptr(), nul_pos + 1) };
                 // SAFETY: We know there is a nul byte at nul_pos, so this slice
                 // (ending at the nul byte) is a well-formed C string.
diff --git a/library/core/src/slice/memchr.rs b/library/core/src/slice/memchr.rs
index 3ae15e47bce..3a8b59d727b 100644
--- a/library/core/src/slice/memchr.rs
+++ b/library/core/src/slice/memchr.rs
@@ -85,6 +85,7 @@ const fn memchr_aligned(x: u8, text: &[u8]) -> Option<usize> {
         // FIXME(const-hack, fee1-dead): replace with min
         offset = if offset < len { offset } else { len };
         // FIXME(const-hack, fee1-dead): replace with range slicing
+        // SAFETY: offset is within bounds
         let slice = unsafe { super::from_raw_parts(text.as_ptr(), offset) };
         if let Some(index) = memchr_naive(x, slice) {
             return Some(index);
@@ -113,6 +114,7 @@ const fn memchr_aligned(x: u8, text: &[u8]) -> Option<usize> {
     // Find the byte after the point the body loop stopped.
     // FIXME(const-hack): Use `?` instead.
     // FIXME(const-hack, fee1-dead): use range slicing
+    // SAFETY: offset is within bounds
     let slice = unsafe { super::from_raw_parts(text.as_ptr().add(offset), text.len() - offset) };
     if let Some(i) = memchr_naive(x, slice) { Some(offset + i) } else { None }
 }