partial clippy fixes

This commit is contained in:
Anton-4 2023-12-27 17:46:56 +01:00
parent 26f0448a94
commit 2ac6243e72
No known key found for this signature in database
GPG Key ID: 0971D718C0A9B937
2 changed files with 6 additions and 6 deletions

View File

@ -361,7 +361,7 @@ impl RocStr {
let ptr = if len < big_string.capacity() {
// We happen to have excess capacity already, so we will be able
// to write the terminator into the first byte of excess capacity.
big_string.ptr_to_first_elem() as *mut u8
big_string.ptr_to_first_elem()
} else {
// We always have an allocation that's even bigger than necessary,
// because the refcount bytes take up more than the 1B needed for
@ -376,7 +376,7 @@ impl RocStr {
//
// IMPORTANT: Must use ptr::copy instead of ptr::copy_nonoverlapping
// because the regions definitely overlap!
ptr::copy(big_string.ptr_to_first_elem() as *mut u8, alloc_ptr, len);
ptr::copy(big_string.ptr_to_first_elem(), alloc_ptr, len);
alloc_ptr
};
@ -388,7 +388,7 @@ impl RocStr {
// The backing list was not unique, so we can't mutate it in-place.
// ask for `len + 1` to store the original string and the terminator
with_stack_bytes(len + 1, |alloc_ptr: *mut u8| {
let elem_ptr = big_string.ptr_to_first_elem() as *mut u8;
let elem_ptr = big_string.ptr_to_first_elem();
// memcpy the bytes into the stack allocation
std::ptr::copy_nonoverlapping(elem_ptr, alloc_ptr, len);

View File

@ -255,9 +255,9 @@ mod tests {
decode_u32(&[0xff, 0xff, 0xff, 0xff, 0x0f]),
Ok((u32::MAX, MAX_SIZE_ENCODED_U32))
);
assert!(matches!(decode_u32(&[0x80; 6]), Err(_)));
assert!(matches!(decode_u32(&[0x80; 2]), Err(_)));
assert!(matches!(decode_u32(&[]), Err(_)));
assert!(decode_u32(&[0x80; 6]).is_err());
assert!(decode_u32(&[0x80; 2]).is_err());
assert!(decode_u32(&[]).is_err());
}
#[test]