Skip to content

Commit afcb634

Browse files
committed
use Size addition instead of checked int addition
1 parent 0bc108a commit afcb634

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/librustc/mir/interpret/allocation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
293293
let offset = usize::try_from(ptr.offset.bytes()).unwrap();
294294
Ok(match self.bytes[offset..].iter().position(|&c| c == 0) {
295295
Some(size) => {
296-
let size_with_null = Size::from_bytes(size.checked_add(1).unwrap());
296+
let size_with_null = Size::add(Size::from_bytes(size), Size::from_bytes(1));
297297
// Go through `get_bytes` for checks and AllocationExtra hooks.
298298
// We read the null, so we include it in the request, but we want it removed
299299
// from the result, so we do subslicing.

0 commit comments

Comments
 (0)