From 29b62677dad48aa4d55ad2dae5d176d9880216bd Mon Sep 17 00:00:00 2001 From: Michael Krasnitski Date: Tue, 16 Apr 2024 19:32:04 -0400 Subject: Fix clippy warnings and run rustfmt --- .../dwarf/dwarf_import/src/dwarfdebuginfo.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs') diff --git a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs index b1b91c1d..537051c8 100644 --- a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs +++ b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs @@ -28,6 +28,7 @@ use gimli::{DebuggingInformationEntry, Dwarf, Reader, Unit}; use log::{error, warn}; use std::{ + cmp::Ordering, collections::{hash_map::Values, HashMap}, hash::Hash, }; @@ -222,13 +223,7 @@ impl DebugInfoBuilder { self.types.values() } - pub(crate) fn add_type( - &mut self, - type_uid: TypeUID, - name: String, - t: Ref, - commit: bool, - ) { + pub(crate) fn add_type(&mut self, type_uid: TypeUID, name: String, t: Ref, commit: bool) { if let Some(DebugType { name: existing_name, t: existing_type, @@ -379,8 +374,7 @@ impl DebugInfoBuilder { if simplify_str_to_fqn(func_full_name, true).len() < simplify_str_to_fqn(symbol_full_name.clone(), true).len() { - func.full_name = - Some(symbol_full_name.to_string()); + func.full_name = Some(symbol_full_name.to_string()); } } } @@ -388,10 +382,12 @@ impl DebugInfoBuilder { if let Some(address) = func.address { let existing_functions = bv.functions_at(address); - if existing_functions.len() > 1 { - warn!("Multiple existing functions at address {address:08x}. One or more functions at this address may have the wrong platform information. Please report this binary."); - } else if existing_functions.len() == 1 { - func.platform = Some(existing_functions.get(0).platform()); + match existing_functions.len().cmp(&1) { + Ordering::Greater => { + warn!("Multiple existing functions at address {address:08x}. One or more functions at this address may have the wrong platform information. Please report this binary."); + } + Ordering::Equal => func.platform = Some(existing_functions.get(0).platform()), + Ordering::Less => {} } } } -- cgit v1.3.1