Skip to content

chore: Fix 1.88.0 clippy lints #4872

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 2 commits into from
Jun 27, 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
8 changes: 2 additions & 6 deletions relay-cabi/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,7 @@ impl From<Uuid> for RelayUuid {
#[unsafe(no_mangle)]
#[relay_ffi::catch_unwind]
pub unsafe extern "C" fn relay_uuid_is_nil(uuid: *const RelayUuid) -> bool {
if let Ok(uuid) = Uuid::from_slice(unsafe { &(*uuid).data[..] }) {
uuid == Uuid::nil()
} else {
false
}
Uuid::from_bytes(unsafe { (*uuid).data }) == Uuid::nil()
}

/// Formats the UUID into a string.
Expand All @@ -149,7 +145,7 @@ pub unsafe extern "C" fn relay_uuid_is_nil(uuid: *const RelayUuid) -> bool {
#[unsafe(no_mangle)]
#[relay_ffi::catch_unwind]
pub unsafe extern "C" fn relay_uuid_to_str(uuid: *const RelayUuid) -> RelayStr {
let uuid = Uuid::from_slice(unsafe { &(*uuid).data[..] }).unwrap_or_else(|_| Uuid::nil());
let uuid = Uuid::from_bytes(unsafe { (*uuid).data });
RelayStr::from_string(uuid.as_hyphenated().to_string())
}

Expand Down
2 changes: 1 addition & 1 deletion relay-config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,7 @@ impl Config {
}

let file_name = path.file_name().and_then(|f| f.to_str())?;
let new_file_name = format!("{}.{}", file_name, partition_id);
let new_file_name = format!("{file_name}.{partition_id}");
path.set_file_name(new_file_name);

Some(path)
Expand Down
6 changes: 3 additions & 3 deletions relay-event-normalization/src/normalize/contexts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fn normalize_runtime_context(runtime: &mut RuntimeContext) {
// The equivalent calculation is done in `sentry` in `src/sentry/interfaces/contexts.py`.
if runtime.runtime.value().is_none() {
if let (Some(name), Some(version)) = (runtime.name.value(), runtime.version.value()) {
runtime.runtime = Annotated::from(format!("{} {}", name, version));
runtime.runtime = Annotated::from(format!("{name} {version}"));
}
}
}
Expand Down Expand Up @@ -270,7 +270,7 @@ fn compute_os_context(os: &mut OsContext) {
// The equivalent calculation is done in `sentry` in `src/sentry/interfaces/contexts.py`.
if os.os.value().is_none() {
if let (Some(name), Some(version)) = (os.name.value(), os.version.value()) {
os.os = Annotated::from(format!("{} {}", name, version));
os.os = Annotated::from(format!("{name} {version}"));
}
}
}
Expand All @@ -280,7 +280,7 @@ fn normalize_browser_context(browser: &mut BrowserContext) {
// The equivalent calculation is done in `sentry` in `src/sentry/interfaces/contexts.py`.
if browser.browser.value().is_none() {
if let (Some(name), Some(version)) = (browser.name.value(), browser.version.value()) {
browser.browser = Annotated::from(format!("{} {}", name, version));
browser.browser = Annotated::from(format!("{name} {version}"));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1415,15 +1415,14 @@ mod tests {
for (url, allowed_hosts, expected) in examples {
let json = format!(
r#"{{
"description": "POST {}",
"description": "POST {url}",
"span_id": "bd2eb23da2beb459",
"start_timestamp": 1597976393.4619668,
"timestamp": 1597976393.4718769,
"trace_id": "ff62a8b040f340bda5d830223def1d81",
"op": "http.client"
}}
"#,
url,
);

let mut span = Annotated::<Span>::from_json(&json).unwrap();
Expand All @@ -1433,7 +1432,7 @@ mod tests {

assert_eq!(
scrubbed.0.as_deref(),
Some(format!("POST {}", expected).as_str()),
Some(format!("POST {expected}").as_str()),
"Could not match {url}"
);
}
Expand Down
9 changes: 3 additions & 6 deletions relay-event-normalization/src/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,15 @@ impl Processor for TimestampProcessor {
if let Some(start_timestamp) = span.start_timestamp.value() {
if start_timestamp.into_inner().timestamp_millis() < 0 {
meta.add_error(Error::invalid(format!(
"start_timestamp is too stale: {}",
start_timestamp
"start_timestamp is too stale: {start_timestamp}"
)));
return Err(ProcessingAction::DeleteValueHard);
}
}
if let Some(end_timestamp) = span.timestamp.value() {
if end_timestamp.into_inner().timestamp_millis() < 0 {
meta.add_error(Error::invalid(format!(
"timestamp is too stale: {}",
end_timestamp
"timestamp is too stale: {end_timestamp}"
)));
return Err(ProcessingAction::DeleteValueHard);
}
Expand All @@ -81,8 +79,7 @@ impl Processor for TimestampProcessor {
if let Some(timestamp) = breadcrumb.timestamp.value() {
if timestamp.into_inner().timestamp_millis() < 0 {
meta.add_error(Error::invalid(format!(
"timestamp is too stale: {}",
timestamp
"timestamp is too stale: {timestamp}"
)));
return Err(ProcessingAction::DeleteValueHard);
}
Expand Down
4 changes: 2 additions & 2 deletions relay-event-schema/src/protocol/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ impl Empty for ThreadId {
impl fmt::Display for ThreadId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ThreadId::Int(id) => write!(f, "{}", id),
ThreadId::String(id) => write!(f, "{}", id),
ThreadId::Int(id) => write!(f, "{id}"),
ThreadId::String(id) => write!(f, "{id}"),
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions relay-filter/src/transaction_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ mod tests {
assert_eq!(
filter_result,
Ok(()),
"Event filtered for event_type={} although filter should have not matched",
event_type
"Event filtered for event_type={event_type} although filter should have not matched"
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion relay-log/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Level {

impl Display for Level {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", format!("{:?}", self).to_lowercase())
write!(f, "{}", format!("{self:?}").to_lowercase())
}
}

Expand Down
4 changes: 2 additions & 2 deletions relay-profiling/src/sample/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ mod tests {
fn test_roundtrip() {
let first_payload = include_bytes!("../../tests/fixtures/sample/v2/valid.json");
let first_parse = parse(first_payload);
assert!(first_parse.is_ok(), "{:#?}", first_parse);
assert!(first_parse.is_ok(), "{first_parse:#?}");
let second_payload = serde_json::to_vec(&first_parse.unwrap()).unwrap();
let second_parse = parse(&second_payload[..]);
assert!(second_parse.is_ok(), "{:#?}", second_parse);
assert!(second_parse.is_ok(), "{second_parse:#?}");
}

#[test]
Expand Down
9 changes: 3 additions & 6 deletions relay-profiling/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,13 @@ where
AnyType::String(s) => s.parse::<T>().map_err(serde::de::Error::custom),
AnyType::Number(n) => Ok(n),
AnyType::Bool(v) => Err(serde::de::Error::custom(format!(
"unsupported value: {:?}",
v
"unsupported value: {v:?}"
))),
AnyType::Array(v) => Err(serde::de::Error::custom(format!(
"unsupported value: {:?}",
v
"unsupported value: {v:?}"
))),
AnyType::Object(v) => Err(serde::de::Error::custom(format!(
"unsupported value: {:?}",
v
"unsupported value: {v:?}"
))),
AnyType::Null => Err(serde::de::Error::custom("unsupported null value")),
}
Expand Down
4 changes: 2 additions & 2 deletions relay-prosperoconv/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn main() {
"clone",
"git@github.com:getsentry/tempest.git",
&temp_dir_str,
&format!("--revision={}", version),
&format!("--revision={version}"),
"--depth=1",
])
.status()
Expand All @@ -52,7 +52,7 @@ fn main() {
"clone",
"https://github.com/getsentry/tempest.git",
&temp_dir_str,
&format!("--revision={}", version),
&format!("--revision={version}"),
"--depth=1",
])
.status()
Expand Down
2 changes: 1 addition & 1 deletion relay-quotas/src/redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ mod tests {
scope_id: None,
limit: Some(quota_limit),
window: Some(600),
reason_code: Some(ReasonCode::new(format!("ns: {:?}", namespace))),
reason_code: Some(ReasonCode::new(format!("ns: {namespace:?}"))),
namespace,
}
};
Expand Down
2 changes: 1 addition & 1 deletion relay-sampling/src/redis_sampling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct ReservoirRuleKey(String);

impl ReservoirRuleKey {
pub fn new(org_id: OrganizationId, rule_id: RuleId) -> Self {
Self(format!("reservoir:{}:{}", org_id, rule_id))
Self(format!("reservoir:{org_id}:{rule_id}"))
}

fn as_str(&self) -> &str {
Expand Down
17 changes: 8 additions & 9 deletions relay-server/benches/benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ fn mock_envelope_with_project_key(project_key: &ProjectKey, size: &str) -> Box<E

let bytes = Bytes::from(format!(
"\
{{\"event_id\":\"9ec79c33ec9942ab8353589fcb2e04dc\",\"dsn\":\"https://{}:@sentry.io/42\"}}\n\
{{\"event_id\":\"9ec79c33ec9942ab8353589fcb2e04dc\",\"dsn\":\"https://{project_key}:@sentry.io/42\"}}\n\
{{\"type\":\"attachment\"}}\n\
{}\n\
",
project_key, payload
{payload}\n\
"
));

let mut envelope = Envelope::parse_bytes(bytes).unwrap();
Expand All @@ -88,7 +87,7 @@ fn benchmark_sqlite_envelope_stack(c: &mut Criterion) {

// Benchmark push operations
group.bench_with_input(
BenchmarkId::new(format!("push_{}", envelope_size), size),
BenchmarkId::new(format!("push_{envelope_size}"), size),
size,
|b, &size| {
b.iter_with_setup(
Expand Down Expand Up @@ -126,7 +125,7 @@ fn benchmark_sqlite_envelope_stack(c: &mut Criterion) {

// Benchmark pop operations
group.bench_with_input(
BenchmarkId::new(format!("pop_{}", envelope_size), size),
BenchmarkId::new(format!("pop_{envelope_size}"), size),
size,
|b, &size| {
b.iter_with_setup(
Expand Down Expand Up @@ -166,7 +165,7 @@ fn benchmark_sqlite_envelope_stack(c: &mut Criterion) {

// Benchmark mixed push and pop operations
group.bench_with_input(
BenchmarkId::new(format!("mixed_{}", envelope_size), size),
BenchmarkId::new(format!("mixed_{envelope_size}"), size),
size,
|b, &size| {
b.iter_with_setup(
Expand Down Expand Up @@ -245,7 +244,7 @@ fn benchmark_envelope_buffer(c: &mut Criterion) {
b.iter_with_setup(
|| {
let project_keys: Vec<_> = (0..num_projects)
.map(|i| ProjectKey::parse(&format!("{:#032x}", i)).unwrap())
.map(|i| ProjectKey::parse(&format!("{i:#032x}")).unwrap())
.collect();

let mut envelopes = vec![];
Expand Down Expand Up @@ -277,7 +276,7 @@ fn benchmark_envelope_buffer(c: &mut Criterion) {
b.iter_with_setup(
|| {
let project_keys: Vec<_> = (0..num_projects)
.map(|i| ProjectKey::parse(&format!("{:#032x}", i)).unwrap())
.map(|i| ProjectKey::parse(&format!("{i:#032x}")).unwrap())
.collect();

let mut envelopes = vec![];
Expand Down
2 changes: 1 addition & 1 deletion relay-server/src/metrics_extraction/transactions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2083,7 +2083,7 @@ mod tests {
),
] {
let config: TransactionMetricsConfig = serde_json::from_str(config_str).unwrap();
assert_eq!(config.deprecated1, expected_strategy, "{}", config_str);
assert_eq!(config.deprecated1, expected_strategy, "{config_str}");
}
}

Expand Down
2 changes: 1 addition & 1 deletion relay-server/src/services/outcome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ impl fmt::Display for Outcome {
Outcome::RateLimited(None) => write!(f, "rate limited"),
Outcome::RateLimited(Some(reason)) => write!(f, "rate limited with reason {reason}"),
#[cfg(feature = "processing")]
Outcome::CardinalityLimited(id) => write!(f, "cardinality limited ({})", id),
Outcome::CardinalityLimited(id) => write!(f, "cardinality limited ({id})"),
Outcome::Invalid(DiscardReason::Internal) => write!(f, "internal error"),
Outcome::Invalid(reason) => write!(f, "invalid data ({reason})"),
Outcome::Abuse => write!(f, "abuse limit reached"),
Expand Down
4 changes: 2 additions & 2 deletions relay-server/src/services/processor/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,12 @@ mod tests {
let attribute_value = |key: &str| -> String {
match attributes
.get(key)
.unwrap_or_else(|| panic!("attribute {} missing", key))
.unwrap_or_else(|| panic!("attribute {key} missing"))
.to_owned()
.value
{
Some(Value::StringValue(str)) => str,
_ => panic!("attribute {} not a string", key),
_ => panic!("attribute {key} not a string"),
}
};
assert_eq!(
Expand Down
4 changes: 2 additions & 2 deletions relay-spans/src/v2_to_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,14 @@ fn derive_http_description(attributes: &Attributes, kind: &Option<&SpanV2Kind>)
let Some(url_path) = url_path else {
return Some(description);
};
let base_description = format!("{} {}", http_method, url_path);
let base_description = format!("{http_method} {url_path}");

// Check for GraphQL operations
if let Some(graphql_ops) = attributes
.get_value("sentry.graphql.operation")
.and_then(|v| v.as_str())
{
return Some(format!("{} ({})", base_description, graphql_ops));
return Some(format!("{base_description} ({graphql_ops})"));
}

Some(base_description)
Expand Down
4 changes: 2 additions & 2 deletions relay-threading/benches/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fn bench_pool_scaling(c: &mut Criterion) {
// Test with different task counts
for tasks in [100, 1000, 10000].iter() {
group.bench_with_input(
BenchmarkId::new(format!("threads_{}", threads), tasks),
BenchmarkId::new(format!("threads_{threads}"), tasks),
tasks,
|b, &tasks| {
b.to_async(&runtime).iter(|| run_benchmark(&pool, tasks));
Expand All @@ -117,7 +117,7 @@ fn bench_multi_threaded_spawn(c: &mut Criterion) {
// Test with different task counts
for tasks in [1000, 10000].iter() {
group.bench_with_input(
BenchmarkId::new(format!("spawn_threads_{}", spawn_threads), tasks),
BenchmarkId::new(format!("spawn_threads_{spawn_threads}"), tasks),
tasks,
|b, &tasks| {
b.to_async(&runtime).iter(|| async {
Expand Down
6 changes: 2 additions & 4 deletions relay-threading/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,7 @@ mod tests {
// If running concurrently, the overall time should be near 200ms (with some allowance).
assert!(
elapsed < Duration::from_millis(250),
"Elapsed time was too high: {:?}",
elapsed
"Elapsed time was too high: {elapsed:?}"
);
}

Expand Down Expand Up @@ -391,8 +390,7 @@ mod tests {
// If running concurrently, the overall time should be near 200ms (with some allowance).
assert!(
elapsed < Duration::from_millis(250),
"Elapsed time was too high: {:?}",
elapsed
"Elapsed time was too high: {elapsed:?}"
);
}

Expand Down
6 changes: 2 additions & 4 deletions tools/bench-buffer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,8 @@ fn mock_envelope(
let project_key = (rand::random::<f64>() * project_count as f64) as u128;
let mut envelope = format!(
"\
{{\"event_id\":\"9ec79c33ec9942ab8353589fcb2e04dc\",\"dsn\":\"https://{:032x}:@sentry.io/42\"}}\n\
{{\"type\":\"attachment\", \"length\":{}}}\n",
project_key,
payload_size,
{{\"event_id\":\"9ec79c33ec9942ab8353589fcb2e04dc\",\"dsn\":\"https://{project_key:032x}:@sentry.io/42\"}}\n\
{{\"type\":\"attachment\", \"length\":{payload_size}}}\n",
).into_bytes();

// Fill with random bytes to get estimated compression ratio:
Expand Down
2 changes: 1 addition & 1 deletion tools/document-pii/src/item_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ fn normalize_type_path(mut path: String, crate_root: &str, module_path: &str) ->
path = path
.replace(' ', "")
.replace('-', "_")
.replace("crate::", &format!("{}::", crate_root));
.replace("crate::", &format!("{crate_root}::"));

if path.contains("super::") {
let parent_module = {
Expand Down