Replace checked slice indexing by unchecked to support panic-free code

Fixes #126425

Replace the potentially panicking `[]` indexing with `get_unchecked()`
to prevent linking with panic-related code.
This commit is contained in:
Eugene Shamis 2024-11-01 15:33:07 -04:00
parent 432972cae6
commit 02a1ab8071

View File

@ -88,7 +88,9 @@ unsafe trait GenericRadix: Sized {
};
}
}
let buf = &buf[curr..];
// SAFETY: `curr` is initialized to `buf.len()` and is only decremented,
// so it is always in bounds.
let buf = unsafe { buf.get_unchecked(curr..) };
// SAFETY: The only chars in `buf` are created by `Self::digit` which are assumed to be
// valid UTF-8
let buf = unsafe {