File tree Expand file tree Collapse file tree 2 files changed +3
-0
lines changed Expand file tree Collapse file tree 2 files changed +3
-0
lines changed Original file line number Diff line number Diff 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.
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments