From 2ac6243e72579daf76180840442b3502f08efbd0 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Wed, 27 Dec 2023 17:46:56 +0100 Subject: [PATCH] partial clippy fixes --- crates/roc_std/src/roc_str.rs | 6 +++--- crates/wasm_module/src/parse.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/roc_std/src/roc_str.rs b/crates/roc_std/src/roc_str.rs index 68e85ee283..3ff02f2649 100644 --- a/crates/roc_std/src/roc_str.rs +++ b/crates/roc_std/src/roc_str.rs @@ -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); diff --git a/crates/wasm_module/src/parse.rs b/crates/wasm_module/src/parse.rs index 753ebe9530..ad21b58b3d 100644 --- a/crates/wasm_module/src/parse.rs +++ b/crates/wasm_module/src/parse.rs @@ -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]