mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
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 @@ 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 {
|
||||
|
Loading…
Reference in New Issue
Block a user