Skip to content

Commit db3be2b

Browse files
chore: Fix 1.88.0 clippy lints (#4872)
Addresses: - [uninlined_format_args ](https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args) - [dangerous_implicit_autorefs](rust-lang/rust#123239) #skip-changelog
1 parent d5b8889 commit db3be2b

File tree

22 files changed

+45
-62
lines changed

22 files changed

+45
-62
lines changed

relay-cabi/src/core.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,7 @@ impl From<Uuid> for RelayUuid {
135135
#[unsafe(no_mangle)]
136136
#[relay_ffi::catch_unwind]
137137
pub unsafe extern "C" fn relay_uuid_is_nil(uuid: *const RelayUuid) -> bool {
138-
if let Ok(uuid) = Uuid::from_slice(unsafe { &(*uuid).data[..] }) {
139-
uuid == Uuid::nil()
140-
} else {
141-
false
142-
}
138+
Uuid::from_bytes(unsafe { (*uuid).data }) == Uuid::nil()
143139
}
144140

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

relay-config/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2247,7 +2247,7 @@ impl Config {
22472247
}
22482248

22492249
let file_name = path.file_name().and_then(|f| f.to_str())?;
2250-
let new_file_name = format!("{}.{}", file_name, partition_id);
2250+
let new_file_name = format!("{file_name}.{partition_id}");
22512251
path.set_file_name(new_file_name);
22522252

22532253
Some(path)

relay-event-normalization/src/normalize/contexts.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ fn normalize_runtime_context(runtime: &mut RuntimeContext) {
145145
// The equivalent calculation is done in `sentry` in `src/sentry/interfaces/contexts.py`.
146146
if runtime.runtime.value().is_none() {
147147
if let (Some(name), Some(version)) = (runtime.name.value(), runtime.version.value()) {
148-
runtime.runtime = Annotated::from(format!("{} {}", name, version));
148+
runtime.runtime = Annotated::from(format!("{name} {version}"));
149149
}
150150
}
151151
}
@@ -270,7 +270,7 @@ fn compute_os_context(os: &mut OsContext) {
270270
// The equivalent calculation is done in `sentry` in `src/sentry/interfaces/contexts.py`.
271271
if os.os.value().is_none() {
272272
if let (Some(name), Some(version)) = (os.name.value(), os.version.value()) {
273-
os.os = Annotated::from(format!("{} {}", name, version));
273+
os.os = Annotated::from(format!("{name} {version}"));
274274
}
275275
}
276276
}
@@ -280,7 +280,7 @@ fn normalize_browser_context(browser: &mut BrowserContext) {
280280
// The equivalent calculation is done in `sentry` in `src/sentry/interfaces/contexts.py`.
281281
if browser.browser.value().is_none() {
282282
if let (Some(name), Some(version)) = (browser.name.value(), browser.version.value()) {
283-
browser.browser = Annotated::from(format!("{} {}", name, version));
283+
browser.browser = Annotated::from(format!("{name} {version}"));
284284
}
285285
}
286286
}

relay-event-normalization/src/normalize/span/description/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,15 +1415,14 @@ mod tests {
14151415
for (url, allowed_hosts, expected) in examples {
14161416
let json = format!(
14171417
r#"{{
1418-
"description": "POST {}",
1418+
"description": "POST {url}",
14191419
"span_id": "bd2eb23da2beb459",
14201420
"start_timestamp": 1597976393.4619668,
14211421
"timestamp": 1597976393.4718769,
14221422
"trace_id": "ff62a8b040f340bda5d830223def1d81",
14231423
"op": "http.client"
14241424
}}
14251425
"#,
1426-
url,
14271426
);
14281427

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

14341433
assert_eq!(
14351434
scrubbed.0.as_deref(),
1436-
Some(format!("POST {}", expected).as_str()),
1435+
Some(format!("POST {expected}").as_str()),
14371436
"Could not match {url}"
14381437
);
14391438
}

relay-event-normalization/src/timestamp.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,15 @@ impl Processor for TimestampProcessor {
5353
if let Some(start_timestamp) = span.start_timestamp.value() {
5454
if start_timestamp.into_inner().timestamp_millis() < 0 {
5555
meta.add_error(Error::invalid(format!(
56-
"start_timestamp is too stale: {}",
57-
start_timestamp
56+
"start_timestamp is too stale: {start_timestamp}"
5857
)));
5958
return Err(ProcessingAction::DeleteValueHard);
6059
}
6160
}
6261
if let Some(end_timestamp) = span.timestamp.value() {
6362
if end_timestamp.into_inner().timestamp_millis() < 0 {
6463
meta.add_error(Error::invalid(format!(
65-
"timestamp is too stale: {}",
66-
end_timestamp
64+
"timestamp is too stale: {end_timestamp}"
6765
)));
6866
return Err(ProcessingAction::DeleteValueHard);
6967
}
@@ -81,8 +79,7 @@ impl Processor for TimestampProcessor {
8179
if let Some(timestamp) = breadcrumb.timestamp.value() {
8280
if timestamp.into_inner().timestamp_millis() < 0 {
8381
meta.add_error(Error::invalid(format!(
84-
"timestamp is too stale: {}",
85-
timestamp
82+
"timestamp is too stale: {timestamp}"
8683
)));
8784
return Err(ProcessingAction::DeleteValueHard);
8885
}

relay-event-schema/src/protocol/thread.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ impl Empty for ThreadId {
7373
impl fmt::Display for ThreadId {
7474
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
7575
match self {
76-
ThreadId::Int(id) => write!(f, "{}", id),
77-
ThreadId::String(id) => write!(f, "{}", id),
76+
ThreadId::Int(id) => write!(f, "{id}"),
77+
ThreadId::String(id) => write!(f, "{id}"),
7878
}
7979
}
8080
}

relay-filter/src/transaction_name.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ mod tests {
247247
assert_eq!(
248248
filter_result,
249249
Ok(()),
250-
"Event filtered for event_type={} although filter should have not matched",
251-
event_type
250+
"Event filtered for event_type={event_type} although filter should have not matched"
252251
)
253252
}
254253
}

relay-log/src/setup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl Level {
126126

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

relay-profiling/src/sample/v2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,10 @@ mod tests {
221221
fn test_roundtrip() {
222222
let first_payload = include_bytes!("../../tests/fixtures/sample/v2/valid.json");
223223
let first_parse = parse(first_payload);
224-
assert!(first_parse.is_ok(), "{:#?}", first_parse);
224+
assert!(first_parse.is_ok(), "{first_parse:#?}");
225225
let second_payload = serde_json::to_vec(&first_parse.unwrap()).unwrap();
226226
let second_parse = parse(&second_payload[..]);
227-
assert!(second_parse.is_ok(), "{:#?}", second_parse);
227+
assert!(second_parse.is_ok(), "{second_parse:#?}");
228228
}
229229

230230
#[test]

relay-profiling/src/utils.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,13 @@ where
3131
AnyType::String(s) => s.parse::<T>().map_err(serde::de::Error::custom),
3232
AnyType::Number(n) => Ok(n),
3333
AnyType::Bool(v) => Err(serde::de::Error::custom(format!(
34-
"unsupported value: {:?}",
35-
v
34+
"unsupported value: {v:?}"
3635
))),
3736
AnyType::Array(v) => Err(serde::de::Error::custom(format!(
38-
"unsupported value: {:?}",
39-
v
37+
"unsupported value: {v:?}"
4038
))),
4139
AnyType::Object(v) => Err(serde::de::Error::custom(format!(
42-
"unsupported value: {:?}",
43-
v
40+
"unsupported value: {v:?}"
4441
))),
4542
AnyType::Null => Err(serde::de::Error::custom("unsupported null value")),
4643
}

0 commit comments

Comments
 (0)