Skip to content

Commit

Permalink
style: fix clippy lints from Rust 1.79 release (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
morrisonlevi authored Jun 13, 2024
1 parent 718e036 commit 6fcf188
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
1 change: 0 additions & 1 deletion profiling-ffi/src/crashtracker/collector.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
5 changes: 5 additions & 0 deletions profiling-ffi/src/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,36 @@ use std::borrow::Cow;
use std::ptr::NonNull;
use std::str::FromStr;

#[allow(dead_code)]
#[repr(C)]
pub enum ExporterNewResult {
Ok(NonNull<ProfileExporter>),
Err(Error),
}

#[allow(dead_code)]
#[repr(C)]
pub enum RequestBuildResult {
Ok(NonNull<Request>),
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>),
Agentless(CharSlice<'a>, CharSlice<'a>),
File(CharSlice<'a>),
}

#[allow(dead_code)]
#[repr(C)]
pub struct File<'a> {
name: CharSlice<'a>,
Expand Down
3 changes: 3 additions & 0 deletions profiling-ffi/src/profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -69,13 +70,15 @@ impl From<anyhow::Result<()>> for ProfileResult {
}

/// Returned by [ddog_prof_Profile_new].
#[allow(dead_code)]
#[repr(C)]
pub enum ProfileNewResult {
Ok(Profile),
#[allow(dead_code)]
Err(Error),
}

#[allow(dead_code)]
#[repr(C)]
pub enum SerializeResult {
Ok(EncodedProfile),
Expand Down
7 changes: 2 additions & 5 deletions profiling/src/internal/profile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<i64, u64>(*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));
Expand Down
4 changes: 2 additions & 2 deletions trace-normalization/src/normalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6fcf188

Please sign in to comment.