summaryrefslogtreecommitdiff
path: root/rust/examples
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2024-12-03 11:08:06 -0500
committerMason Reed <mason@vector35.com>2024-12-03 11:08:39 -0500
commitc7f728bf5cdef1d05c6443de800cbc5464c0bb4f (patch)
treef72f6aa463f55874396d95364e480a6330a1c99b /rust/examples
parent9b22a138793d31972cf2c8b3350eb2025505befe (diff)
IDB Import: Misc clippy lints
Diffstat (limited to 'rust/examples')
-rw-r--r--rust/examples/idb_import/src/lib.rs6
-rw-r--r--rust/examples/idb_import/src/types.rs19
2 files changed, 12 insertions, 13 deletions
diff --git a/rust/examples/idb_import/src/lib.rs b/rust/examples/idb_import/src/lib.rs
index 4adf04ca..48d1b8fd 100644
--- a/rust/examples/idb_import/src/lib.rs
+++ b/rust/examples/idb_import/src/lib.rs
@@ -200,7 +200,7 @@ pub fn import_til_section(
if let TranslateTypeResult::Translated(bn_ty)
| TranslateTypeResult::PartiallyTranslated(bn_ty, _) = &ty.ty
{
- if !debug_info.add_type(&String::from_utf8_lossy(&ty.name), &bn_ty, &[/* TODO */]) {
+ if !debug_info.add_type(&String::from_utf8_lossy(&ty.name), bn_ty, &[/* TODO */]) {
error!(
"Unable to add type `{}`",
&String::from_utf8_lossy(&ty.name)
@@ -214,7 +214,7 @@ pub fn import_til_section(
if let TranslateTypeResult::Translated(bn_ty)
| TranslateTypeResult::PartiallyTranslated(bn_ty, _) = &ty.ty
{
- if !debug_info.add_type(&String::from_utf8_lossy(&ty.name), &bn_ty, &[/* TODO */]) {
+ if !debug_info.add_type(&String::from_utf8_lossy(&ty.name), bn_ty, &[/* TODO */]) {
error!(
"Unable to fix type `{}`",
&String::from_utf8_lossy(&ty.name)
@@ -255,7 +255,7 @@ fn parse_id0_section_info(
let bnty = ty
.as_ref()
- .and_then(|ty| match translate_ephemeral_type(debug_file, &ty) {
+ .and_then(|ty| match translate_ephemeral_type(debug_file, ty) {
TranslateTypeResult::Translated(result) => Some(result),
TranslateTypeResult::PartiallyTranslated(result, None) => {
warn!("Unable to fully translate the type at {addr:#x}");
diff --git a/rust/examples/idb_import/src/types.rs b/rust/examples/idb_import/src/types.rs
index 01cc5ff3..c614634b 100644
--- a/rust/examples/idb_import/src/types.rs
+++ b/rust/examples/idb_import/src/types.rs
@@ -161,7 +161,7 @@ impl<F: Fn(usize, usize) -> Result<(), ()>> TranslateIDBTypes<'_, F> {
}
TranslateTypeResult::PartiallyTranslated(og_ty, error) => {
TranslateTypeResult::PartiallyTranslated(
- Type::named_type_from_type(&String::from_utf8_lossy(&ty.name), &og_ty),
+ Type::named_type_from_type(&String::from_utf8_lossy(&ty.name), og_ty),
error
.as_ref()
.map(|x| BnTypeError::Typedef(Box::new(x.clone())))
@@ -169,7 +169,7 @@ impl<F: Fn(usize, usize) -> Result<(), ()>> TranslateIDBTypes<'_, F> {
)
}
TranslateTypeResult::Translated(og_ty) => TranslateTypeResult::Translated(
- Type::named_type_from_type(&String::from_utf8_lossy(&ty.name), &og_ty),
+ Type::named_type_from_type(&String::from_utf8_lossy(&ty.name), og_ty),
),
}
}
@@ -262,7 +262,7 @@ impl<F: Fn(usize, usize) -> Result<(), ()>> TranslateIDBTypes<'_, F> {
}
fn translate_array(&self, array: &TILArray) -> TranslateTypeResult {
- match self.translate_type(&*array.elem_type) {
+ match self.translate_type(&array.elem_type) {
TranslateTypeResult::NotYet => TranslateTypeResult::NotYet,
TranslateTypeResult::Translated(ty) => {
TranslateTypeResult::Translated(Type::array(&ty, array.nelem.into()))
@@ -520,7 +520,7 @@ impl<F: Fn(usize, usize) -> Result<(), ()>> TranslateIDBTypes<'_, F> {
// updated after alBasicers are finished
TILType::Union(TILUnion::Ref { ref_type, .. })
| TILType::Struct(TILStruct::Ref { ref_type, .. })
- | TILType::Enum(TILEnum::Ref { ref_type, .. }) => self.translate_pointer(&**ref_type),
+ | TILType::Enum(TILEnum::Ref { ref_type, .. }) => self.translate_pointer(ref_type),
TILType::Pointer(ty) => self.translate_pointer(&ty.typ),
TILType::Function(fun) => self.translate_function(fun),
@@ -573,11 +573,11 @@ pub fn translate_ephemeral_type(debug_file: &BinaryView, ty: &TILType) -> Transl
translator.translate_type(ty)
}
-pub fn translate_til_types<'a>(
+pub fn translate_til_types(
arch: CoreArchitecture,
- til: &'a TILSection,
+ til: &TILSection,
progress: impl Fn(usize, usize) -> Result<(), ()>,
-) -> Result<Vec<TranslatesIDBType<'a>>> {
+) -> Result<Vec<TranslatesIDBType>> {
let total = til.symbols.len() + til.types.len();
let mut types = Vec::with_capacity(total);
let mut types_by_ord = HashMap::with_capacity(total);
@@ -672,9 +672,8 @@ pub fn translate_til_types<'a>(
}
// count the number of finished types
- match &translator.types[i].ty {
- TranslateTypeResult::Translated(_) => num_translated += 1,
- _ => {}
+ if let TranslateTypeResult::Translated(_) = &translator.types[i].ty {
+ num_translated += 1
}
}