From d1098195e0fd16be5ad7ee712242851854c6f137 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Mon, 25 Sep 2023 17:32:33 -0400 Subject: [PATCH] chore: Fix clippy errors Signed-off-by: Andrew Lamb --- src/collector.rs | 2 +- src/profiler.rs | 28 ++++++++++++++-------------- src/report.rs | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/collector.rs b/src/collector.rs index 41b34139..c05fb18b 100644 --- a/src/collector.rs +++ b/src/collector.rs @@ -37,7 +37,7 @@ pub struct Bucket { impl Default for Bucket { fn default() -> Bucket { - let entries = Box::new(Default::default()); + let entries = Box::default(); Self { length: 0, entries } } diff --git a/src/profiler.rs b/src/profiler.rs index e68ee9ec..d7314ea7 100644 --- a/src/profiler.rs +++ b/src/profiler.rs @@ -34,24 +34,24 @@ pub struct Profiler { running: bool, - #[cfg(all(any( + #[cfg(any( target_arch = "x86_64", target_arch = "aarch64", target_arch = "riscv64", target_arch = "loongarch64" - )))] + ))] blocklist_segments: Vec<(usize, usize)>, } #[derive(Clone)] pub struct ProfilerGuardBuilder { frequency: c_int, - #[cfg(all(any( + #[cfg(any( target_arch = "x86_64", target_arch = "aarch64", target_arch = "riscv64", target_arch = "loongarch64" - )))] + ))] blocklist_segments: Vec<(usize, usize)>, } @@ -60,12 +60,12 @@ impl Default for ProfilerGuardBuilder { ProfilerGuardBuilder { frequency: 99, - #[cfg(all(any( + #[cfg(any( target_arch = "x86_64", target_arch = "aarch64", target_arch = "riscv64", target_arch = "loongarch64" - )))] + ))] blocklist_segments: Vec::new(), } } @@ -76,12 +76,12 @@ impl ProfilerGuardBuilder { Self { frequency, ..self } } - #[cfg(all(any( + #[cfg(any( target_arch = "x86_64", target_arch = "aarch64", target_arch = "riscv64", target_arch = "loongarch64" - )))] + ))] pub fn blocklist>(self, blocklist: &[T]) -> Self { let blocklist_segments = { let mut segments = Vec::new(); @@ -126,12 +126,12 @@ impl ProfilerGuardBuilder { Err(Error::CreatingError) } Ok(profiler) => { - #[cfg(all(any( + #[cfg(any( target_arch = "x86_64", target_arch = "aarch64", target_arch = "riscv64", target_arch = "loongarch64" - )))] + ))] { profiler.blocklist_segments = self.blocklist_segments; } @@ -388,22 +388,22 @@ impl Profiler { sample_counter: 0, running: false, - #[cfg(all(any( + #[cfg(any( target_arch = "x86_64", target_arch = "aarch64", target_arch = "riscv64", target_arch = "loongarch64" - )))] + ))] blocklist_segments: Vec::new(), }) } - #[cfg(all(any( + #[cfg(any( target_arch = "x86_64", target_arch = "aarch64", target_arch = "riscv64", target_arch = "loongarch64" - )))] + ))] fn is_blocklisted(&self, addr: usize) -> bool { for libs in &self.blocklist_segments { if addr > libs.0 && addr < libs.1 { diff --git a/src/report.rs b/src/report.rs index 37b885a8..971cb8d6 100644 --- a/src/report.rs +++ b/src/report.rs @@ -229,7 +229,7 @@ mod protobuf { /// `pprof` will generate google's pprof format report. pub fn pprof(&self) -> crate::Result { let mut dedup_str = HashSet::new(); - for key in self.data.iter().map(|(key, _)| key) { + for key in self.data.keys() { dedup_str.insert(key.thread_name_or_id()); for frame in key.frames.iter() { for symbol in frame {