From 16b6295afc4f7aee0e4aba4f2217b124524843d0 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sun, 4 May 2025 15:49:30 -0400 Subject: [Rust] Misc clippy lints --- plugins/pdb-ng/src/lib.rs | 2 +- plugins/pdb-ng/src/type_parser.rs | 16 +++++++++++----- rust/src/function.rs | 3 ++- rust/src/low_level_il/block.rs | 4 ++-- rust/src/low_level_il/expression.rs | 6 +++--- rust/src/low_level_il/instruction.rs | 2 +- rust/src/low_level_il/lifting.rs | 2 +- 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/plugins/pdb-ng/src/lib.rs b/plugins/pdb-ng/src/lib.rs index 2c1049b0..188b2ed5 100644 --- a/plugins/pdb-ng/src/lib.rs +++ b/plugins/pdb-ng/src/lib.rs @@ -540,7 +540,7 @@ impl PDBParser { impl CustomDebugInfoParser for PDBParser { fn is_valid(&self, view: &BinaryView) -> bool { - view.type_name().to_string() == "PE" || is_pdb(view) + view.type_name() == "PE" || is_pdb(view) } fn parse_info( diff --git a/plugins/pdb-ng/src/type_parser.rs b/plugins/pdb-ng/src/type_parser.rs index 7910e13a..61c64218 100644 --- a/plugins/pdb-ng/src/type_parser.rs +++ b/plugins/pdb-ng/src/type_parser.rs @@ -1759,9 +1759,8 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> { structure.width(data.size); self.namespace_stack.push(union_name.to_string()); - let success = self.parse_union_fields(&mut structure, data.fields, finder); + let _success = self.parse_union_fields(&mut structure, data.fields, finder); self.namespace_stack.pop(); - let _ = success?; let new_type = Type::structure(structure.finalize().as_ref()); Ok(Some(Box::new(ParsedType::Named(union_name, new_type)))) @@ -2015,7 +2014,11 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> { // for some reason if let Some(raw_name) = Self::type_data_to_raw_name(&parsed) { if let Some(&full_index) = self.full_type_indices.get(&raw_name) { - if let None = self.type_stack.iter().find(|&&idx| idx == full_index) + if self + .type_stack + .iter() + .find(|&&idx| idx == full_index) + .is_none() { if full_index != index { return self.try_type_index_to_bare( @@ -2050,8 +2053,11 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> { // for some reason if let Some(raw_name) = Self::type_data_to_raw_name(&parsed) { if let Some(&full_index) = self.full_type_indices.get(&raw_name) { - if let None = - self.type_stack.iter().find(|&&idx| idx == full_index) + if self + .type_stack + .iter() + .find(|&&idx| idx == full_index) + .is_none() { if full_index != index { return self.try_type_index_to_bare( diff --git a/rust/src/function.rs b/rust/src/function.rs index 3eea3a3f..50753d74 100644 --- a/rust/src/function.rs +++ b/rust/src/function.rs @@ -49,7 +49,7 @@ use crate::variable::{ use crate::workflow::Workflow; use std::fmt::{Debug, Formatter}; use std::ptr::NonNull; -use std::time::{Duration, UNIX_EPOCH}; +use std::time::Duration; use std::{ffi::c_char, hash::Hash, ops::Range}; /// Used to describe a location within a [`Function`]. @@ -2520,6 +2520,7 @@ pub struct PerformanceInfo { pub seconds: Duration, } +#[allow(unused)] impl PerformanceInfo { pub fn new(name: String, seconds: Duration) -> Self { Self { diff --git a/rust/src/low_level_il/block.rs b/rust/src/low_level_il/block.rs index 519c707e..fd3e7c81 100644 --- a/rust/src/low_level_il/block.rs +++ b/rust/src/low_level_il/block.rs @@ -51,7 +51,7 @@ where } } -impl<'func, M, F> Debug for LowLevelILBlock<'func, M, F> +impl Debug for LowLevelILBlock<'_, M, F> where M: FunctionMutability, F: FunctionForm, @@ -63,7 +63,7 @@ where } } -impl<'func, M, F> Clone for LowLevelILBlock<'func, M, F> +impl Clone for LowLevelILBlock<'_, M, F> where M: FunctionMutability, F: FunctionForm, diff --git a/rust/src/low_level_il/expression.rs b/rust/src/low_level_il/expression.rs index 331ab980..6addb7e1 100644 --- a/rust/src/low_level_il/expression.rs +++ b/rust/src/low_level_il/expression.rs @@ -91,7 +91,7 @@ where } } -impl<'func, M, F, R> fmt::Debug for LowLevelILExpression<'func, M, F, R> +impl Debug for LowLevelILExpression<'_, M, F, R> where M: FunctionMutability, F: FunctionForm, @@ -202,7 +202,7 @@ where } } -impl<'func, F> LowLevelILExpression<'func, Finalized, F, ValueExpr> +impl LowLevelILExpression<'_, Finalized, F, ValueExpr> where F: FunctionForm, { @@ -650,7 +650,7 @@ where } } -impl<'func> LowLevelILExpressionKind<'func, Mutable, NonSSA> { +impl LowLevelILExpressionKind<'_, Mutable, NonSSA> { pub fn flag_write(&self) -> Option { use self::LowLevelILExpressionKind::*; diff --git a/rust/src/low_level_il/instruction.rs b/rust/src/low_level_il/instruction.rs index a1253df5..ded9c6f3 100644 --- a/rust/src/low_level_il/instruction.rs +++ b/rust/src/low_level_il/instruction.rs @@ -100,7 +100,7 @@ where } } -impl<'func, M, F> Debug for LowLevelILInstruction<'func, M, F> +impl Debug for LowLevelILInstruction<'_, M, F> where M: FunctionMutability, F: FunctionForm, diff --git a/rust/src/low_level_il/lifting.rs b/rust/src/low_level_il/lifting.rs index c40f68f2..b0f85f11 100644 --- a/rust/src/low_level_il/lifting.rs +++ b/rust/src/low_level_il/lifting.rs @@ -667,7 +667,7 @@ impl<'a> LiftableLowLevelILWithSize<'a> } } -impl<'func, R> LowLevelILExpression<'func, Mutable, NonSSA, R> +impl LowLevelILExpression<'_, Mutable, NonSSA, R> where R: ExpressionResultType, { -- cgit v1.3.1