Skip to content

Commit 4a83b60

Browse files
committed
Fix clippy warnings
Also remove uses of ref.
1 parent 8500805 commit 4a83b60

File tree

17 files changed

+205
-213
lines changed

17 files changed

+205
-213
lines changed

main/src/code.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ fn call_x86(code: &Code, cs: &Capstone, insn: &Insn) -> Option<Call> {
164164
if let Some(imm) = is_imm(&op) {
165165
return Some(Call {
166166
from: insn.address(),
167-
to: imm as u64,
167+
to: imm,
168168
});
169169
} else if let Some((_offset, address, size)) = is_ip_offset(insn, &op) {
170170
// TODO: handle `lea rax, [rip + offset]; call rax`

main/src/filter.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,13 @@ fn filter_type(
159159
inline_types: &HashSet<TypeOffset>,
160160
) -> bool {
161161
// Filter by user options.
162-
if !match *ty.kind() {
163-
TypeKind::Base(ref val) => filter_base(val, options),
164-
TypeKind::Def(ref val) => filter_type_def(val, options),
165-
TypeKind::Struct(ref val) => filter_struct(val, options),
166-
TypeKind::Union(ref val) => filter_union(val, options),
167-
TypeKind::Enumeration(ref val) => filter_enumeration(val, options),
168-
TypeKind::Unspecified(ref val) => filter_unspecified(val, options),
162+
if !match ty.kind() {
163+
TypeKind::Base(val) => filter_base(val, options),
164+
TypeKind::Def(val) => filter_type_def(val, options),
165+
TypeKind::Struct(val) => filter_struct(val, options),
166+
TypeKind::Union(val) => filter_union(val, options),
167+
TypeKind::Enumeration(val) => filter_enumeration(val, options),
168+
TypeKind::Unspecified(val) => filter_unspecified(val, options),
169169
TypeKind::Void
170170
| TypeKind::Array(..)
171171
| TypeKind::Function(..)
@@ -175,8 +175,8 @@ fn filter_type(
175175
} {
176176
return false;
177177
}
178-
match *ty.kind() {
179-
TypeKind::Struct(ref val) => {
178+
match ty.kind() {
179+
TypeKind::Struct(val) => {
180180
// Hack for rust closures
181181
// TODO: is there better way of identifying these, or a
182182
// a way to match pairs for diffing?

main/src/lib.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,14 @@ pub use self::print::file::{
2727
};
2828
pub use self::print::{DiffPrefix, HtmlPrinter, Id, Printer, TextPrinter};
2929

30-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30+
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)]
3131
pub enum Sort {
32+
#[default]
3233
None,
3334
Name,
3435
Size,
3536
}
3637

37-
impl Default for Sort {
38-
fn default() -> Self {
39-
Sort::None
40-
}
41-
}
42-
4338
#[derive(Debug, Default, Clone)]
4439
pub struct Options {
4540
pub print_source: bool,

main/src/print/function.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ pub(crate) fn print_instructions(
454454
let mut cfi_next = cfis.next();
455455
loop {
456456
match (&insn_next, cfi_next) {
457-
(&Some(ref insn), Some(cfi)) => {
457+
(Some(insn), Some(cfi)) => {
458458
if cfi.0.is_none() || cfi.0 <= insn.address() {
459459
print_cfi(state, cfi, range)?;
460460
cfi_next = cfis.next();
@@ -463,15 +463,15 @@ pub(crate) fn print_instructions(
463463
insn_next = insns.next();
464464
}
465465
}
466-
(&Some(ref insn), None) => {
466+
(Some(insn), None) => {
467467
insn.print(state, code, &disassembler, details, range)?;
468468
insn_next = insns.next();
469469
}
470-
(&None, Some(cfi)) => {
470+
(None, Some(cfi)) => {
471471
print_cfi(state, cfi, range)?;
472472
cfi_next = cfis.next();
473473
}
474-
(&None, None) => break,
474+
(None, None) => break,
475475
}
476476
}
477477
}

main/src/print/inherit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ impl DiffList for Inherit {
5959

6060
fn diff_cost(state: &DiffState, _arg_a: &(), a: &Self, _arg_b: &(), b: &Self) -> usize {
6161
let mut cost = 0;
62-
match (a.ty(state.hash_a()), b.ty(state.hash_b())) {
63-
(Some(ref ty_a), Some(ref ty_b)) => {
62+
match (&a.ty(state.hash_a()), &b.ty(state.hash_b())) {
63+
(Some(ty_a), Some(ty_b)) => {
6464
if Type::cmp_id(state.hash_a(), ty_a, state.hash_b(), ty_b) != cmp::Ordering::Equal
6565
{
6666
cost += 2;

main/src/print/local_variable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ impl<'a, 'input> DiffList for &'a LocalVariable<'input> {
9393
if a.name().cmp(&b.name()) != cmp::Ordering::Equal {
9494
cost += 1;
9595
}
96-
match (a.ty(state.hash_a()), b.ty(state.hash_b())) {
97-
(Some(ref ty_a), Some(ref ty_b)) => {
96+
match (&a.ty(state.hash_a()), &b.ty(state.hash_b())) {
97+
(Some(ty_a), Some(ty_b)) => {
9898
if Type::cmp_id(state.hash_a(), ty_a, state.hash_b(), ty_b) != cmp::Ordering::Equal
9999
{
100100
cost += 1;

main/src/print/member.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ impl<'input> DiffList for Member<'input> {
119119
if a.name().cmp(&b.name()) != cmp::Ordering::Equal {
120120
cost += 1;
121121
}
122-
match (a.ty(state.hash_a()), b.ty(state.hash_b())) {
123-
(Some(ref ty_a), Some(ref ty_b)) => {
122+
match (&a.ty(state.hash_a()), &b.ty(state.hash_b())) {
123+
(Some(ty_a), Some(ty_b)) => {
124124
if Type::cmp_id(state.hash_a(), ty_a, state.hash_b(), ty_b) != cmp::Ordering::Equal
125125
{
126126
cost += 1;

main/src/print/mod.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -955,21 +955,21 @@ impl<T> MergeResult<T, T> {
955955
Arg: Copy,
956956
F: Fn(&T, Arg, &T, Arg) -> cmp::Ordering,
957957
{
958-
match *x {
959-
MergeResult::Both(_, ref x_right) => match *y {
960-
MergeResult::Both(_, ref y_right) => f(x_right, arg_right, y_right, arg_right),
961-
MergeResult::Left(ref y_left) => f(x_right, arg_right, y_left, arg_left),
962-
MergeResult::Right(ref y_right) => f(x_right, arg_right, y_right, arg_right),
958+
match x {
959+
MergeResult::Both(_, x_right) => match y {
960+
MergeResult::Both(_, y_right) => f(x_right, arg_right, y_right, arg_right),
961+
MergeResult::Left(y_left) => f(x_right, arg_right, y_left, arg_left),
962+
MergeResult::Right(y_right) => f(x_right, arg_right, y_right, arg_right),
963963
},
964-
MergeResult::Left(ref x_left) => match *y {
965-
MergeResult::Both(_, ref y_right) => f(x_left, arg_left, y_right, arg_right),
966-
MergeResult::Left(ref y_left) => f(x_left, arg_left, y_left, arg_left),
967-
MergeResult::Right(ref y_right) => f(x_left, arg_left, y_right, arg_right),
964+
MergeResult::Left(x_left) => match y {
965+
MergeResult::Both(_, y_right) => f(x_left, arg_left, y_right, arg_right),
966+
MergeResult::Left(y_left) => f(x_left, arg_left, y_left, arg_left),
967+
MergeResult::Right(y_right) => f(x_left, arg_left, y_right, arg_right),
968968
},
969-
MergeResult::Right(ref x_right) => match *y {
970-
MergeResult::Both(_, ref y_right) => f(x_right, arg_right, y_right, arg_right),
971-
MergeResult::Left(ref y_left) => f(x_right, arg_right, y_left, arg_left),
972-
MergeResult::Right(ref y_right) => f(x_right, arg_right, y_right, arg_right),
969+
MergeResult::Right(x_right) => match y {
970+
MergeResult::Both(_, y_right) => f(x_right, arg_right, y_right, arg_right),
971+
MergeResult::Left(y_left) => f(x_right, arg_right, y_left, arg_left),
972+
MergeResult::Right(y_right) => f(x_right, arg_right, y_right, arg_right),
973973
},
974974
}
975975
}

main/src/print/parameter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ impl<'input> DiffList for Parameter<'input> {
7676
if a.name().cmp(&b.name()) != cmp::Ordering::Equal {
7777
cost += 1;
7878
}
79-
match (a.ty(state.hash_a()), b.ty(state.hash_b())) {
80-
(Some(ref ty_a), Some(ref ty_b)) => {
79+
match (&a.ty(state.hash_a()), &b.ty(state.hash_b())) {
80+
(Some(ty_a), Some(ty_b)) => {
8181
if Type::cmp_id(state.hash_a(), ty_a, state.hash_b(), ty_b) != cmp::Ordering::Equal
8282
{
8383
cost += 1;

main/src/print/section.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::print::{self, DiffList, DiffState, Print, PrintState, ValuePrinter};
66
use crate::Result;
77

88
fn print_name(section: &Section, w: &mut dyn ValuePrinter) -> Result<()> {
9-
if let Some(ref segment) = section.segment() {
9+
if let Some(segment) = section.segment() {
1010
write!(w, "{},", segment)?;
1111
}
1212
match section.name() {
@@ -17,8 +17,8 @@ fn print_name(section: &Section, w: &mut dyn ValuePrinter) -> Result<()> {
1717
}
1818

1919
fn print_address(section: &Section, w: &mut dyn ValuePrinter) -> Result<()> {
20-
if let Some(ref address) = section.address() {
21-
print::range::print_address(address, w)?;
20+
if let Some(address) = section.address() {
21+
print::range::print_address(&address, w)?;
2222
}
2323
Ok(())
2424
}

0 commit comments

Comments
 (0)