diff options
| -rw-r--r-- | library/core/src/fmt/num.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/library/core/src/fmt/num.rs b/library/core/src/fmt/num.rs index f1540803f97..aaf429bac8e 100644 --- a/library/core/src/fmt/num.rs +++ b/library/core/src/fmt/num.rs @@ -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 { |
