Skip to content

Commit

Permalink
Merge pull request #793 from private-attribution/rust-173
Browse files Browse the repository at this point in the history
Fix new clippy warnings after Rust 1.73 release
  • Loading branch information
akoshelev authored Oct 6, 2023
2 parents 14a6b77 + b28e6d7 commit bb1d517
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/ff/prime_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ macro_rules! field_impl {
proptest! {

#[test]
#[allow(clippy::ignored_unit_patterns)]
fn serde(v in 0..$field::PRIME) {
let field_v = $field(v);
let mut buf = GenericArray::default();
Expand Down
6 changes: 5 additions & 1 deletion src/helpers/buffers/ordering_mpsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ mod fixture {

#[async_trait]
impl TestSender for OrderingMpscSender<Fp32BitPrime> {
// I don't understand what triggers this warning, maybe https://github.com/rust-lang/rust-clippy/issues/11403
#[allow(clippy::ignored_unit_patterns)]
async fn send_test(&self, i: usize) {
self.send(
i,
Expand Down Expand Up @@ -383,7 +385,7 @@ mod unit {
let send = async move {
tx_a.send(0, input).await.unwrap();
};
let (_, output) = join(send, rx.take_next(1)).await;
let ((), output) = join(send, rx.take_next(1)).await;
assert_eq!(
input,
Fp31::deserialize(GenericArray::from_slice(output.as_ref().unwrap()))
Expand Down Expand Up @@ -506,6 +508,7 @@ mod proptests {

proptest::proptest! {
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn arbitrary_size_seq(cap in 2..1000_usize) {
let indices = (0..cap).collect::<Vec<_>>();
tokio::runtime::Builder::new_multi_thread()
Expand All @@ -516,6 +519,7 @@ mod proptests {
}

#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn arbitrary_size_shuffle(indices in shuffled(), excess in 0..10_usize) {
tokio::runtime::Builder::new_multi_thread()
.enable_all()
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/buffers/ordering_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ mod test {
values.resize_with(COUNT, || rng.gen::<Fp32BitPrime>());

let sender = sender();
let (_, _, output) = join3(
let (_, (), output) = join3(
join_all(values.iter().enumerate().map(|(i, &v)| sender.send(i, v))),
sender.close(values.len()),
sender.as_stream().collect::<Vec<_>>(),
Expand Down Expand Up @@ -568,7 +568,7 @@ mod test {
let indices = shuffle_indices(COUNT);

let sender = sender();
let (_, _, output) = join3(
let (_, (), output) = join3(
join_all(indices.into_iter().map(|i| sender.send(i, values[i]))),
sender.close(values.len()),
sender.as_stream().collect::<Vec<_>>(),
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/gateway/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ mod tests {

let world = TestWorld::new_with(config);
world
.semi_honest((), |ctx, _| async move {
.semi_honest((), |ctx, ()| async move {
let fp2_ctx = ctx.narrow("fp2").set_total_records(100);
let fp32_ctx = ctx.narrow("fp32").set_total_records(100);
let role = ctx.role();
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/prss_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub async fn negotiate<T: Transport, R: RngCore + CryptoRng>(
let (send_left_pk, send_right_pk) = ep_setup.public_keys();
let record_id = RecordId::FIRST;

let (_, _, recv_left_pk, recv_right_pk) = try_join4(
let ((), (), recv_left_pk, recv_right_pk) = try_join4(
left_sender.send(record_id, send_left_pk),
right_sender.send(record_id, send_right_pk),
left_receiver.receive(record_id),
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/transport/stream/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ mod test {

proptest::proptest! {
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn test_records_stream_works_with_any_chunks(
(expected_bytes, chunked_bytes, _seed) in arb_expected_and_chunked_body(30, 100)
) {
Expand Down Expand Up @@ -820,6 +821,7 @@ mod test {

proptest::proptest! {
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn test_delimited_stream_works_with_any_chunks(
(expected_items, chunked_bytes, _seed) in arb_expected_and_chunked_body(100)
) {
Expand Down
3 changes: 3 additions & 0 deletions src/hpke/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ mod tests {
proptest::proptest! {
#![proptest_config(ProptestConfig::with_cases(50))]
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn arbitrary_ct_corruption(bad_byte in 0..23_usize, bad_bit in 0..7_usize, seed: [u8; 32]) {
let rng = StdRng::from_seed(seed);
let mut suite = EncryptionSuite::new(1, rng);
Expand All @@ -372,6 +373,7 @@ mod tests {
proptest::proptest! {
#![proptest_config(ProptestConfig::with_cases(50))]
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn arbitrary_enc_corruption(bad_byte in 0..32_usize, bad_bit in 0..7_usize, seed: [u8; 32]) {
let rng = StdRng::from_seed(seed);
let mut suite = EncryptionSuite::new(1, rng);
Expand Down Expand Up @@ -416,6 +418,7 @@ mod tests {
proptest::proptest! {
#![proptest_config(ProptestConfig::with_cases(50))]
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn arbitrary_info_corruption(corrupted_info_field in 1..5,
site_domain in "[a-z]{10}",
helper_origin in "[a-z]{10}",
Expand Down
2 changes: 2 additions & 0 deletions src/protocol/boolean/comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ mod tests {

proptest! {
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn gt_fp31_proptest(a in 0..Fp31::PRIME, c in 0..Fp31::PRIME) {
type F = Fp31;
let r = thread_rng().gen::<F>();
Expand All @@ -566,6 +567,7 @@ mod tests {
}

#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn gt_fp_32bit_prime_proptest(a in 0..Fp32BitPrime::PRIME, c in 0..Fp32BitPrime::PRIME) {
type F = Fp32BitPrime;
let r = thread_rng().gen::<F>();
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/boolean/random_bits_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ mod tests {

for _ in 0..OUTER {
let v = world
.semi_honest((), |ctx, _| async move {
.semi_honest((), |ctx, ()| async move {
let validator = ctx.validator();
let ctx = validator
.context()
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ mod tests {

let send_channel = ctx.send_channel(left_peer);
let recv_channel = ctx.recv_channel::<F>(right_peer);
let (_, right_share) = try_join!(
let ((), right_share) = try_join!(
send_channel.send(record_id, share.l() - l - seq_l),
recv_channel.receive(record_id),
)
Expand Down
1 change: 1 addition & 0 deletions src/protocol/dp/insecure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ mod test {
proptest! {
#![proptest_config(ProptestConfig::with_cases(50))]
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn output_differentially_private(
rng_seed: u64,
epsilon in 1..255_u8,
Expand Down
1 change: 1 addition & 0 deletions src/protocol/ipa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@ pub mod tests {

proptest! {
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn serde(timestamp in 0..u128::MAX, match_key in 0..u64::MAX, trigger_bit in 0..u128::MAX, breakdown_key in 0..u128::MAX, trigger_value in 0..u128::MAX, seed in 0..u128::MAX) {
serde_internal::<Fp31>(timestamp, match_key, trigger_bit, breakdown_key, trigger_value, seed);
serde_internal::<Fp32BitPrime>(timestamp, match_key, trigger_bit, breakdown_key, trigger_value, seed);
Expand Down
10 changes: 2 additions & 8 deletions src/telemetry/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ impl CounterDetails {
};
for label in key.key().labels() {
let (label_key, label_val) = label.clone().into_parts();
let dimension_values = self
.dimensions
.entry(label_key)
.or_insert_with(HashMap::new);
let dimension_values = self.dimensions.entry(label_key).or_default();

*dimension_values.entry(label_val).or_insert(0) += val;
}
Expand Down Expand Up @@ -85,10 +82,7 @@ impl Metrics {
if !filter_fn(labels.as_slice()) {
continue;
}
let entry = this
.counters
.entry(key_name.clone())
.or_insert_with(CounterDetails::default);
let entry = this.counters.entry(key_name.clone()).or_default();

if let Some(descr) = descr {
this.metric_description.insert(key_name, descr);
Expand Down
1 change: 1 addition & 0 deletions src/test_fixture/event_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ mod tests {

proptest! {
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn iter_test(rng_seed: u64, config in arb_config(), total_events in 1_usize..2000) {
does_not_exceed_config_maximums(rng_seed, &config, total_events);
}
Expand Down

0 comments on commit bb1d517

Please sign in to comment.