Skip to content

Commit 31cf340

Browse files
authored
style: fix clippy lints on Rust 1.90 (#1229)
* style: fix clippy lints on Rust 1.90 * fix: crasht test * fix: telemetry test and add timeout
1 parent 47f50ae commit 31cf340

File tree

6 files changed

+24
-28
lines changed

6 files changed

+24
-28
lines changed

bin_tests/tests/crashtracker_bin_test.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,18 +200,17 @@ fn test_crash_tracking_callstack() {
200200

201201
// Note: in Release, we do not have the crate and module name prepended to the function name
202202
// Here we compile the crashing app in Debug.
203-
let mut expected_functions = vec![
203+
let mut expected_functions = Vec::new();
204+
// It seems that on arm/arm64, fn3 is inlined in fn2, so not present.
205+
// Add fn3 only for x86_64 arch
206+
#[cfg(target_arch = "x86_64")]
207+
expected_functions.push("crashing_test_app::unix::fn3");
208+
expected_functions.extend_from_slice(&[
204209
"crashing_test_app::unix::fn2",
205210
"crashing_test_app::unix::fn1",
206211
"crashing_test_app::unix::main",
207212
"crashing_test_app::main",
208-
];
209-
// It seems that on arm/arm64, fn3 is inlined in fn2, so not present.
210-
// Add fn3 only for x86_64 arch
211-
#[cfg(target_arch = "x86_64")]
212-
{
213-
expected_functions.insert(0, "crashing_test_app::unix::fn3");
214-
}
213+
]);
215214

216215
let crashing_callstack = &crash_payload["error"]["stack"]["frames"];
217216
assert!(

data-pipeline/src/span_concentrator/aggregation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@ where
9090
}
9191
}
9292

93-
impl Eq for (dyn BorrowableAggregationKey + '_) {}
93+
impl Eq for dyn BorrowableAggregationKey + '_ {}
9494

95-
impl PartialEq for (dyn BorrowableAggregationKey + '_) {
95+
impl PartialEq for dyn BorrowableAggregationKey + '_ {
9696
fn eq(&self, other: &dyn BorrowableAggregationKey) -> bool {
9797
self.borrowed_aggregation_key()
9898
.eq(&other.borrowed_aggregation_key())
9999
}
100100
}
101101

102-
impl std::hash::Hash for (dyn BorrowableAggregationKey + '_) {
102+
impl std::hash::Hash for dyn BorrowableAggregationKey + '_ {
103103
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
104104
self.borrowed_aggregation_key().hash(state)
105105
}

data-pipeline/src/telemetry/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -724,11 +724,11 @@ mod tests {
724724
})
725725
.unwrap();
726726
client.shutdown().await;
727-
while telemetry_srv.hits_async().await == 0 {
727+
while telemetry_srv.calls_async().await == 0 {
728728
sleep(Duration::from_millis(10)).await;
729729
}
730730
// One payload generate-metrics
731-
telemetry_srv.assert_hits_async(1).await;
731+
telemetry_srv.assert_calls_async(1).await;
732732
}
733733

734734
#[cfg_attr(miri, ignore)]
@@ -739,7 +739,7 @@ mod tests {
739739
let telemetry_srv = server
740740
.mock_async(|when, then| {
741741
when.method(POST)
742-
.body_contains(r#""application":{"service_name":"test_service","service_version":"test_version","env":"test_env","language_name":"test_language","language_version":"test_language_version","tracer_version":"test_tracer_version"}"#);
742+
.body_includes(r#""application":{"service_name":"test_service","service_version":"test_version","env":"test_env","language_name":"test_language","language_version":"test_language_version","tracer_version":"test_tracer_version"}"#);
743743
then.status(200).body("");
744744
})
745745
.await;
@@ -765,7 +765,12 @@ mod tests {
765765
})
766766
.unwrap();
767767
client.shutdown().await;
768+
// Wait for the server to receive at least one call, but don't hang forever.
769+
let start = std::time::Instant::now();
768770
while telemetry_srv.calls_async().await == 0 {
771+
if start.elapsed() > Duration::from_secs(180) {
772+
panic!("telemetry server did not receive calls within timeout");
773+
}
769774
sleep(Duration::from_millis(10)).await;
770775
}
771776
// One payload generate-metrics

datadog-ipc/tarpc/examples/compression.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ pub enum CompressedMessage<T> {
2525
},
2626
}
2727

28-
#[derive(Deserialize, Serialize)]
29-
enum CompressionType {
30-
Uncompressed,
31-
Compressed,
32-
}
33-
3428
async fn compress<T>(message: T) -> io::Result<CompressedMessage<T>>
3529
where
3630
T: Serialize,

datadog-live-debugger-ffi/src/evaluator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ impl<'a> From<&'a datadog_live_debugger::IntermediateValue<'a, c_void>> for Inte
3333
}
3434
}
3535

36+
#[allow(clippy::zero_ptr)] // written this way for cbindgen's sake
3637
pub const EVALUATOR_RESULT_UNDEFINED: *const c_void = 0isize as *const c_void;
3738
pub const EVALUATOR_RESULT_INVALID: *const c_void = -1isize as *const c_void;
3839
pub const EVALUATOR_RESULT_REDACTED: *const c_void = -2isize as *const c_void;

datadog-sidecar-ffi/src/lib.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,14 @@ use datadog_sidecar::shm_remote_config::{path_for_remote_config, RemoteConfigRea
3535
use datadog_trace_utils::msgpack_encoder;
3636
use ddcommon::tag::Tag;
3737
use ddcommon::Endpoint;
38-
use ddcommon_ffi as ffi;
39-
use ddcommon_ffi::{CharSlice, MaybeError};
38+
use ddcommon_ffi::slice::{AsBytes, CharSlice};
39+
use ddcommon_ffi::{self as ffi, MaybeError};
4040
use ddtelemetry::{
4141
data::{self, Dependency, Integration},
4242
worker::{LifecycleAction, LogIdentifier, TelemetryActions},
4343
};
4444
use ddtelemetry_ffi::try_c;
4545
use dogstatsd_client::DogStatsDActionOwned;
46-
use ffi::slice::AsBytes;
4746
use libc::c_char;
4847
use std::ffi::{c_void, CStr, CString};
4948
use std::fs::File;
@@ -686,11 +685,9 @@ pub unsafe extern "C" fn ddog_sidecar_enqueue_telemetry_log(
686685
}
687686

688687
fn char_slice_to_string(slice: CharSlice) -> Result<String, String> {
689-
let cast_slice =
690-
unsafe { slice::from_raw_parts(slice.as_slice().as_ptr() as *const u8, slice.len()) };
691-
let slice = std::str::from_utf8(cast_slice)
692-
.map_err(|e| format!("Failed to convert CharSlice to String: {e}"))?;
693-
Ok(slice.to_string())
688+
slice
689+
.try_to_string()
690+
.map_err(|e| format!("Failed to convert CharSlice to String: {e}"))
694691
}
695692

696693
#[allow(clippy::too_many_arguments)]

0 commit comments

Comments
 (0)