File tree 2 files changed +3
-0
lines changed
2 files changed +3
-0
lines changed Original file line number Diff line number Diff line change @@ -331,6 +331,7 @@ impl CStr {
331
331
match nul_pos {
332
332
Some ( nul_pos) => {
333
333
// FIXME(const-hack) replace with range index
334
+ // SAFETY: nul_pos + 1 <= bytes.len()
334
335
let subslice = unsafe { crate :: slice:: from_raw_parts ( bytes. as_ptr ( ) , nul_pos + 1 ) } ;
335
336
// SAFETY: We know there is a nul byte at nul_pos, so this slice
336
337
// (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> {
85
85
// FIXME(const-hack, fee1-dead): replace with min
86
86
offset = if offset < len { offset } else { len } ;
87
87
// FIXME(const-hack, fee1-dead): replace with range slicing
88
+ // SAFETY: offset is within bounds
88
89
let slice = unsafe { super :: from_raw_parts ( text. as_ptr ( ) , offset) } ;
89
90
if let Some ( index) = memchr_naive ( x, slice) {
90
91
return Some ( index) ;
@@ -113,6 +114,7 @@ const fn memchr_aligned(x: u8, text: &[u8]) -> Option<usize> {
113
114
// Find the byte after the point the body loop stopped.
114
115
// FIXME(const-hack): Use `?` instead.
115
116
// FIXME(const-hack, fee1-dead): use range slicing
117
+ // SAFETY: offset is within bounds
116
118
let slice = unsafe { super :: from_raw_parts ( text. as_ptr ( ) . add ( offset) , text. len ( ) - offset) } ;
117
119
if let Some ( i) = memchr_naive ( x, slice) { Some ( offset + i) } else { None }
118
120
}
You can’t perform that action at this time.
0 commit comments