Skip to content

Commit cfc5d94

Browse files
committed
cargo +nightly fmt
1 parent 80806c6 commit cfc5d94

File tree

29 files changed

+209
-443
lines changed

29 files changed

+209
-443
lines changed

objdiff-cli/src/argp_version.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ use std::ffi::OsStr;
77
use argp::{EarlyExit, FromArgs, TopLevelCommand, parser::ParseGlobalOptions};
88

99
struct ArgsOrVersion<T>(T)
10-
where
11-
T: FromArgs;
10+
where T: FromArgs;
1211

1312
impl<T> TopLevelCommand for ArgsOrVersion<T> where T: FromArgs {}
1413

1514
impl<T> FromArgs for ArgsOrVersion<T>
16-
where
17-
T: FromArgs,
15+
where T: FromArgs
1816
{
1917
fn _from_args(
2018
command_name: &[&str],
@@ -60,8 +58,6 @@ where
6058
/// This function will exit early from the current process if argument parsing was unsuccessful or if information like `--help` was requested.
6159
/// Error messages will be printed to stderr, and `--help` output to stdout.
6260
pub fn from_env<T>() -> T
63-
where
64-
T: TopLevelCommand,
65-
{
61+
where T: TopLevelCommand {
6662
argp::parse_args_or_exit::<ArgsOrVersion<T>>(argp::DEFAULT).0
6763
}

objdiff-cli/src/cmd/diff.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,9 @@ impl AppState {
322322
pub struct TermWaker(pub AtomicBool);
323323

324324
impl Wake for TermWaker {
325-
fn wake(self: Arc<Self>) {
326-
self.0.store(true, Ordering::Relaxed);
327-
}
325+
fn wake(self: Arc<Self>) { self.0.store(true, Ordering::Relaxed); }
328326

329-
fn wake_by_ref(self: &Arc<Self>) {
330-
self.0.store(true, Ordering::Relaxed);
331-
}
327+
fn wake_by_ref(self: &Arc<Self>) { self.0.store(true, Ordering::Relaxed); }
332328
}
333329

334330
fn run_interactive(

objdiff-core/src/arch/arm.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,10 @@ impl ArchArm {
4343
&& s.name() == Ok(".ARM.attributes")
4444
}) {
4545
let attr_data = arm_attrs.uncompressed_data()?;
46-
let build_attrs = BuildAttrs::new(
47-
&attr_data,
48-
match file.endianness() {
49-
object::Endianness::Little => arm_attr::Endian::Little,
50-
object::Endianness::Big => arm_attr::Endian::Big,
51-
},
52-
)?;
46+
let build_attrs = BuildAttrs::new(&attr_data, match file.endianness() {
47+
object::Endianness::Little => arm_attr::Endian::Little,
48+
object::Endianness::Big => arm_attr::Endian::Big,
49+
})?;
5350
for subsection in build_attrs.subsections() {
5451
let subsection = subsection?;
5552
if !subsection.is_aeabi() {

objdiff-core/src/arch/arm64.rs

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ use crate::{
2121
pub struct ArchArm64 {}
2222

2323
impl ArchArm64 {
24-
pub fn new(_file: &object::File) -> Result<Self> {
25-
Ok(Self {})
26-
}
24+
pub fn new(_file: &object::File) -> Result<Self> { Ok(Self {}) }
2725
}
2826

2927
impl Arch for ArchArm64 {
@@ -188,9 +186,7 @@ struct DisplayCtx<'a> {
188186
// Reworked for more structured output. The library only gives us a Display impl, and no way to
189187
// capture any of this information, so it needs to be reimplemented here.
190188
fn display_instruction<Cb>(args: &mut Cb, ins: &Instruction, ctx: &mut DisplayCtx) -> &'static str
191-
where
192-
Cb: FnMut(InstructionPart<'static>),
193-
{
189+
where Cb: FnMut(InstructionPart<'static>) {
194190
let mnemonic = match ins.opcode {
195191
Opcode::Invalid => return "<invalid>",
196192
Opcode::UDF => "udf",
@@ -2005,17 +2001,13 @@ fn condition_code(cond: u8) -> &'static str {
20052001

20062002
#[inline]
20072003
fn push_register<Cb>(args: &mut Cb, size: SizeCode, reg: u16, sp: bool)
2008-
where
2009-
Cb: FnMut(InstructionPart<'static>),
2010-
{
2004+
where Cb: FnMut(InstructionPart<'static>) {
20112005
push_opaque(args, reg_name(size, reg, sp));
20122006
}
20132007

20142008
#[inline]
20152009
fn push_shift<Cb>(args: &mut Cb, style: ShiftStyle, amount: u8)
2016-
where
2017-
Cb: FnMut(InstructionPart<'static>),
2018-
{
2010+
where Cb: FnMut(InstructionPart<'static>) {
20192011
push_opaque(args, shift_style(style));
20202012
if amount != 0 {
20212013
push_plain(args, " ");
@@ -2025,16 +2017,12 @@ where
20252017

20262018
#[inline]
20272019
fn push_condition_code<Cb>(args: &mut Cb, cond: u8)
2028-
where
2029-
Cb: FnMut(InstructionPart<'static>),
2030-
{
2020+
where Cb: FnMut(InstructionPart<'static>) {
20312021
push_opaque(args, condition_code(cond));
20322022
}
20332023

20342024
fn push_barrier<Cb>(args: &mut Cb, option: u8)
2035-
where
2036-
Cb: FnMut(InstructionPart<'static>),
2037-
{
2025+
where Cb: FnMut(InstructionPart<'static>) {
20382026
match option {
20392027
0b0001 => push_opaque(args, "oshld"),
20402028
0b0010 => push_opaque(args, "oshst"),
@@ -2054,42 +2042,32 @@ where
20542042

20552043
#[inline]
20562044
fn push_opaque<'a, Cb>(args: &mut Cb, text: &'a str)
2057-
where
2058-
Cb: FnMut(InstructionPart<'a>),
2059-
{
2045+
where Cb: FnMut(InstructionPart<'a>) {
20602046
args(InstructionPart::opaque(text));
20612047
}
20622048

20632049
#[inline]
20642050
fn push_plain<Cb>(args: &mut Cb, text: &'static str)
2065-
where
2066-
Cb: FnMut(InstructionPart<'static>),
2067-
{
2051+
where Cb: FnMut(InstructionPart<'static>) {
20682052
args(InstructionPart::basic(text));
20692053
}
20702054

20712055
#[inline]
20722056
fn push_separator<Cb>(args: &mut Cb)
2073-
where
2074-
Cb: FnMut(InstructionPart<'static>),
2075-
{
2057+
where Cb: FnMut(InstructionPart<'static>) {
20762058
args(InstructionPart::separator());
20772059
}
20782060

20792061
#[inline]
20802062
fn push_unsigned<Cb>(args: &mut Cb, v: u64)
2081-
where
2082-
Cb: FnMut(InstructionPart<'static>),
2083-
{
2063+
where Cb: FnMut(InstructionPart<'static>) {
20842064
push_plain(args, "#");
20852065
args(InstructionPart::unsigned(v));
20862066
}
20872067

20882068
#[inline]
20892069
fn push_signed<Cb>(args: &mut Cb, v: i64)
2090-
where
2091-
Cb: FnMut(InstructionPart<'static>),
2092-
{
2070+
where Cb: FnMut(InstructionPart<'static>) {
20932071
push_plain(args, "#");
20942072
args(InstructionPart::signed(v));
20952073
}
@@ -2129,9 +2107,7 @@ fn is_reg_index_reloc(resolved: Option<ResolvedRelocation>) -> bool {
21292107
}
21302108

21312109
fn push_operand<Cb>(args: &mut Cb, o: &Operand, ctx: &mut DisplayCtx)
2132-
where
2133-
Cb: FnMut(InstructionPart<'static>),
2134-
{
2110+
where Cb: FnMut(InstructionPart<'static>) {
21352111
match o {
21362112
Operand::Nothing => unreachable!(),
21372113
Operand::PCOffset(off) => {

objdiff-core/src/arch/mod.rs

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -143,26 +143,20 @@ impl DataType {
143143
DataType::Float => {
144144
let bytes: [u8; 4] = bytes.try_into().unwrap();
145145
strs.push((
146-
format!(
147-
"{:?}f",
148-
match endian {
149-
object::Endianness::Little => f32::from_le_bytes(bytes),
150-
object::Endianness::Big => f32::from_be_bytes(bytes),
151-
}
152-
),
146+
format!("{:?}f", match endian {
147+
object::Endianness::Little => f32::from_le_bytes(bytes),
148+
object::Endianness::Big => f32::from_be_bytes(bytes),
149+
}),
153150
None,
154151
));
155152
}
156153
DataType::Double => {
157154
let bytes: [u8; 8] = bytes.try_into().unwrap();
158155
strs.push((
159-
format!(
160-
"{:?}",
161-
match endian {
162-
object::Endianness::Little => f64::from_le_bytes(bytes),
163-
object::Endianness::Big => f64::from_be_bytes(bytes),
164-
}
165-
),
156+
format!("{:?}", match endian {
157+
object::Endianness::Little => f64::from_le_bytes(bytes),
158+
object::Endianness::Big => f64::from_be_bytes(bytes),
159+
}),
166160
None,
167161
));
168162
}
@@ -377,15 +371,11 @@ pub trait Arch: Any + Debug + Send + Sync {
377371
Ok(None)
378372
}
379373

380-
fn reloc_name(&self, _flags: RelocationFlags) -> Option<&'static str> {
381-
None
382-
}
374+
fn reloc_name(&self, _flags: RelocationFlags) -> Option<&'static str> { None }
383375

384376
fn data_reloc_size(&self, flags: RelocationFlags) -> usize;
385377

386-
fn symbol_address(&self, address: u64, _kind: SymbolKind) -> u64 {
387-
address
388-
}
378+
fn symbol_address(&self, address: u64, _kind: SymbolKind) -> u64 { address }
389379

390380
fn extra_symbol_flags(&self, _symbol: &object::Symbol) -> SymbolFlagSet {
391381
SymbolFlagSet::default()
@@ -399,13 +389,9 @@ pub trait Arch: Any + Debug + Send + Sync {
399389
None
400390
}
401391

402-
fn symbol_hover(&self, _obj: &Object, _symbol_index: usize) -> Vec<HoverItem> {
403-
Vec::new()
404-
}
392+
fn symbol_hover(&self, _obj: &Object, _symbol_index: usize) -> Vec<HoverItem> { Vec::new() }
405393

406-
fn symbol_context(&self, _obj: &Object, _symbol_index: usize) -> Vec<ContextItem> {
407-
Vec::new()
408-
}
394+
fn symbol_context(&self, _obj: &Object, _symbol_index: usize) -> Vec<ContextItem> { Vec::new() }
409395

410396
fn instruction_hover(
411397
&self,
@@ -463,9 +449,7 @@ pub fn new_arch(object: &object::File, diff_side: DiffSide) -> Result<Box<dyn Ar
463449
pub struct ArchDummy {}
464450

465451
impl ArchDummy {
466-
pub fn new() -> Box<Self> {
467-
Box::new(Self {})
468-
}
452+
pub fn new() -> Box<Self> { Box::new(Self {}) }
469453
}
470454

471455
impl Arch for ArchDummy {
@@ -489,9 +473,7 @@ impl Arch for ArchDummy {
489473
Ok(())
490474
}
491475

492-
fn data_reloc_size(&self, _flags: RelocationFlags) -> usize {
493-
0
494-
}
476+
fn data_reloc_size(&self, _flags: RelocationFlags) -> usize { 0 }
495477
}
496478

497479
#[derive(Debug, Clone, Copy, PartialEq, Eq)]

objdiff-core/src/arch/ppc/flow_analysis.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ impl RegisterState {
175175
impl Index<powerpc::GPR> for RegisterState {
176176
type Output = RegisterContent;
177177

178-
fn index(&self, gpr: powerpc::GPR) -> &Self::Output {
179-
&self.gpr[gpr.0 as usize]
180-
}
178+
fn index(&self, gpr: powerpc::GPR) -> &Self::Output { &self.gpr[gpr.0 as usize] }
181179
}
182180
impl IndexMut<powerpc::GPR> for RegisterState {
183181
fn index_mut(&mut self, gpr: powerpc::GPR) -> &mut Self::Output {
@@ -188,9 +186,7 @@ impl IndexMut<powerpc::GPR> for RegisterState {
188186
impl Index<powerpc::FPR> for RegisterState {
189187
type Output = RegisterContent;
190188

191-
fn index(&self, fpr: powerpc::FPR) -> &Self::Output {
192-
&self.fpr[fpr.0 as usize]
193-
}
189+
fn index(&self, fpr: powerpc::FPR) -> &Self::Output { &self.fpr[fpr.0 as usize] }
194190
}
195191
impl IndexMut<powerpc::FPR> for RegisterState {
196192
fn index_mut(&mut self, fpr: powerpc::FPR) -> &mut Self::Output {
@@ -300,9 +296,7 @@ impl PPCFlowAnalysisResult {
300296
self.argument_contents.insert((address, argument), value);
301297
}
302298

303-
fn new() -> Self {
304-
PPCFlowAnalysisResult { argument_contents: Default::default() }
305-
}
299+
fn new() -> Self { PPCFlowAnalysisResult { argument_contents: Default::default() } }
306300
}
307301

308302
impl FlowAnalysisResult for PPCFlowAnalysisResult {
@@ -383,9 +377,7 @@ fn fill_registers_from_relocation(
383377
// See: https://github.com/encounter/decomp-toolkit/blob/main/src/analysis/pass.rs
384378
const SLEDS: [&str; 6] = ["_savefpr_", "_restfpr_", "_savegpr_", "_restgpr_", "_savev", "_restv"];
385379

386-
fn is_sled_function(name: &str) -> bool {
387-
SLEDS.iter().any(|sled| name.starts_with(sled))
388-
}
380+
fn is_sled_function(name: &str) -> bool { SLEDS.iter().any(|sled| name.starts_with(sled)) }
389381

390382
pub fn ppc_data_flow_analysis(
391383
obj: &Object,

objdiff-core/src/arch/ppc/mod.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ fn is_rel_abs_arg(arg: &powerpc::Argument) -> bool {
4545
)
4646
}
4747

48-
fn is_offset_arg(arg: &powerpc::Argument) -> bool {
49-
matches!(arg, powerpc::Argument::Offset(_))
50-
}
48+
fn is_offset_arg(arg: &powerpc::Argument) -> bool { matches!(arg, powerpc::Argument::Offset(_)) }
5149

5250
#[derive(Debug)]
5351
pub struct ArchPpc {
@@ -230,10 +228,9 @@ impl Arch for ArchPpc {
230228
.skip_while(|&(a, _)| a < address)
231229
.take_while(|&(a, _)| a == address)
232230
.find(|(_, reloc)| {
233-
matches!(
234-
reloc.flags(),
235-
object::RelocationFlags::Coff { typ: pe::IMAGE_REL_PPC_PAIR }
236-
)
231+
matches!(reloc.flags(), object::RelocationFlags::Coff {
232+
typ: pe::IMAGE_REL_PPC_PAIR
233+
})
237234
})
238235
.map_or(
239236
Ok(Some(RelocationOverride {
@@ -627,15 +624,12 @@ fn decode_exception_info(
627624
};
628625

629626
//Add the new entry to the list
630-
result.insert(
631-
extab_func.index().0 - 1,
632-
ExceptionInfo {
633-
eti_symbol: make_symbol_ref(&extabindex)?,
634-
etb_symbol: make_symbol_ref(&extab)?,
635-
data,
636-
dtors,
637-
},
638-
);
627+
result.insert(extab_func.index().0 - 1, ExceptionInfo {
628+
eti_symbol: make_symbol_ref(&extabindex)?,
629+
etb_symbol: make_symbol_ref(&extab)?,
630+
data,
631+
dtors,
632+
});
639633
}
640634

641635
Ok(Some(result))

objdiff-core/src/arch/superh/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ pub mod disasm;
1515
pub struct ArchSuperH {}
1616

1717
impl ArchSuperH {
18-
pub fn new(_file: &object::File) -> Result<Self> {
19-
Ok(Self {})
20-
}
18+
pub fn new(_file: &object::File) -> Result<Self> { Ok(Self {}) }
2119
}
2220

2321
struct DataInfo {

0 commit comments

Comments
 (0)