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

Remove match infallible {} workaround #702

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion crates/dapf/src/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct HttpClient {
inner: HttpClientInner,
}

#[allow(clippy::large_enum_variant)]
#[expect(clippy::large_enum_variant)]
enum HttpClientInner {
/// Never reuse the same reqwest client for two different http requests. Usefull for specific
/// debugging or load testing scenarios.
Expand Down
2 changes: 1 addition & 1 deletion crates/dapf/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ enum HpkeAction {
}

#[derive(Debug, Subcommand)]
#[allow(clippy::large_enum_variant)]
#[expect(clippy::large_enum_variant)]
enum TestAction {
/// Add an hpke config to a test-utils enabled `daphne-server`.
AddHpkeConfig {
Expand Down
2 changes: 1 addition & 1 deletion crates/daphne-server/docker/example-service.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2024 Cloudflare, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause

FROM rust:1.80.1-bookworm AS builder
FROM rust:1.82-bookworm AS builder

RUN apt update && \
apt install -y \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl Cache {
);
}

#[allow(dead_code)]
#[expect(dead_code)]
pub fn delete<P>(&mut self, key: &str) -> CacheResult<P::Value>
where
P: KvPrefix,
Expand Down
4 changes: 2 additions & 2 deletions crates/daphne-server/src/storage_proxy_connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<'h> Do<'h> {
}
}

#[allow(dead_code)]
#[expect(dead_code)]
pub fn with_retry(self) -> Self {
Self {
retry: true,
Expand Down Expand Up @@ -126,7 +126,7 @@ impl<'w> Do<'w> {
}
}

#[allow(dead_code)]
#[expect(dead_code)]
pub fn request_with_id<B: DurableMethod + Copy>(
&self,
path: B,
Expand Down
2 changes: 1 addition & 1 deletion crates/daphne-server/tests/e2e/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ async fn leader_collect_taskprov_ok(version: DapVersion) {
.poll_collection_url_using_token(client, &collect_uri, DAP_TASKPROV_COLLECTOR_TOKEN)
.await
.unwrap();
#[allow(clippy::format_in_format_args)]
#[expect(clippy::format_in_format_args)]
{
assert_eq!(
resp.status(),
Expand Down
6 changes: 3 additions & 3 deletions crates/daphne-server/tests/e2e/test_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ impl TestRunner {
get_raw_hpke_config(client, self.task_id.as_ref(), &self.helper_url, "helper").await
}

#[allow(dead_code)]
#[expect(dead_code)]
pub async fn leader_post_expect_ok(
&self,
client: &reqwest::Client,
Expand Down Expand Up @@ -401,7 +401,7 @@ impl TestRunner {
Ok(())
}

#[allow(dead_code, clippy::too_many_arguments)]
#[expect(dead_code, clippy::too_many_arguments)]
pub async fn leader_post_expect_abort(
&self,
client: &reqwest::Client,
Expand Down Expand Up @@ -515,7 +515,7 @@ impl TestRunner {
Ok(())
}

#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
pub async fn leader_put_expect_abort(
&self,
client: &reqwest::Client,
Expand Down
2 changes: 1 addition & 1 deletion crates/daphne-worker-test/docker/runtests.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2024 Cloudflare, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause

FROM rust:1.80.1-bookworm
FROM rust:1.82-bookworm

WORKDIR /tmp/dap_test

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2024 Cloudflare, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause

FROM rust:1.80.1-bookworm AS builder
FROM rust:1.82-bookworm AS builder
RUN apt update && apt install -y capnproto clang cmake

# Pre-install worker-build and Rust's wasm32 target to speed up our custom build command
Expand Down
7 changes: 3 additions & 4 deletions crates/daphne-worker/src/durable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ macro_rules! mk_durable_object {
#[doc(hidden)]
pub async fn fetch(
&mut self,
#[allow(unused_mut)] mut req: ::worker::Request
#[cfg(feature = "test-utils")] mut req: ::worker::Request,
#[cfg(not(feature = "test-utils"))] req: ::worker::Request,
) -> ::worker::Result<::worker::Response> {
use $crate::durable::{create_span_from_request, GcDurableObject};
use ::tracing::Instrument;
Expand Down Expand Up @@ -135,23 +136,21 @@ macro_rules! mk_durable_object {
&self.env
}

#[allow(dead_code)]
async fn get<T>(&self, key: &str) -> ::worker::Result<Option<T>>
where
T: ::serde::de::DeserializeOwned,
{
$crate::durable::state_get(&self.state, key).await
}

#[allow(dead_code)]
async fn get_or_default<T>(&self, key: &str) -> ::worker::Result<T>
where
T: ::serde::de::DeserializeOwned + std::default::Default,
{
$crate::durable::state_get_or_default(&self.state, key).await
}

#[allow(dead_code)]
#[expect(dead_code)]
async fn set_if_not_exists<T>(&self, key: &str, val: &T) -> ::worker::Result<Option<T>>
where
T: ::serde::de::DeserializeOwned + ::serde::Serialize,
Expand Down
1 change: 0 additions & 1 deletion crates/daphne-worker/src/durable/test_state_cleaner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use super::GcDurableObject;
/// Durable Object (DO) for keeping track of all persistent DO storage.
#[durable_object]
pub struct TestStateCleaner {
#[allow(dead_code)]
state: State,
env: Env,
}
Expand Down
16 changes: 4 additions & 12 deletions crates/daphne-worker/src/storage_proxy/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ pub async fn bearer_auth(
return (StatusCode::UNAUTHORIZED, "Incorrect authorization token").into_response();
}

match next.call(request.map(axum::body::Body::new)).await {
Ok(r) => r,
Err(infalible) => match infalible {},
}
let Ok(response) = next.call(request.map(axum::body::Body::new)).await;
response
}

#[worker::send]
Expand All @@ -62,10 +60,7 @@ pub async fn time_kv_requests(
mut next: Next,
) -> axum::response::Response {
let start = worker::Date::now();
let response = match next.call(request).await {
Ok(response) => response,
Err(infallible) => match infallible {},
};
let Ok(response) = next.call(request).await;
let elapsed = elapsed(&start);

let op = match method {
Expand Down Expand Up @@ -97,10 +92,7 @@ pub async fn time_do_requests(
mut next: Next,
) -> axum::response::Response {
let start = worker::Date::now();
let response = match next.call(request).await {
Ok(response) => response,
Err(infallible) => match infallible {},
};
let Ok(response) = next.call(request).await;
let elapsed = elapsed(&start);
ctx.metrics.durable_request_time_seconds_observe(
&uri,
Expand Down
2 changes: 1 addition & 1 deletion crates/daphne/benches/pine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use prio::{

fn pine(c: &mut Criterion) {
// NOTE We ignore this clippy warning because we may want to benchmark more parameters later.
#[allow(clippy::single_element_loop)]
#[expect(clippy::single_element_loop)]
for (dimension, chunk_len, chunk_len_sq_norm_equal) in [(200_000, 150 * 2, 447 * 18)] {
let pine =
Pine::new_64(1 << 15, dimension, 15, chunk_len, chunk_len_sq_norm_equal).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions crates/daphne/benches/vdaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use prio::{
fn count_vec(c: &mut Criterion) {
for dimension in [100, 1_000, 10_000, 100_000] {
let nonce = [0; 16];
#[allow(clippy::cast_possible_truncation)]
#[allow(clippy::cast_sign_loss)]
#[expect(clippy::cast_possible_truncation)]
#[expect(clippy::cast_sign_loss)]
let chunk_length = (dimension as f64).sqrt() as usize; // asymptotically optimal

// Prio2
Expand Down
1 change: 0 additions & 1 deletion crates/daphne/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ pub struct DapTaskParameters {
impl DapTaskParameters {
/// Construct a new task config using the taskprov extension. Return the task ID and the
/// taskprov advertisement encoded as a base64url string.
#[allow(clippy::type_complexity)]
pub fn to_config_with_taskprov(
&self,
task_info: Vec<u8>,
Expand Down
2 changes: 0 additions & 2 deletions crates/daphne/src/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ impl ParameterizedDecode<DapVersion> for Extension {

/// Report metadata.
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
#[allow(missing_docs)]
#[cfg_attr(any(test, feature = "test-utils"), derive(deepsize::DeepSizeOf))]
pub struct ReportMetadata {
pub id: ReportId,
Expand Down Expand Up @@ -1056,7 +1055,6 @@ impl Decode for HpkeCiphertext {

/// A plaintext input share.
#[derive(Clone, Debug, PartialEq, Eq)]
#[allow(missing_docs)]
pub struct PlaintextInputShare {
pub extensions: Vec<Extension>,
pub payload: Vec<u8>,
Expand Down
5 changes: 0 additions & 5 deletions crates/daphne/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ pub mod prometheus {
/// Register Daphne metrics with the specified registry. If a prefix is provided, then
/// "{prefix_}" is prepended to the name.
pub fn register(registry: &Registry) -> Result<Self, DapError> {
#[allow(clippy::ignored_unit_patterns)]
let inbound_request_counter = register_int_counter_vec_with_registry!(
"inbound_request_counter",
"Total number of successful inbound requests.",
Expand All @@ -93,7 +92,6 @@ pub mod prometheus {
)
.map_err(|e| fatal_error!(err = ?e, "failed to regsiter inbound_request_counter"))?;

#[allow(clippy::ignored_unit_patterns)]
let report_counter = register_int_counter_vec_with_registry!(
"report_counter",
"Total number reports rejected, aggregated, and collected.",
Expand All @@ -102,7 +100,6 @@ pub mod prometheus {
)
.map_err(|e| fatal_error!(err = ?e, "failed to register report_counter"))?;

#[allow(clippy::ignored_unit_patterns)]
let aggregation_job_batch_size_histogram = register_histogram_with_registry!(
"aggregation_job_batch_size",
"Number of records in an incoming AggregationJobInitReq.",
Expand All @@ -113,7 +110,6 @@ pub mod prometheus {
)
.map_err(|e| fatal_error!(err = ?e, "failed to register aggregation_job_batch_size"))?;

#[allow(clippy::ignored_unit_patterns)]
let aggregation_job_counter = register_int_counter_vec_with_registry!(
format!("aggregation_job_counter"),
"Total number of aggregation jobs started and completed.",
Expand All @@ -122,7 +118,6 @@ pub mod prometheus {
)
.map_err(|e| fatal_error!(err = ?e, "failed to register aggregation_job_counter"))?;

#[allow(clippy::ignored_unit_patterns)]
let aggregation_job_put_span_retry_counter =
register_int_counter_with_registry!(
format!("aggregation_job_put_span_retry_counter"),
Expand Down
14 changes: 7 additions & 7 deletions crates/daphne/src/pine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ impl<F: FftFriendlyFieldElement, X, const SEED_SIZE: usize> Pine<F, X, SEED_SIZE
};

let (wr_test_bound, wr_test_bits) = {
#[allow(clippy::cast_possible_truncation)]
#[allow(clippy::cast_sign_loss)]
#[expect(clippy::cast_possible_truncation)]
#[expect(clippy::cast_sign_loss)]
let wr_test_bound_int =
(((param.norm_bound as f64) * ALPHA).ceil() as u64 + 1).next_power_of_two();
let wr_test_bits = bits(2 * wr_test_bound_int - 1);
Expand Down Expand Up @@ -308,8 +308,8 @@ fn f64_to_field<F: FftFriendlyFieldElement>(x: f64, two_to_frac_bits: f64) -> Re
let out = x * two_to_frac_bits;
let out = out.floor();
let out = if neg { -out } else { out };
#[allow(clippy::cast_possible_truncation)]
#[allow(clippy::cast_sign_loss)]
#[expect(clippy::cast_possible_truncation)]
#[expect(clippy::cast_sign_loss)]
let out = out as u64;
let out = usize::try_from(out).map_err(|e| {
VdafError::Uncategorized(format!(
Expand Down Expand Up @@ -375,8 +375,8 @@ fn norm_bound_f64_to_u64(norm_bound: f64, frac_bits: usize) -> u64 {
let two_to_frac_bits = f64::from(1 << frac_bits);
let norm_bound = norm_bound * two_to_frac_bits;
let norm_bound = norm_bound.floor();
#[allow(clippy::cast_sign_loss)]
#[allow(clippy::cast_possible_truncation)]
#[expect(clippy::cast_sign_loss)]
#[expect(clippy::cast_possible_truncation)]
let norm_bound = norm_bound as u64;
norm_bound
}
Expand Down Expand Up @@ -527,7 +527,7 @@ mod tests {
},
] {
// clippy: We expect the values to match precisely.
#[allow(clippy::float_cmp)]
#[expect(clippy::float_cmp)]
{
assert_eq!(
field_to_f64(
Expand Down
2 changes: 1 addition & 1 deletion crates/daphne/src/pine/test_vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl TestVec {
// Check that the test vector parameters have the values we expect.
//
// clippy: These are test vectors, so we expect the value to match precisely.
#[allow(clippy::float_cmp)]
#[expect(clippy::float_cmp)]
{
assert_eq!(self.alpha, ALPHA);
}
Expand Down
8 changes: 4 additions & 4 deletions crates/daphne/src/protocol/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl EarlyReportState for EarlyReportStateConsumed {
}

/// Report state during aggregation initialization after the VDAF preparation step.
#[allow(clippy::large_enum_variant)]
#[expect(clippy::large_enum_variant)]
#[derive(Clone)]
#[cfg_attr(any(test, feature = "test-utils"), derive(deepsize::DeepSizeOf))]
pub enum EarlyReportStateInitialized {
Expand Down Expand Up @@ -400,7 +400,7 @@ impl ReplayProtection {
impl DapTaskConfig {
/// Leader -> Helper: Initialize the aggregation flow for a sequence of reports. The outputs are the Leader's
/// state for the aggregation flow and the outbound `AggregationJobInitReq` message.
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
pub async fn produce_agg_job_req<S>(
&self,
decrypter: impl HpkeDecrypter,
Expand All @@ -427,7 +427,7 @@ impl DapTaskConfig {
.await
}

#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
async fn produce_agg_job_req_impl<S>(
&self,
decrypter: impl HpkeDecrypter,
Expand Down Expand Up @@ -547,7 +547,7 @@ impl DapTaskConfig {
))
}

#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
#[cfg(any(test, feature = "test-utils"))]
pub async fn test_produce_agg_job_req<S>(
&self,
Expand Down
2 changes: 1 addition & 1 deletion crates/daphne/src/protocol/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl VdafConfig {
}

/// Generate a report for the given public and input shares with the given extensions.
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
pub(crate) fn produce_report_with_extensions_for_shares(
public_share: Vec<u8>,
input_shares: [Vec<u8>; 2],
Expand Down
2 changes: 1 addition & 1 deletion crates/daphne/src/protocol/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl VdafConfig {
/// Aggregators. The first encrypted aggregate shares must be the Leader's.
///
/// * `version` is the `DapVersion` to use.
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
pub fn consume_encrypted_agg_shares(
&self,
decrypter: &impl HpkeDecrypter,
Expand Down
1 change: 0 additions & 1 deletion crates/daphne/src/taskprov.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use serde::{Deserialize, Serialize};
use url::Url;

/// SHA-256 of "dap-taskprov"
#[allow(dead_code)]
pub(crate) const TASKPROV_SALT: [u8; 32] = [
0x28, 0xb9, 0xbb, 0x4f, 0x62, 0x4f, 0x67, 0x9a, 0xc1, 0x98, 0xd9, 0x68, 0xf4, 0xb0, 0x9e, 0xec,
0x74, 0x01, 0x7a, 0x52, 0xcb, 0x4c, 0xf6, 0x39, 0xfb, 0x83, 0xe0, 0x47, 0x72, 0x3a, 0x0f, 0xfe,
Expand Down
Loading
Loading