Skip to content

Commit 36fb820

Browse files
committed
chore: fix new lints
1 parent 1242657 commit 36fb820

File tree

8 files changed

+20
-25
lines changed

8 files changed

+20
-25
lines changed

tfhe-csprng/src/seeders/implem/rdseed.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ unsafe fn rdseed_random_m128() -> u128 {
3838
let mut rand1: u64 = 0;
3939
let mut rand2: u64 = 0;
4040
let mut output_bytes = [0u8; 16];
41-
unsafe {
42-
loop {
43-
if core::arch::x86_64::_rdseed64_step(&mut rand1) == 1 {
44-
break;
45-
}
41+
42+
loop {
43+
if core::arch::x86_64::_rdseed64_step(&mut rand1) == 1 {
44+
break;
4645
}
47-
loop {
48-
if core::arch::x86_64::_rdseed64_step(&mut rand2) == 1 {
49-
break;
50-
}
46+
}
47+
loop {
48+
if core::arch::x86_64::_rdseed64_step(&mut rand2) == 1 {
49+
break;
5150
}
5251
}
52+
5353
output_bytes[0..8].copy_from_slice(&rand1.to_ne_bytes());
5454
output_bytes[8..16].copy_from_slice(&rand2.to_ne_bytes());
5555
u128::from_ne_bytes(output_bytes)

tfhe/src/core_crypto/keycache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ pub fn generate_keys() {
229229

230230
println!("Generating keys for core_crypto");
231231

232-
let classical_u32_params = vec![DUMMY_31_U32, DUMMY_NATIVE_U32];
232+
let classical_u32_params = [DUMMY_31_U32, DUMMY_NATIVE_U32];
233233
for param in classical_u32_params.iter().copied() {
234234
let mut keys_gen = |_| lwe_programmable_bootstrapping::generate_keys(param, &mut rsc);
235235
generate_and_store(param, &mut keys_gen);

tfhe/src/high_level_api/upgrade.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl UpgradeGraph {
115115

116116
fn get_or_insert_node(&mut self, node: Node) -> NodeId {
117117
self.index_of_node(&node)
118-
.map_or_else(|| self.add_node(node), |index| index)
118+
.unwrap_or_else(|| self.add_node(node))
119119
}
120120

121121
fn add_node(&mut self, node: Node) -> NodeId {

tfhe/src/integer/bigint/algorithms.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,7 @@ pub(crate) fn shr_assign(lhs: &mut [u64], shift: u32, shift_type: ShiftType) {
337337
let value_mask = u64::MAX >> shift_in_words;
338338
let carry_mask = ((1u64 << shift_in_words) - 1u64).rotate_right(shift_in_words);
339339

340-
let mut carry = if sign_bit == 1 {
341-
u64::MAX & carry_mask
342-
} else {
343-
0
344-
};
340+
let mut carry = if sign_bit == 1 { carry_mask } else { 0 };
345341
for word in &mut head.iter_mut().rev() {
346342
let rotated = word.rotate_right(shift_in_words);
347343
let value = (rotated & value_mask) | carry;

tfhe/src/integer/bigint/u256.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ mod tests {
257257
}
258258

259259
#[test]
260+
#[allow(clippy::identity_op)]
260261
fn test_shr_limits() {
261262
assert_eq!(U256::MAX >> 256u32, U256::MAX >> (256 % U256::BITS));
262263
assert_eq!(U256::MAX >> 257u32, U256::MAX >> (257 % U256::BITS));

tfhe/src/integer/bigint/u512.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ mod tests {
137137
}
138138

139139
#[test]
140+
#[allow(clippy::identity_op)]
140141
fn test_shr_limits() {
141142
assert_eq!(U512::MAX >> 512u32, U512::MAX >> (512u32 % U512::BITS));
142143
assert_eq!(U512::MAX >> 513u32, U512::MAX >> (513u32 % U512::BITS));

tfhe/src/keycache/mod.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,11 @@ pub mod utils {
226226
// we check if we can load the key from persistent storage
227227
let persistent_storage = &self.persistent_storage;
228228
let maybe_key = persistent_storage.load(param);
229-
maybe_key.map_or_else(
230-
|| {
231-
let key = key_gen_closure(param);
232-
persistent_storage.store(param, &key);
233-
key
234-
},
235-
|key| key,
236-
)
229+
maybe_key.unwrap_or_else(|| {
230+
let key = key_gen_closure(param);
231+
persistent_storage.store(param, &key);
232+
key
233+
})
237234
};
238235

239236
let try_load_from_memory_and_init = || -> Result<_, ()> {

tfhe/src/shortint/key_switching_key/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ impl<'keys> KeySwitchingKeyView<'keys> {
813813
let output_ciphertext_count = functions.map_or_else(|| 1, |x| x.len());
814814

815815
let identity_fn_array: &[&(dyn Fn(u64) -> u64 + Sync)] = &[&|x: u64| x];
816-
let functions_to_use = functions.map_or_else(|| identity_fn_array, |fns| fns);
816+
let functions_to_use = functions.unwrap_or(identity_fn_array);
817817
let using_user_provided_functions = functions.is_some();
818818
let using_identity_lut = !using_user_provided_functions;
819819
let mut output_cts = vec![self.dest_server_key.create_trivial(0); output_ciphertext_count];

0 commit comments

Comments
 (0)