Skip to content

chore: Fix 1.87.0 clippy lints #4746

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

Merged
merged 7 commits into from
May 19, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ pub fn normalize_parsed_queries(
string: &str,
) -> Result<(String, Vec<Statement>), ()> {
let mut parsed = parse_query(db_system, string).map_err(|_| ())?;
parsed.visit(&mut NormalizeVisitor);
parsed.visit(&mut MaxDepthVisitor::new());
let _ = parsed.visit(&mut NormalizeVisitor);
let _ = parsed.visit(&mut MaxDepthVisitor::new());

let concatenated = parsed
.iter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ fn sql_tables_from_query(
let mut visitor = SqlTableNameVisitor {
table_names: Default::default(),
};
ast.visit(&mut visitor);
let _ = ast.visit(&mut visitor);
let comma_size: usize = 1;
let mut s = String::with_capacity(
visitor
Expand Down
4 changes: 4 additions & 0 deletions relay-event-schema/src/processor/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,10 @@ impl<'a> ProcessingState<'a> {
///
/// - Returns `Ok(None)` if the current state is the root.
/// - Returns `Err(self)` if the current state does not own the parent state.
#[expect(
clippy::result_large_err,
reason = "this method returns `self` in the error case"
)]
pub fn try_into_parent(self) -> Result<Option<Self>, Self> {
match self.parent {
Some(BoxCow::Borrowed(_)) => Err(self),
Expand Down
4 changes: 1 addition & 3 deletions relay-metrics/benches/benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ impl NumbersGenerator {

fn next(&self) -> usize {
let dist = Uniform::new(self.min, self.max + 1);
let value = self.generator.borrow_mut().sample(dist);

value
self.generator.borrow_mut().sample(dist)
}
}

Expand Down
5 changes: 2 additions & 3 deletions relay-pii/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,11 +729,10 @@ where
return self.inner.visit_borrowed_str(v);
};

let res = match self.transformer.transform_str(v) {
match self.transformer.transform_str(v) {
Cow::Borrowed(v) => self.inner.visit_borrowed_str(v),
Cow::Owned(v) => self.inner.visit_string(v),
};
res
}
}

fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
Expand Down
2 changes: 1 addition & 1 deletion relay-quotas/src/quota.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl ItemScoping {
// skip `Unknown` categories silently. If the list of categories only contains `Unknown`s,
// we do **not** match, since apparently the quota is meant for some data this Relay does
// not support yet.
categories.is_empty() || categories.iter().any(|cat| *cat == self.category)
categories.is_empty() || categories.contains(&self.category)
}

/// Returns `true` if the rate limit namespace matches the namespace of the item.
Expand Down
23 changes: 10 additions & 13 deletions relay-server/src/services/global_rate_limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl GlobalLimiter for GlobalRateLimitsServiceHandle {
quantity,
})
.await
.map_err(|_| RateLimitingError::UnreachableGlobalRateLimits)?;
.map_err(|_| RateLimitingError::UnreachableGlobalRateLimits)??;

// Perform a reverse lookup to match each owned quota with its original reference.
// If multiple identical quotas exist, the first match will be reused. Equality is determined
Expand All @@ -80,18 +80,15 @@ impl GlobalLimiter for GlobalRateLimitsServiceHandle {
//
// The operation has a time complexity of O(n^2), but the number of quotas is assumed
// to be small, as they are currently used only for metric bucket limiting.
let rate_limited_global_quotas =
rate_limited_owned_global_quotas.map(|owned_global_quotas| {
owned_global_quotas
.iter()
.filter_map(|owned_global_quota| {
let global_quota = owned_global_quota.build_ref();
global_quotas.iter().find(|x| **x == global_quota)
})
.collect::<Vec<_>>()
});

rate_limited_global_quotas

let res = rate_limited_owned_global_quotas
.iter()
.filter_map(|owned_global_quota| {
let global_quota = owned_global_quota.build_ref();
global_quotas.iter().find(|x| **x == global_quota)
})
.collect::<Vec<_>>();
Ok(res)
}
}

Expand Down
8 changes: 7 additions & 1 deletion relay-server/src/services/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ pub enum ProcessingError {
PiiConfigError(PiiConfigError),

#[error("invalid processing group type")]
InvalidProcessingGroup(#[from] InvalidProcessingGroupType),
InvalidProcessingGroup(Box<InvalidProcessingGroupType>),

#[error("invalid replay")]
InvalidReplay(DiscardReason),
Expand Down Expand Up @@ -620,6 +620,12 @@ impl From<ExtractMetricsError> for ProcessingError {
}
}

impl From<InvalidProcessingGroupType> for ProcessingError {
fn from(value: InvalidProcessingGroupType) -> Self {
Self::InvalidProcessingGroup(Box::new(value))
}
}

type ExtractedEvent = (Annotated<Event>, usize);

/// A container for extracted metrics during processing.
Expand Down
6 changes: 2 additions & 4 deletions relay-server/src/services/processor/nnswitch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,8 @@ fn get_zstd_dictionary(id: usize) -> Option<&'static zstd::dict::DecoderDictiona
}

fn decompress_data_zstd(data: Bytes, dictionary_id: u8) -> std::io::Result<Vec<u8>> {
let dictionary = get_zstd_dictionary(dictionary_id as usize).ok_or(std::io::Error::new(
std::io::ErrorKind::Other,
"Unknown compression dictionary",
))?;
let dictionary = get_zstd_dictionary(dictionary_id as usize)
.ok_or(std::io::Error::other("Unknown compression dictionary"))?;

let mut decompressor = ZstdDecompressor::with_prepared_dictionary(dictionary)?;
decompressor.decompress(data.as_ref(), MAX_DECOMPRESSED_SIZE)
Expand Down
Loading