diff --git a/ddprof-ffi/src/exporter.rs b/ddprof-ffi/src/exporter.rs index f7dc015af..e1458bb0e 100644 --- a/ddprof-ffi/src/exporter.rs +++ b/ddprof-ffi/src/exporter.rs @@ -235,7 +235,7 @@ fn unwrap_cancellation_token<'a>( ) -> Option<&'a tokio_util::sync::CancellationToken> { cancel.map(|c| { let wrapped_reference: &CancellationToken = unsafe { c.as_ref() }; - let unwrapped_reference: &tokio_util::sync::CancellationToken = &(*wrapped_reference).0; + let unwrapped_reference: &tokio_util::sync::CancellationToken = &(wrapped_reference.0); unwrapped_reference }) diff --git a/ddprof-ffi/src/tags.rs b/ddprof-ffi/src/tags.rs index 5edd9371c..77c68992c 100644 --- a/ddprof-ffi/src/tags.rs +++ b/ddprof-ffi/src/tags.rs @@ -54,6 +54,9 @@ pub struct ParseTagsResult { error_message: Option>>, } +/// # Safety +/// The `string`'s .ptr must point to a valid object at least as large as its +/// .len property. #[must_use] #[no_mangle] pub unsafe extern "C" fn ddprof_ffi_Vec_tag_parse(string: CharSlice) -> ParseTagsResult { diff --git a/ddprof-ffi/src/vec.rs b/ddprof-ffi/src/vec.rs index 8258d1c19..1e49078ca 100644 --- a/ddprof-ffi/src/vec.rs +++ b/ddprof-ffi/src/vec.rs @@ -124,7 +124,6 @@ impl Default for Vec { } } -#[allow(clippy::get_first)] #[cfg(test)] mod test { use crate::vec::*; @@ -155,10 +154,9 @@ mod test { assert!(ffi_vec.capacity >= 2); let slice = unsafe { ffi_vec.as_slice().as_slice() }; - let first = slice.get(0).unwrap(); - let second = slice.get(1).unwrap(); - assert_eq!(first, &1); - assert_eq!(second, &2); + let [first, second]: [_; 2] = slice.try_into().expect("slice to have 2 items"); + assert_eq!(first, 1); + assert_eq!(second, 2); } #[test] diff --git a/ddprof-profiles/src/lib.rs b/ddprof-profiles/src/lib.rs index 99ee7079e..46240e7c2 100644 --- a/ddprof-profiles/src/lib.rs +++ b/ddprof-profiles/src/lib.rs @@ -656,7 +656,8 @@ mod api_test { #[test] fn impl_from_profile_for_pprof_profile() { - let profile: pprof::Profile = (&provide_distinct_locations()).into(); + let locations = provide_distinct_locations(); + let profile = pprof::Profile::from(&locations); assert_eq!(profile.sample.len(), 2); assert_eq!(profile.mapping.len(), 1); diff --git a/ddtelemetry/src/worker.rs b/ddtelemetry/src/worker.rs index 0468026a6..592e569fb 100644 --- a/ddtelemetry/src/worker.rs +++ b/ddtelemetry/src/worker.rs @@ -256,9 +256,8 @@ impl TelemetryWorker { let mut series = Vec::new(); for (context_key, extra_tags, points) in self.data.metric_buckets.flush_series() { let context_guard = self.data.metric_contexts.get_context(context_key); - - #[allow(clippy::significant_drop_in_scrutinee)] - let context = match context_guard.read() { + let maybe_context = context_guard.read(); + let context = match maybe_context { Some(context) => context, None => { telemetry_worker_log!(