Skip to content

Commit 8bb4ab3

Browse files
committed
[Rust] Fix misc clippy lints
1 parent 39201de commit 8bb4ab3

2 files changed

Lines changed: 30 additions & 42 deletions

File tree

rust/src/function.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ impl Function {
10771077
{
10781078
let locations: Vec<BNValueLocation> = values
10791079
.into_iter()
1080-
.map(|location| ValueLocation::into_rust_raw(&location.into()))
1080+
.map(|location| ValueLocation::into_rust_raw(&location))
10811081
.collect();
10821082
unsafe {
10831083
BNSetUserFunctionParameterLocations(
@@ -1089,9 +1089,7 @@ impl Function {
10891089
},
10901090
)
10911091
}
1092-
locations
1093-
.into_iter()
1094-
.for_each(|location| ValueLocation::free_rust_raw(location.into()));
1092+
locations.into_iter().for_each(ValueLocation::free_rust_raw);
10951093
}
10961094

10971095
pub fn set_auto_parameter_locations<I>(&self, values: I, confidence: u8)
@@ -1100,7 +1098,7 @@ impl Function {
11001098
{
11011099
let locations: Vec<BNValueLocation> = values
11021100
.into_iter()
1103-
.map(|location| ValueLocation::into_rust_raw(&location.into()))
1101+
.map(|location| ValueLocation::into_rust_raw(&location))
11041102
.collect();
11051103
unsafe {
11061104
BNSetAutoFunctionParameterLocations(
@@ -1112,9 +1110,7 @@ impl Function {
11121110
},
11131111
)
11141112
}
1115-
locations
1116-
.into_iter()
1117-
.for_each(|location| ValueLocation::free_rust_raw(location.into()));
1113+
locations.into_iter().for_each(ValueLocation::free_rust_raw);
11181114
}
11191115

11201116
pub fn parameter_at(

rust/src/types.rs

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ impl TypeBuilder {
449449
// TODO: Deprecate this for a FunctionBuilder (along with the Type variant?)
450450
/// NOTE: This is likely to be deprecated and removed in favor of a function type builder, please
451451
/// use [`Type::function`] where possible.
452-
pub fn function<'a, T: Into<ReturnValue>>(
452+
pub fn function<T: Into<ReturnValue>>(
453453
return_value: T,
454454
parameters: Vec<FunctionParameter>,
455455
variable_arguments: bool,
@@ -500,11 +500,7 @@ impl TypeBuilder {
500500
// TODO: Deprecate this for a FunctionBuilder (along with the Type variant?)
501501
/// NOTE: This is likely to be deprecated and removed in favor of a function type builder, please
502502
/// use [`Type::function_with_opts`] where possible.
503-
pub fn function_with_opts<
504-
'a,
505-
T: Into<ReturnValue>,
506-
C: Into<Conf<Ref<CoreCallingConvention>>>,
507-
>(
503+
pub fn function_with_opts<T: Into<ReturnValue>, C: Into<Conf<Ref<CoreCallingConvention>>>>(
508504
return_value: T,
509505
parameters: &[FunctionParameter],
510506
variable_arguments: bool,
@@ -929,7 +925,7 @@ impl Type {
929925
}
930926

931927
// TODO: FunctionBuilder
932-
pub fn function<'a, T: Into<ReturnValue>>(
928+
pub fn function<T: Into<ReturnValue>>(
933929
return_value: T,
934930
parameters: Vec<FunctionParameter>,
935931
variable_arguments: bool,
@@ -979,11 +975,7 @@ impl Type {
979975
}
980976

981977
// TODO: FunctionBuilder
982-
pub fn function_with_opts<
983-
'a,
984-
T: Into<ReturnValue>,
985-
C: Into<Conf<Ref<CoreCallingConvention>>>,
986-
>(
978+
pub fn function_with_opts<T: Into<ReturnValue>, C: Into<Conf<Ref<CoreCallingConvention>>>>(
987979
return_value: T,
988980
parameters: &[FunctionParameter],
989981
variable_arguments: bool,
@@ -1253,7 +1245,7 @@ impl ValueLocation {
12531245
}
12541246

12551247
pub fn variable_for_return_value(&self) -> Option<Variable> {
1256-
let value_raw = Self::into_rust_raw(&self);
1248+
let value_raw = Self::into_rust_raw(self);
12571249
let mut var_raw = BNVariable::default();
12581250
let valid = unsafe { BNGetValueLocationVariableForReturnValue(&value_raw, &mut var_raw) };
12591251
Self::free_rust_raw(value_raw);
@@ -1265,7 +1257,7 @@ impl ValueLocation {
12651257
}
12661258

12671259
pub fn variable_for_parameter(&self, idx: usize) -> Option<Variable> {
1268-
let value_raw = Self::into_rust_raw(&self);
1260+
let value_raw = Self::into_rust_raw(self);
12691261
let mut var_raw = BNVariable::default();
12701262
let valid =
12711263
unsafe { BNGetValueLocationVariableForParameter(&value_raw, &mut var_raw, idx) };
@@ -1283,7 +1275,7 @@ impl ValueLocation {
12831275
Self {
12841276
components: components_raw
12851277
.iter()
1286-
.map(|component| ValueLocationComponent::from_raw(component))
1278+
.map(ValueLocationComponent::from_raw)
12871279
.collect(),
12881280
indirect: loc.indirect,
12891281
returned_pointer: if loc.returnedPointerValid {
@@ -1298,7 +1290,7 @@ impl ValueLocation {
12981290
let components: Box<[BNValueLocationComponent]> = value
12991291
.components
13001292
.iter()
1301-
.map(|component| ValueLocationComponent::into_raw(component))
1293+
.map(ValueLocationComponent::into_raw)
13021294
.collect();
13031295
BNValueLocation {
13041296
count: components.len(),
@@ -1321,11 +1313,11 @@ impl ValueLocation {
13211313
}
13221314
}
13231315

1324-
impl Into<ValueLocation> for Variable {
1325-
fn into(self) -> ValueLocation {
1316+
impl From<Variable> for ValueLocation {
1317+
fn from(value: Variable) -> Self {
13261318
ValueLocation {
13271319
components: vec![ValueLocationComponent {
1328-
variable: self,
1320+
variable: value,
13291321
offset: 0,
13301322
size: None,
13311323
}],
@@ -1397,46 +1389,46 @@ impl ReturnValue {
13971389
}
13981390
}
13991391

1400-
impl Into<ReturnValue> for Ref<Type> {
1401-
fn into(self) -> ReturnValue {
1392+
impl From<Ref<Type>> for ReturnValue {
1393+
fn from(value: Ref<Type>) -> ReturnValue {
14021394
ReturnValue {
1403-
ty: self.into(),
1395+
ty: value.into(),
14041396
location: None,
14051397
}
14061398
}
14071399
}
14081400

1409-
impl Into<ReturnValue> for &Ref<Type> {
1410-
fn into(self) -> ReturnValue {
1401+
impl From<&Ref<Type>> for ReturnValue {
1402+
fn from(value: &Ref<Type>) -> ReturnValue {
14111403
ReturnValue {
1412-
ty: self.clone().into(),
1404+
ty: value.clone().into(),
14131405
location: None,
14141406
}
14151407
}
14161408
}
14171409

1418-
impl Into<ReturnValue> for &Type {
1419-
fn into(self) -> ReturnValue {
1410+
impl From<&Type> for ReturnValue {
1411+
fn from(value: &Type) -> ReturnValue {
14201412
ReturnValue {
1421-
ty: self.to_owned().into(),
1413+
ty: value.to_owned().into(),
14221414
location: None,
14231415
}
14241416
}
14251417
}
14261418

1427-
impl Into<ReturnValue> for Conf<Ref<Type>> {
1428-
fn into(self) -> ReturnValue {
1419+
impl From<Conf<Ref<Type>>> for ReturnValue {
1420+
fn from(value: Conf<Ref<Type>>) -> ReturnValue {
14291421
ReturnValue {
1430-
ty: self,
1422+
ty: value,
14311423
location: None,
14321424
}
14331425
}
14341426
}
14351427

1436-
impl Into<ReturnValue> for &Conf<Ref<Type>> {
1437-
fn into(self) -> ReturnValue {
1428+
impl From<&Conf<Ref<Type>>> for ReturnValue {
1429+
fn from(value: &Conf<Ref<Type>>) -> ReturnValue {
14381430
ReturnValue {
1439-
ty: self.clone(),
1431+
ty: value.clone(),
14401432
location: None,
14411433
}
14421434
}

0 commit comments

Comments
 (0)