Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy lints #105

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion garble/mpz-garble-core/src/encoding/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ impl Encoder for ChaChaEncoder {

#[cfg(test)]
mod test {
use crate::encoding::{state, EncodedValue};
use std::marker::PhantomData;

use super::*;
Expand Down
11 changes: 4 additions & 7 deletions garble/mpz-garble-core/src/encoding/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,13 +780,12 @@ define_encoding_commitment_variant!(U128Commitment, U128, 128);
#[cfg(test)]
mod tests {
use crate::{ChaChaEncoder, Encoder};
use mpz_circuits::types::StaticValueType;

use std::marker::PhantomData;

use rand::{
distributions::{Distribution, Standard},
Rng, SeedableRng,
SeedableRng,
};
use rand_chacha::ChaCha12Rng;
use rstest::*;
Expand All @@ -811,12 +810,10 @@ mod tests {
#[case::u32_array(PhantomData::<[u32; 16]>)]
#[case::u64_array(PhantomData::<[u64; 16]>)]
#[case::u128_array(PhantomData::<[u128; 16]>)]
fn test_encoding<T: StaticValueType + Default>(
encoder: ChaChaEncoder,
#[case] _pd: PhantomData<T>,
) where
fn test_encoding<T>(encoder: ChaChaEncoder, #[case] _pd: PhantomData<T>)
where
Standard: Distribution<T>,
T: Into<Value> + Copy,
T: StaticValueType + Default + Into<Value> + Copy,
{
let mut rng = ChaCha12Rng::from_seed([0u8; 32]);

Expand Down
2 changes: 1 addition & 1 deletion garble/mpz-garble/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ mod tests {

use super::*;

use mpz_circuits::types::{StaticValueType, ValueType};
use mpz_circuits::types::StaticValueType;
use mpz_garble_core::{encoding_state, ChaChaEncoder, Encoder};
use rstest::*;

Expand Down
5 changes: 1 addition & 4 deletions matrix-transpose/benches/transpose.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#![allow(clippy::all)]

use criterion::{criterion_group, criterion_main, Criterion};
use rand::{
distributions::{Distribution, Standard},
prelude::*,
};
use rand::{distributions::Standard, prelude::*};

fn random_vec<T>(elements: usize) -> Vec<T>
where
Expand Down
8 changes: 4 additions & 4 deletions matrix-transpose/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ pub enum TransposeError {
#[cfg(test)]
mod tests {
use super::*;
use rand::{
distributions::{Distribution, Standard},
prelude::*,
};
use rand::{distributions::Standard, prelude::*};

fn random_vec<T>(elements: usize) -> Vec<T>
where
Expand All @@ -96,7 +93,10 @@ mod tests {
let row_count = bits.len();

let mut bits_: Vec<Vec<bool>> = vec![vec![false; row_count]; col_count];

#[allow(clippy::needless_range_loop)]
for j in 0..row_count {
#[allow(clippy::needless_range_loop)]
for i in 0..col_count {
bits_[i][j] = bits[j][i];
}
Expand Down
3 changes: 3 additions & 0 deletions mpz-core/benches/lpn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ fn criterion_benchmark(c: &mut Criterion) {
prg.random_blocks(&mut x);
prg.random_blocks(&mut y);
bench.iter(|| {
#[allow(clippy::unit_arg)]
black_box(lpn.compute(&mut y, &x));
});
});
Expand All @@ -29,6 +30,7 @@ fn criterion_benchmark(c: &mut Criterion) {
prg.random_blocks(&mut x);
prg.random_blocks(&mut y);
bench.iter(|| {
#[allow(clippy::unit_arg)]
black_box(lpn.compute(&mut y, &x));
});
});
Expand All @@ -44,6 +46,7 @@ fn criterion_benchmark(c: &mut Criterion) {
prg.random_blocks(&mut x);
prg.random_blocks(&mut y);
bench.iter(|| {
#[allow(clippy::unit_arg)]
black_box(lpn.compute(&mut y, &x));
});
});
Expand Down
1 change: 0 additions & 1 deletion mpz-core/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use generic_array::{typenum::consts::U16, GenericArray};
use itybity::{BitIterable, BitLength, GetBit, Lsb0, Msb0};
use rand::{distributions::Standard, prelude::Distribution, CryptoRng, Rng};
use serde::{Deserialize, Serialize};
use std::convert::From;

/// A block of 128 bits
#[repr(transparent)]
Expand Down
1 change: 0 additions & 1 deletion ot/mpz-ot-core/src/kos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ mod tests {

use rand::Rng;
use rand_chacha::ChaCha12Rng;
use rand_core::SeedableRng;

#[fixture]
fn choices() -> Vec<bool> {
Expand Down
5 changes: 1 addition & 4 deletions ot/mpz-ot/src/actor/kos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ mod tests {
use msgs::Message;

use super::*;
use futures::{
stream::{SplitSink, SplitStream},
StreamExt,
};
use futures::stream::{SplitSink, SplitStream};
use rstest::*;

use mpz_core::Block;
Expand Down
3 changes: 1 addition & 2 deletions ot/mpz-ot/src/kos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ pub(crate) fn into_base_stream<'a, St: IoStream<msgs::Message<T>> + Send + Unpin
#[cfg(test)]
mod tests {
use super::*;
use futures_util::StreamExt;
use rstest::*;

use itybity::ToBits;
Expand All @@ -59,7 +58,7 @@ mod tests {
use rand::Rng;
use rand_chacha::ChaCha12Rng;
use rand_core::SeedableRng;
use utils_aio::{duplex::MemoryDuplex, sink::IoSink, stream::IoStream};
use utils_aio::duplex::MemoryDuplex;

use crate::{
ideal::{ideal_ot_pair, IdealOTReceiver, IdealOTSender},
Expand Down
5 changes: 2 additions & 3 deletions share-conversion/mpz-share-conversion-core/src/fields/p256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,8 @@ mod tests {

use super::*;

use crate::fields::{
tests::{test_field_basic, test_field_bit_ops, test_field_compute_product_repeated},
Field,
use crate::fields::tests::{
test_field_basic, test_field_bit_ops, test_field_compute_product_repeated,
};

#[test]
Expand Down
4 changes: 1 addition & 3 deletions share-conversion/mpz-share-conversion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,9 @@ mod tests {

use std::marker::PhantomData;

use crate::config::{ReceiverConfig, SenderConfig};

use mpz_ot::ideal::{ideal_ot_shared_pair, IdealSharedOTReceiver, IdealSharedOTSender};
use mpz_share_conversion_core::{
fields::{gf2_128::Gf2_128, p256::P256, Field},
fields::{gf2_128::Gf2_128, p256::P256},
ShareType,
};
use rand::SeedableRng;
Expand Down
Loading