diff options
| author | Michael Krasnitski <michael.krasnitski@gmail.com> | 2024-04-16 19:32:04 -0400 |
|---|---|---|
| committer | Kyle Martin <krm504@nyu.edu> | 2024-05-09 13:11:41 -0400 |
| commit | 29b62677dad48aa4d55ad2dae5d176d9880216bd (patch) | |
| tree | f205a5f4ebb7e71ea132fe06a7076c70616d3c62 /rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs | |
| parent | 608f261e6bca5869e748d4509da92a5717dce75d (diff) | |
Fix clippy warnings and run rustfmt
Diffstat (limited to 'rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs')
| -rw-r--r-- | rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs | 22 |
1 files changed, 9 insertions, 13 deletions
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<Type>, - commit: bool, - ) { + pub(crate) fn add_type(&mut self, type_uid: TypeUID, name: String, t: Ref<Type>, 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 => {} } } } |
