Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat committed Aug 14, 2024
1 parent 2b7fdc4 commit fb80d83
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions sdk/stdlib-sys/src/intrinsics/felt.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::transmute_int_to_float)]

use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};

#[link(wasm_import_module = "miden:stdlib/intrinsics_felt")]
Expand Down Expand Up @@ -139,19 +141,19 @@ impl From<Felt> for u64 {

impl From<u32> for Felt {
fn from(value: u32) -> Self {
Self(unsafe { core::mem::transmute(value) })
Self(unsafe { core::mem::transmute::<u32, f32>(value) })
}
}

impl From<u16> for Felt {
fn from(value: u16) -> Self {
Self(unsafe { core::mem::transmute(value as u32) })
Self(unsafe { core::mem::transmute::<u32, f32>(value as u32) })
}
}

impl From<u8> for Felt {
fn from(value: u8) -> Self {
Self(unsafe { core::mem::transmute(value as u32) })
Self(unsafe { core::mem::transmute::<u32, f32>(value as u32) })
}
}

Expand Down
4 changes: 2 additions & 2 deletions sdk/stdlib-sys/src/stdlib/crypto/hashes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn hash_1to1(
input: [u8; 32],
extern_hash_1to1: unsafe extern "C" fn(u32, u32, u32, u32, u32, u32, u32, u32, *mut u8),
) -> [u8; 32] {
let input = unsafe { core::mem::transmute::<_, [u32; 8]>(input) };
let input = unsafe { core::mem::transmute::<[u8; 32], [u32; 8]>(input) };
unsafe {
let mut ret_area = ::core::mem::MaybeUninit::<[u8; 32]>::uninit();
let ptr = ret_area.as_mut_ptr() as *mut u8;
Expand Down Expand Up @@ -137,7 +137,7 @@ fn hash_2to1(
*mut u8,
),
) -> [u8; 32] {
let input = unsafe { core::mem::transmute::<_, [u32; 16]>(input) };
let input = unsafe { core::mem::transmute::<[u8; 64], [u32; 16]>(input) };
unsafe {
let mut ret_area = ::core::mem::MaybeUninit::<[u8; 32]>::uninit();
let ptr = ret_area.as_mut_ptr() as *mut u8;
Expand Down
2 changes: 1 addition & 1 deletion sdk/stdlib-sys/src/stdlib/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub fn pipe_double_words_to_memory(num_words: Felt) -> (Word, Vec<Felt>) {
}

let num_words_in_felts = num_words.as_u64() as usize * 4;
let mut buf: Vec<Felt> = Vec::with_capacity(num_words_in_felts as usize);
let mut buf: Vec<Felt> = Vec::with_capacity(num_words_in_felts);
let write_ptr = buf.as_mut_ptr();
let end_ptr = unsafe { write_ptr.add(num_words_in_felts) };
// Place for returned C, B, A, write_ptr
Expand Down

0 comments on commit fb80d83

Please sign in to comment.