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:
parent
432972cae6
commit
02a1ab8071
@ -88,7 +88,9 @@ fn fmt_int<T: DisplayInt>(&self, mut x: T, f: &mut fmt::Formatter<'_>) -> fmt::R
|
||||
};
|
||||
}
|
||||
}
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user