mirror of
https://github.com/roc-lang/roc.git
synced 2024-07-14 22:00:24 +03:00
partial clippy fixes
This commit is contained in:
parent
26f0448a94
commit
2ac6243e72
@ -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);
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user