From 8bb4ab351a7a0f371ca758ed82ca50085e6c50fd Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Tue, 26 May 2026 15:21:26 -0400 Subject: [Rust] Fix misc clippy lints --- rust/src/function.rs | 12 ++++------- rust/src/types.rs | 60 +++++++++++++++++++++++----------------------------- 2 files changed, 30 insertions(+), 42 deletions(-) (limited to 'rust/src') diff --git a/rust/src/function.rs b/rust/src/function.rs index dcfe9900..9806a5ca 100644 --- a/rust/src/function.rs +++ b/rust/src/function.rs @@ -1077,7 +1077,7 @@ impl Function { { let locations: Vec = values .into_iter() - .map(|location| ValueLocation::into_rust_raw(&location.into())) + .map(|location| ValueLocation::into_rust_raw(&location)) .collect(); unsafe { BNSetUserFunctionParameterLocations( @@ -1089,9 +1089,7 @@ impl Function { }, ) } - locations - .into_iter() - .for_each(|location| ValueLocation::free_rust_raw(location.into())); + locations.into_iter().for_each(ValueLocation::free_rust_raw); } pub fn set_auto_parameter_locations(&self, values: I, confidence: u8) @@ -1100,7 +1098,7 @@ impl Function { { let locations: Vec = values .into_iter() - .map(|location| ValueLocation::into_rust_raw(&location.into())) + .map(|location| ValueLocation::into_rust_raw(&location)) .collect(); unsafe { BNSetAutoFunctionParameterLocations( @@ -1112,9 +1110,7 @@ impl Function { }, ) } - locations - .into_iter() - .for_each(|location| ValueLocation::free_rust_raw(location.into())); + locations.into_iter().for_each(ValueLocation::free_rust_raw); } pub fn parameter_at( diff --git a/rust/src/types.rs b/rust/src/types.rs index 167c8bbd..7ca6f33b 100644 --- a/rust/src/types.rs +++ b/rust/src/types.rs @@ -449,7 +449,7 @@ impl TypeBuilder { // TODO: Deprecate this for a FunctionBuilder (along with the Type variant?) /// NOTE: This is likely to be deprecated and removed in favor of a function type builder, please /// use [`Type::function`] where possible. - pub fn function<'a, T: Into>( + pub fn function>( return_value: T, parameters: Vec, variable_arguments: bool, @@ -500,11 +500,7 @@ impl TypeBuilder { // TODO: Deprecate this for a FunctionBuilder (along with the Type variant?) /// NOTE: This is likely to be deprecated and removed in favor of a function type builder, please /// use [`Type::function_with_opts`] where possible. - pub fn function_with_opts< - 'a, - T: Into, - C: Into>>, - >( + pub fn function_with_opts, C: Into>>>( return_value: T, parameters: &[FunctionParameter], variable_arguments: bool, @@ -929,7 +925,7 @@ impl Type { } // TODO: FunctionBuilder - pub fn function<'a, T: Into>( + pub fn function>( return_value: T, parameters: Vec, variable_arguments: bool, @@ -979,11 +975,7 @@ impl Type { } // TODO: FunctionBuilder - pub fn function_with_opts< - 'a, - T: Into, - C: Into>>, - >( + pub fn function_with_opts, C: Into>>>( return_value: T, parameters: &[FunctionParameter], variable_arguments: bool, @@ -1253,7 +1245,7 @@ impl ValueLocation { } pub fn variable_for_return_value(&self) -> Option { - let value_raw = Self::into_rust_raw(&self); + let value_raw = Self::into_rust_raw(self); let mut var_raw = BNVariable::default(); let valid = unsafe { BNGetValueLocationVariableForReturnValue(&value_raw, &mut var_raw) }; Self::free_rust_raw(value_raw); @@ -1265,7 +1257,7 @@ impl ValueLocation { } pub fn variable_for_parameter(&self, idx: usize) -> Option { - let value_raw = Self::into_rust_raw(&self); + let value_raw = Self::into_rust_raw(self); let mut var_raw = BNVariable::default(); let valid = unsafe { BNGetValueLocationVariableForParameter(&value_raw, &mut var_raw, idx) }; @@ -1283,7 +1275,7 @@ impl ValueLocation { Self { components: components_raw .iter() - .map(|component| ValueLocationComponent::from_raw(component)) + .map(ValueLocationComponent::from_raw) .collect(), indirect: loc.indirect, returned_pointer: if loc.returnedPointerValid { @@ -1298,7 +1290,7 @@ impl ValueLocation { let components: Box<[BNValueLocationComponent]> = value .components .iter() - .map(|component| ValueLocationComponent::into_raw(component)) + .map(ValueLocationComponent::into_raw) .collect(); BNValueLocation { count: components.len(), @@ -1321,11 +1313,11 @@ impl ValueLocation { } } -impl Into for Variable { - fn into(self) -> ValueLocation { +impl From for ValueLocation { + fn from(value: Variable) -> Self { ValueLocation { components: vec![ValueLocationComponent { - variable: self, + variable: value, offset: 0, size: None, }], @@ -1397,46 +1389,46 @@ impl ReturnValue { } } -impl Into for Ref { - fn into(self) -> ReturnValue { +impl From> for ReturnValue { + fn from(value: Ref) -> ReturnValue { ReturnValue { - ty: self.into(), + ty: value.into(), location: None, } } } -impl Into for &Ref { - fn into(self) -> ReturnValue { +impl From<&Ref> for ReturnValue { + fn from(value: &Ref) -> ReturnValue { ReturnValue { - ty: self.clone().into(), + ty: value.clone().into(), location: None, } } } -impl Into for &Type { - fn into(self) -> ReturnValue { +impl From<&Type> for ReturnValue { + fn from(value: &Type) -> ReturnValue { ReturnValue { - ty: self.to_owned().into(), + ty: value.to_owned().into(), location: None, } } } -impl Into for Conf> { - fn into(self) -> ReturnValue { +impl From>> for ReturnValue { + fn from(value: Conf>) -> ReturnValue { ReturnValue { - ty: self, + ty: value, location: None, } } } -impl Into for &Conf> { - fn into(self) -> ReturnValue { +impl From<&Conf>> for ReturnValue { + fn from(value: &Conf>) -> ReturnValue { ReturnValue { - ty: self.clone(), + ty: value.clone(), location: None, } } -- cgit v1.3.1