Skip to content

Commit

Permalink
Fix or work around clippy lints (#31)
Browse files Browse the repository at this point in the history
* Fix clippy lints from nightly

* Work around more recent clippy lints

Doing allow(clippy::get_first) or any other lint that doesn't exist on
1.60 is annoying.
  • Loading branch information
morrisonlevi committed Jul 12, 2022
1 parent 6bc8a37 commit 7e0d038
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ddprof-ffi/src/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
3 changes: 3 additions & 0 deletions ddprof-ffi/src/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ pub struct ParseTagsResult {
error_message: Option<Box<crate::Vec<u8>>>,
}

/// # 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 {
Expand Down
8 changes: 3 additions & 5 deletions ddprof-ffi/src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ impl<T> Default for Vec<T> {
}
}

#[allow(clippy::get_first)]
#[cfg(test)]
mod test {
use crate::vec::*;
Expand Down Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion ddprof-profiles/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions ddtelemetry/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down

0 comments on commit 7e0d038

Please sign in to comment.