diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs index 5440aef6fe6..cd4c7c71ccd 100644 --- a/src/librustc/mir/interpret/allocation.rs +++ b/src/librustc/mir/interpret/allocation.rs @@ -293,7 +293,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra> Allocation { let offset = usize::try_from(ptr.offset.bytes()).unwrap(); Ok(match self.bytes[offset..].iter().position(|&c| c == 0) { Some(size) => { - let size_with_null = Size::from_bytes(size.checked_add(1).unwrap()); + let size_with_null = Size::add(Size::from_bytes(size), Size::from_bytes(1)); // Go through `get_bytes` for checks and AllocationExtra hooks. // We read the null, so we include it in the request, but we want it removed // from the result, so we do subslicing.