From 6fcf188c8a6b3369dadecc8382640bd0c3c1a8d4 Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Thu, 13 Jun 2024 11:23:18 -0600 Subject: [PATCH] style: fix clippy lints from Rust 1.79 release (#486) --- profiling-ffi/src/crashtracker/collector.rs | 1 - profiling-ffi/src/exporter.rs | 5 +++++ profiling-ffi/src/profiles.rs | 3 +++ profiling/src/internal/profile/mod.rs | 7 ++----- trace-normalization/src/normalizer.rs | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/profiling-ffi/src/crashtracker/collector.rs b/profiling-ffi/src/crashtracker/collector.rs index 9c4d8c6b1..6dac58134 100644 --- a/profiling-ffi/src/crashtracker/collector.rs +++ b/profiling-ffi/src/crashtracker/collector.rs @@ -1,6 +1,5 @@ // Copyright 2021-Present Datadog, Inc. https://www.datadoghq.com/ // SPDX-License-Identifier: Apache-2.0 -#![cfg(unix)] use crate::crashtracker::datatypes::*; use anyhow::Context; use ddcommon_ffi::{slice::AsBytes, CharSlice}; diff --git a/profiling-ffi/src/exporter.rs b/profiling-ffi/src/exporter.rs index e45ec4712..2c1c57782 100644 --- a/profiling-ffi/src/exporter.rs +++ b/profiling-ffi/src/exporter.rs @@ -15,24 +15,28 @@ use std::borrow::Cow; use std::ptr::NonNull; use std::str::FromStr; +#[allow(dead_code)] #[repr(C)] pub enum ExporterNewResult { Ok(NonNull), Err(Error), } +#[allow(dead_code)] #[repr(C)] pub enum RequestBuildResult { Ok(NonNull), Err(Error), } +#[allow(dead_code)] #[repr(C)] pub enum SendResult { HttpResponse(HttpStatus), Err(Error), } +#[allow(dead_code)] #[repr(C)] pub enum ProfilingEndpoint<'a> { Agent(CharSlice<'a>), @@ -40,6 +44,7 @@ pub enum ProfilingEndpoint<'a> { File(CharSlice<'a>), } +#[allow(dead_code)] #[repr(C)] pub struct File<'a> { name: CharSlice<'a>, diff --git a/profiling-ffi/src/profiles.rs b/profiling-ffi/src/profiles.rs index 0c4bbea00..5ec993237 100644 --- a/profiling-ffi/src/profiles.rs +++ b/profiling-ffi/src/profiles.rs @@ -49,6 +49,7 @@ impl Drop for Profile { /// A generic result type for when a profiling operation may fail, but there's /// nothing to return in the case of success. +#[allow(dead_code)] #[repr(C)] pub enum ProfileResult { Ok( @@ -69,6 +70,7 @@ impl From> for ProfileResult { } /// Returned by [ddog_prof_Profile_new]. +#[allow(dead_code)] #[repr(C)] pub enum ProfileNewResult { Ok(Profile), @@ -76,6 +78,7 @@ pub enum ProfileNewResult { Err(Error), } +#[allow(dead_code)] #[repr(C)] pub enum SerializeResult { Ok(EncodedProfile), diff --git a/profiling/src/internal/profile/mod.rs b/profiling/src/internal/profile/mod.rs index 300b50e4e..31a15f803 100644 --- a/profiling/src/internal/profile/mod.rs +++ b/profiling/src/internal/profile/mod.rs @@ -358,13 +358,10 @@ impl Profile { label ); - let local_root_span_id: u64 = if let LabelValue::Num { num, .. } = label.get_value() { - // Manually specify the type here to be sure we're transmuting an - // i64 and not a &i64. - let id: i64 = *num; + let local_root_span_id = if let LabelValue::Num { num, .. } = label.get_value() { // Safety: the value is a u64, but pprof only has signed values, so we // transmute it; the backend does the same. - unsafe { std::intrinsics::transmute(id) } + unsafe { std::intrinsics::transmute::(*num) } } else { return Err(anyhow::format_err!("the local root span id label value must be sent as a number, not a string, given {:?}", label)); diff --git a/trace-normalization/src/normalizer.rs b/trace-normalization/src/normalizer.rs index cc5fa7d3f..ec87a18de 100644 --- a/trace-normalization/src/normalizer.rs +++ b/trace-normalization/src/normalizer.rs @@ -66,7 +66,7 @@ fn normalize_span(s: &mut pb::Span) -> anyhow::Result<()> { if s.duration < 0 { s.duration = 0; } - if s.duration > std::i64::MAX - s.start { + if s.duration > i64::MAX - s.start { s.duration = 0; } if s.start < YEAR_2000_NANOSEC_TS { @@ -397,7 +397,7 @@ mod tests { #[test] fn test_normalize_large_duration() { let mut test_span = new_test_span(); - test_span.duration = std::i64::MAX; + test_span.duration = i64::MAX; assert!(normalizer::normalize_span(&mut test_span).is_ok()); assert_eq!(test_span.duration, 0);