From 8756eee07bf7aab171c14918dddcec54c46e3512 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Mon, 7 Jul 2025 14:56:41 -0600 Subject: [PATCH] clippy fixes & version bump --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- objdiff-cli/src/cmd/diff.rs | 10 +++------- objdiff-cli/src/cmd/report.rs | 12 +++++------- objdiff-cli/src/views/function_diff.rs | 8 ++++---- objdiff-core/config_gen.rs | 10 +++++----- objdiff-core/src/arch/arm.rs | 2 +- objdiff-core/src/arch/arm64.rs | 2 +- objdiff-core/src/arch/mod.rs | 18 +++++++++--------- objdiff-core/src/arch/ppc/flow_analysis.rs | 2 +- objdiff-core/src/arch/ppc/mod.rs | 6 ++---- objdiff-core/src/arch/superh/disasm.rs | 2 +- objdiff-core/src/arch/superh/mod.rs | 4 ++-- objdiff-core/src/bindings/report.rs | 2 +- objdiff-core/src/diff/display.rs | 10 +++++----- objdiff-core/src/diff/mod.rs | 6 +----- objdiff-core/src/jobs/objdiff.rs | 22 ++++++++-------------- objdiff-core/src/obj/mod.rs | 6 +++--- objdiff-core/src/obj/read.rs | 8 ++++---- objdiff-gui/src/fonts/mod.rs | 6 +++--- objdiff-gui/src/views/appearance.rs | 8 ++++---- objdiff-gui/src/views/config.rs | 6 +++--- objdiff-gui/src/views/diff.rs | 4 ++-- objdiff-gui/src/views/function_diff.rs | 6 +++--- objdiff-gui/src/views/graphics.rs | 2 +- objdiff-gui/src/views/jobs.rs | 8 +++----- objdiff-gui/src/views/symbol_diff.rs | 8 ++++++-- objdiff-wasm/package-lock.json | 4 ++-- objdiff-wasm/package.json | 2 +- 29 files changed, 89 insertions(+), 105 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f7ee9db..381bc60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3373,7 +3373,7 @@ dependencies = [ [[package]] name = "objdiff-cli" -version = "3.0.0-beta.10" +version = "3.0.0-beta.11" dependencies = [ "anyhow", "argp", @@ -3396,7 +3396,7 @@ dependencies = [ [[package]] name = "objdiff-core" -version = "3.0.0-beta.10" +version = "3.0.0-beta.11" dependencies = [ "anyhow", "arm-attr", @@ -3450,7 +3450,7 @@ dependencies = [ [[package]] name = "objdiff-gui" -version = "3.0.0-beta.10" +version = "3.0.0-beta.11" dependencies = [ "anyhow", "cfg-if", @@ -3486,7 +3486,7 @@ dependencies = [ [[package]] name = "objdiff-wasm" -version = "3.0.0-beta.10" +version = "3.0.0-beta.11" dependencies = [ "log", "objdiff-core", diff --git a/Cargo.toml b/Cargo.toml index 33744cd..6bc0ad4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ strip = "debuginfo" codegen-units = 1 [workspace.package] -version = "3.0.0-beta.10" +version = "3.0.0-beta.11" authors = ["Luke Street "] edition = "2024" license = "MIT OR Apache-2.0" diff --git a/objdiff-cli/src/cmd/diff.rs b/objdiff-cli/src/cmd/diff.rs index 0d79f35..a52d34b 100644 --- a/objdiff-cli/src/cmd/diff.rs +++ b/objdiff-cli/src/cmd/diff.rs @@ -203,14 +203,10 @@ fn run_oneshot( let output_format = OutputFormat::from_option(args.format.as_deref())?; let (diff_config, mapping_config) = build_config_from_args(args)?; let target = target_path - .map(|p| { - obj::read::read(p.as_ref(), &diff_config).with_context(|| format!("Loading {}", p)) - }) + .map(|p| obj::read::read(p.as_ref(), &diff_config).with_context(|| format!("Loading {p}"))) .transpose()?; let base = base_path - .map(|p| { - obj::read::read(p.as_ref(), &diff_config).with_context(|| format!("Loading {}", p)) - }) + .map(|p| obj::read::read(p.as_ref(), &diff_config).with_context(|| format!("Loading {p}"))) .transpose()?; let result = diff::diff_objs(target.as_ref(), base.as_ref(), None, &diff_config, &mapping_config)?; @@ -399,7 +395,7 @@ fn run_interactive( stdout(), EnterAlternateScreen, EnableMouseCapture, - SetTitle(format!("{} - objdiff", symbol_name)), + SetTitle(format!("{symbol_name} - objdiff")), )?; let backend = CrosstermBackend::new(stdout()); let mut terminal = Terminal::new(backend)?; diff --git a/objdiff-cli/src/cmd/report.rs b/objdiff-cli/src/cmd/report.rs index 3a5f218..7c7decc 100644 --- a/objdiff-cli/src/cmd/report.rs +++ b/objdiff-cli/src/cmd/report.rs @@ -177,16 +177,14 @@ fn report_object( .target_path .as_ref() .map(|p| { - obj::read::read(p.as_ref(), diff_config) - .with_context(|| format!("Failed to open {}", p)) + obj::read::read(p.as_ref(), diff_config).with_context(|| format!("Failed to open {p}")) }) .transpose()?; let base = object .base_path .as_ref() .map(|p| { - obj::read::read(p.as_ref(), diff_config) - .with_context(|| format!("Failed to open {}", p)) + obj::read::read(p.as_ref(), diff_config).with_context(|| format!("Failed to open {p}")) }) .transpose()?; let result = @@ -433,8 +431,8 @@ fn read_report(path: &Utf8PlatformPath) -> Result { std::io::stdin().read_to_end(&mut data)?; return Report::parse(&data).with_context(|| "Failed to load report from stdin"); } - let file = File::open(path).with_context(|| format!("Failed to open {}", path))?; + let file = File::open(path).with_context(|| format!("Failed to open {path}"))?; let mmap = - unsafe { memmap2::Mmap::map(&file) }.with_context(|| format!("Failed to map {}", path))?; - Report::parse(mmap.as_ref()).with_context(|| format!("Failed to load report {}", path)) + unsafe { memmap2::Mmap::map(&file) }.with_context(|| format!("Failed to map {path}"))?; + Report::parse(mmap.as_ref()).with_context(|| format!("Failed to load report {path}")) } diff --git a/objdiff-cli/src/views/function_diff.rs b/objdiff-cli/src/views/function_diff.rs index a0472e5..4a767ec 100644 --- a/objdiff-cli/src/views/function_diff.rs +++ b/objdiff-cli/src/views/function_diff.rs @@ -87,7 +87,7 @@ impl UiView for FunctionDiffUi { .and_then(|(_, _, d)| d.match_percent) { line_r.spans.push(Span::styled( - format!("{:.2}% ", percent), + format!("{percent:.2}% "), Style::new().fg(match_percent_color(percent)), )); } @@ -97,7 +97,7 @@ impl UiView for FunctionDiffUi { .and_then(|t| t.format(&state.time_format).ok()) .unwrap_or_else(|| "N/A".to_string()); line_r.spans.push(Span::styled( - format!("Last reload: {}", reload_time), + format!("Last reload: {reload_time}"), Style::new().fg(Color::White), )); line_r.spans.push(Span::styled( @@ -538,7 +538,7 @@ impl FunctionDiffUi { let label_text = match segment.text { DiffText::Basic(text) => text.to_string(), DiffText::Line(num) => format!("{num} "), - DiffText::Address(addr) => format!("{:x}:", addr), + DiffText::Address(addr) => format!("{addr:x}:"), DiffText::Opcode(mnemonic, _op) => format!("{mnemonic} "), DiffText::Argument(arg) => arg.to_string(), DiffText::BranchDest(addr) => format!("{addr:x}"), @@ -546,7 +546,7 @@ impl FunctionDiffUi { sym.demangled_name.as_ref().unwrap_or(&sym.name).clone() } DiffText::Addend(addend) => match addend.cmp(&0i64) { - Ordering::Greater => format!("+{:#x}", addend), + Ordering::Greater => format!("+{addend:#x}"), Ordering::Less => format!("-{:#x}", -addend), _ => String::new(), }, diff --git a/objdiff-core/config_gen.rs b/objdiff-core/config_gen.rs index c904a78..1642550 100644 --- a/objdiff-core/config_gen.rs +++ b/objdiff-core/config_gen.rs @@ -60,10 +60,10 @@ pub struct ConfigGroup { } fn build_doc(name: &str, description: Option<&str>) -> TokenStream { - let mut doc = format!(" {}", name); + let mut doc = format!(" {name}"); let mut out = quote! { #[doc = #doc] }; if let Some(description) = description { - doc = format!(" {}", description); + doc = format!(" {description}"); out.extend(quote! { #[doc = ""] }); out.extend(quote! { #[doc = #doc] }); } @@ -443,9 +443,9 @@ pub fn generate_diff_config() { } impl core::fmt::Display for ConfigPropertyValue { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - ConfigPropertyValue::Boolean(value) => write!(f, "{}", value), - ConfigPropertyValue::Choice(value) => write!(f, "{}", value), + match *self { + ConfigPropertyValue::Boolean(value) => write!(f, "{value}"), + ConfigPropertyValue::Choice(value) => f.write_str(value), } } } diff --git a/objdiff-core/src/arch/arm.rs b/objdiff-core/src/arch/arm.rs index 45116cd..0760187 100644 --- a/objdiff-core/src/arch/arm.rs +++ b/objdiff-core/src/arch/arm.rs @@ -575,7 +575,7 @@ fn push_args( arg_cb(InstructionPart::basic("}"))?; } args::Argument::CoprocNum(value) => { - arg_cb(InstructionPart::opaque(format!("p{}", value)))?; + arg_cb(InstructionPart::opaque(format!("p{value}")))?; } args::Argument::ShiftImm(shift) => { arg_cb(InstructionPart::opaque(shift.op.to_string()))?; diff --git a/objdiff-core/src/arch/arm64.rs b/objdiff-core/src/arch/arm64.rs index c086029..2308bfc 100644 --- a/objdiff-core/src/arch/arm64.rs +++ b/objdiff-core/src/arch/arm64.rs @@ -2268,7 +2268,7 @@ where Cb: FnMut(InstructionPart<'static>) { push_plain(args, "]"); push_separator(args); // TODO does 31 have to be handled separate? - args(InstructionPart::opaque(format!("x{}", offset_reg))); + args(InstructionPart::opaque(format!("x{offset_reg}"))); } // Fall back to original logic Operand::SIMDRegister(_, _) diff --git a/objdiff-core/src/arch/mod.rs b/objdiff-core/src/arch/mod.rs index 40eddff..ab1e527 100644 --- a/objdiff-core/src/arch/mod.rs +++ b/objdiff-core/src/arch/mod.rs @@ -66,8 +66,8 @@ impl DataType { pub fn display_labels(&self, endian: object::Endianness, bytes: &[u8]) -> Vec { let mut strs = Vec::new(); for (literal, label_override) in self.display_literals(endian, bytes) { - let label = label_override.unwrap_or_else(|| format!("{}", self)); - strs.push(format!("{}: {}", label, literal)) + let label = label_override.unwrap_or_else(|| format!("{self}")); + strs.push(format!("{label}: {literal}")) } strs } @@ -100,7 +100,7 @@ impl DataType { match self { DataType::Int8 => { let i = i8::from_ne_bytes(bytes.try_into().unwrap()); - strs.push((format!("{:#x}", i), None)); + strs.push((format!("{i:#x}"), None)); if i < 0 { strs.push((format!("{:#x}", ReallySigned(i)), None)); @@ -108,7 +108,7 @@ impl DataType { } DataType::Int16 => { let i = endian.read_i16_bytes(bytes.try_into().unwrap()); - strs.push((format!("{:#x}", i), None)); + strs.push((format!("{i:#x}"), None)); if i < 0 { strs.push((format!("{:#x}", ReallySigned(i)), None)); @@ -116,7 +116,7 @@ impl DataType { } DataType::Int32 => { let i = endian.read_i32_bytes(bytes.try_into().unwrap()); - strs.push((format!("{:#x}", i), None)); + strs.push((format!("{i:#x}"), None)); if i < 0 { strs.push((format!("{:#x}", ReallySigned(i)), None)); @@ -124,7 +124,7 @@ impl DataType { } DataType::Int64 => { let i = endian.read_i64_bytes(bytes.try_into().unwrap()); - strs.push((format!("{:#x}", i), None)); + strs.push((format!("{i:#x}"), None)); if i < 0 { strs.push((format!("{:#x}", ReallySigned(i)), None)); @@ -151,16 +151,16 @@ impl DataType { )); } DataType::Bytes => { - strs.push((format!("{:#?}", bytes), None)); + strs.push((format!("{bytes:#?}"), None)); } DataType::String => { if let Ok(cstr) = CStr::from_bytes_until_nul(bytes) { - strs.push((format!("{:?}", cstr), None)); + strs.push((format!("{cstr:?}"), None)); } if let Some(nul_idx) = bytes.iter().position(|&c| c == b'\0') { let (cow, _, had_errors) = SHIFT_JIS.decode(&bytes[..nul_idx]); if !had_errors { - let str = format!("{:?}", cow); + let str = format!("{cow:?}"); // Only add the Shift JIS string if it's different from the ASCII string. if !strs.iter().any(|x| x.0 == str) { strs.push((str, Some("Shift JIS".into()))); diff --git a/objdiff-core/src/arch/ppc/flow_analysis.rs b/objdiff-core/src/arch/ppc/flow_analysis.rs index 631f6bd..3edd402 100644 --- a/objdiff-core/src/arch/ppc/flow_analysis.rs +++ b/objdiff-core/src/arch/ppc/flow_analysis.rs @@ -92,7 +92,7 @@ impl core::fmt::Display for RegisterContent { // -i is safe because it's at most a 16 bit constant in the i32 { if *i >= 0 { - write!(f, "0x{:x}", i) + write!(f, "0x{i:x}") } else { write!(f, "-0x{:x}", -i) } diff --git a/objdiff-core/src/arch/ppc/mod.rs b/objdiff-core/src/arch/ppc/mod.rs index a968ba4..ec5362a 100644 --- a/objdiff-core/src/arch/ppc/mod.rs +++ b/objdiff-core/src/arch/ppc/mod.rs @@ -461,16 +461,14 @@ fn decode_exception_info( // Decode the extab data let Some(extab_data) = extab_section.data_range(extab_start_addr, extab.size())? else { - log::warn!("Failed to get extab data for function {}", extab_func_name); + log::warn!("Failed to get extab data for function {extab_func_name}"); continue; }; let data = match decode_extab(extab_data) { Ok(decoded_data) => decoded_data, Err(e) => { log::warn!( - "Exception table decoding failed for function {}, reason: {}", - extab_func_name, - e + "Exception table decoding failed for function {extab_func_name}, reason: {e}" ); return Ok(None); } diff --git a/objdiff-core/src/arch/superh/disasm.rs b/objdiff-core/src/arch/superh/disasm.rs index 2b3224c..762ada6 100644 --- a/objdiff-core/src/arch/superh/disasm.rs +++ b/objdiff-core/src/arch/superh/disasm.rs @@ -197,7 +197,7 @@ fn match_ni_f( } _ => { parts.push(InstructionPart::basic(".word 0x")); - parts.push(InstructionPart::basic(format!("{:04X}", op))); + parts.push(InstructionPart::basic(format!("{op:04X}"))); parts.push(InstructionPart::basic(" /* unknown instruction */")); } } diff --git a/objdiff-core/src/arch/superh/mod.rs b/objdiff-core/src/arch/superh/mod.rs index e4cde00..ee8c373 100644 --- a/objdiff-core/src/arch/superh/mod.rs +++ b/objdiff-core/src/arch/superh/mod.rs @@ -109,7 +109,7 @@ impl Arch for ArchSuperH { ); parts.push(InstructionPart::basic(" /* ")); parts.push(InstructionPart::basic("0x")); - parts.push(InstructionPart::basic(format!("{:04X}", data))); + parts.push(InstructionPart::basic(format!("{data:04X}"))); parts.push(InstructionPart::basic(" */")); } else if value.size == 4 && value.address as usize + 3 < symbol_data.len() { let data = u32::from_be_bytes( @@ -119,7 +119,7 @@ impl Arch for ArchSuperH { ); parts.push(InstructionPart::basic(" /* ")); parts.push(InstructionPart::basic("0x")); - parts.push(InstructionPart::basic(format!("{:08X}", data))); + parts.push(InstructionPart::basic(format!("{data:08X}"))); parts.push(InstructionPart::basic(" */")); } } diff --git a/objdiff-core/src/bindings/report.rs b/objdiff-core/src/bindings/report.rs index 923a42a..032252a 100644 --- a/objdiff-core/src/bindings/report.rs +++ b/objdiff-core/src/bindings/report.rs @@ -442,7 +442,7 @@ impl From for ReportItem { #[cfg(feature = "serde")] fn serialize_hex(x: &Option, s: S) -> Result where S: serde::Serializer { - if let Some(x) = x { s.serialize_str(&format!("{:#x}", x)) } else { s.serialize_none() } + if let Some(x) = x { s.serialize_str(&format!("{x:#x}")) } else { s.serialize_none() } } #[cfg(feature = "serde")] diff --git a/objdiff-core/src/diff/display.rs b/objdiff-core/src/diff/display.rs index 439847d..5ae4e78 100644 --- a/objdiff-core/src/diff/display.rs +++ b/objdiff-core/src/diff/display.rs @@ -388,7 +388,7 @@ pub fn symbol_context(obj: &Object, symbol_index: usize) -> Vec { if symbol.section.is_some() { if let Some(address) = symbol.virtual_address { out.push(ContextItem::Copy { - value: format!("{:x}", address), + value: format!("{address:x}"), label: Some("virtual address".to_string()), }); } @@ -405,7 +405,7 @@ pub fn symbol_hover( ) -> Vec { let symbol = &obj.symbols[symbol_index]; let addend_str = match addend.cmp(&0i64) { - Ordering::Greater => format!("+{:x}", addend), + Ordering::Greater => format!("+{addend:x}"), Ordering::Less => format!("-{:x}", -addend), _ => String::new(), }; @@ -456,7 +456,7 @@ pub fn symbol_hover( if let Some(address) = symbol.virtual_address { out.push(HoverItem::Text { label: "Virtual address".into(), - value: format!("{:x}", address), + value: format!("{address:x}"), color: override_color.clone().unwrap_or(HoverItemColor::Special), }); } @@ -526,7 +526,7 @@ pub fn instruction_context( let mut out = Vec::new(); let mut hex_string = String::new(); for byte in resolved.code { - hex_string.push_str(&format!("{:02x}", byte)); + hex_string.push_str(&format!("{byte:02x}")); } out.push(ContextItem::Copy { value: hex_string, label: Some("instruction bytes".to_string()) }); out.append(&mut obj.arch.instruction_context(obj, resolved)); @@ -609,7 +609,7 @@ pub fn instruction_hover( out.push(HoverItem::Separator); for (literal, label_override) in literals { out.push(HoverItem::Text { - label: label_override.unwrap_or_else(|| format!("{}", ty)), + label: label_override.unwrap_or_else(|| format!("{ty}")), value: literal, color: HoverItemColor::Normal, }); diff --git a/objdiff-core/src/diff/mod.rs b/objdiff-core/src/diff/mod.rs index 73e8a94..bb18d12 100644 --- a/objdiff-core/src/diff/mod.rs +++ b/objdiff-core/src/diff/mod.rs @@ -506,11 +506,7 @@ fn apply_symbol_mappings( .map_or(SectionKind::Unknown, |s| s.kind); if left_section_kind != right_section_kind { log::warn!( - "Symbol section kind mismatch: {} ({:?}) vs {} ({:?})", - left_name, - left_section_kind, - right_name, - right_section_kind + "Symbol section kind mismatch: {left_name} ({left_section_kind:?}) vs {right_name} ({right_section_kind:?})" ); continue; } diff --git a/objdiff-core/src/jobs/objdiff.rs b/objdiff-core/src/jobs/objdiff.rs index 072a08a..b91965f 100644 --- a/objdiff-core/src/jobs/objdiff.rs +++ b/objdiff-core/src/jobs/objdiff.rs @@ -79,7 +79,7 @@ fn run_build( Some(target_path_rel) if config.build_target => { update_status( context, - format!("Building target {}", target_path_rel), + format!("Building target {target_path_rel}"), step_idx, total, &cancel, @@ -94,7 +94,7 @@ fn run_build( Some(base_path_rel) if config.build_base => { update_status( context, - format!("Building base {}", base_path_rel), + format!("Building base {base_path_rel}"), step_idx, total, &cancel, @@ -111,7 +111,7 @@ fn run_build( Some(target_path) if first_status.success => { update_status( context, - format!("Loading target {}", target_path), + format!("Loading target {target_path}"), step_idx, total, &cancel, @@ -122,8 +122,8 @@ fn run_build( Err(e) => { first_status = BuildStatus { success: false, - stdout: format!("Loading object '{}'", target_path), - stderr: format!("{:#}", e), + stdout: format!("Loading object '{target_path}'"), + stderr: format!("{e:#}"), ..Default::default() }; None @@ -139,21 +139,15 @@ fn run_build( let second_obj = match &config.base_path { Some(base_path) if second_status.success => { - update_status( - context, - format!("Loading base {}", base_path), - step_idx, - total, - &cancel, - )?; + update_status(context, format!("Loading base {base_path}"), step_idx, total, &cancel)?; step_idx += 1; match read::read(base_path.as_ref(), &config.diff_obj_config) { Ok(obj) => Some(obj), Err(e) => { second_status = BuildStatus { success: false, - stdout: format!("Loading object '{}'", base_path), - stderr: format!("{:#}", e), + stdout: format!("Loading object '{base_path}'"), + stderr: format!("{e:#}"), ..Default::default() }; None diff --git a/objdiff-core/src/obj/mod.rs b/objdiff-core/src/obj/mod.rs index 94f0228..e270171 100644 --- a/objdiff-core/src/obj/mod.rs +++ b/objdiff-core/src/obj/mod.rs @@ -169,8 +169,8 @@ impl fmt::Display for InstructionArgValue<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { InstructionArgValue::Signed(v) => write!(f, "{:#x}", ReallySigned(*v)), - InstructionArgValue::Unsigned(v) => write!(f, "{:#x}", v), - InstructionArgValue::Opaque(v) => write!(f, "{}", v), + InstructionArgValue::Unsigned(v) => write!(f, "{v:#x}"), + InstructionArgValue::Opaque(v) => write!(f, "{v}"), } } } @@ -298,7 +298,7 @@ impl Object { &self, symbol_index: usize, ins_ref: InstructionRef, - ) -> Option { + ) -> Option> { let symbol = self.symbols.get(symbol_index)?; let section_index = symbol.section?; let section = self.sections.get(section_index)?; diff --git a/objdiff-core/src/obj/read.rs b/objdiff-core/src/obj/read.rs index f693487..e194e2f 100644 --- a/objdiff-core/src/obj/read.rs +++ b/objdiff-core/src/obj/read.rs @@ -42,7 +42,7 @@ fn map_symbol( (symbol.kind(), symbol.section_index().and_then(|i| file.section_by_index(i).ok())) { let section_name = section.name().context("Failed to process section name")?; - name = format!("[{}]", section_name); + name = format!("[{section_name}]"); // For section symbols, set the size to zero. If the size is non-zero, it will be included // in the diff. Most of the time, this is duplicative, given that we'll have function or // object symbols that cover the same range. In the case of an empty section, the size @@ -252,7 +252,7 @@ fn map_sections( }); let unique_id = section_names.entry(name.to_string()).or_insert(0); - let id = format!("{}-{}", name, unique_id); + let id = format!("{name}-{unique_id}"); *unique_id += 1; if section_indices.len() <= section.index().0 { @@ -378,7 +378,7 @@ fn map_section_relocations( } object::RelocationTarget::Absolute => { let section_name = obj_section.name()?; - log::warn!("Ignoring absolute relocation @ {}:{:#x}", section_name, address); + log::warn!("Ignoring absolute relocation @ {section_name}:{address:#x}"); continue; } _ => bail!("Unhandled relocation target: {:?}", reloc.target()), @@ -516,7 +516,7 @@ fn parse_line_info( let line_number = read_u32(obj_file, &mut section_data)?; let statement_pos = read_u16(obj_file, &mut section_data)?; if statement_pos != 0xFFFF { - log::warn!("Unhandled statement pos {}", statement_pos); + log::warn!("Unhandled statement pos {statement_pos}"); } let address_delta = read_u32(obj_file, &mut section_data)? as u64; out_section.line_info.insert(base_address + address_delta, line_number); diff --git a/objdiff-gui/src/fonts/mod.rs b/objdiff-gui/src/fonts/mod.rs index a7683b0..db4fb8e 100644 --- a/objdiff-gui/src/fonts/mod.rs +++ b/objdiff-gui/src/fonts/mod.rs @@ -25,7 +25,7 @@ pub fn load_font_family( ) -> Option { let family_handle = source.select_family_by_name(name).ok()?; if family_handle.fonts().is_empty() { - log::warn!("No fonts found for family '{}'", name); + log::warn!("No fonts found for family '{name}'"); return None; } let handles = family_handle.fonts().to_vec(); @@ -34,7 +34,7 @@ pub fn load_font_family( match font_kit::loaders::default::Font::from_handle(handle) { Ok(font) => loaded.push(font), Err(err) => { - log::warn!("Failed to load font '{}': {}", name, err); + log::warn!("Failed to load font '{name}': {err}"); return None; } } @@ -89,7 +89,7 @@ pub fn load_font_if_needed( egui::FontFamily::Name(v) => v, }; let family = load_font_family(source, family_name) - .with_context(|| format!("Failed to load font family '{}'", family_name))?; + .with_context(|| format!("Failed to load font family '{family_name}'"))?; let default_fonts = fonts.families.get(&base_family).cloned().unwrap_or_default(); // FIXME clean up let default_font_ref = family.fonts.get(family.default_index).unwrap(); diff --git a/objdiff-gui/src/views/appearance.rs b/objdiff-gui/src/views/appearance.rs index 6f9acbb..e502a9f 100644 --- a/objdiff-gui/src/views/appearance.rs +++ b/objdiff-gui/src/views/appearance.rs @@ -141,7 +141,7 @@ impl Appearance { ) { Ok(()) => self.ui_font = next_ui_font, Err(e) => { - log::error!("Failed to load font: {}", e) + log::error!("Failed to load font: {e}") } } } @@ -155,7 +155,7 @@ impl Appearance { ) { Ok(()) => self.code_font = next_code_font, Err(e) => { - log::error!("Failed to load font: {}", e) + log::error!("Failed to load font: {e}") } } } @@ -172,7 +172,7 @@ impl Appearance { ) { Ok(_) => {} Err(e) => { - log::error!("Failed to load font: {}", e); + log::error!("Failed to load font: {e}"); // Revert to default self.ui_font = DEFAULT_UI_FONT; } @@ -186,7 +186,7 @@ impl Appearance { ) { Ok(_) => {} Err(e) => { - log::error!("Failed to load font: {}", e); + log::error!("Failed to load font: {e}"); // Revert to default self.code_font = DEFAULT_CODE_FONT; } diff --git a/objdiff-gui/src/views/config.rs b/objdiff-gui/src/views/config.rs index ceeee58..22803e2 100644 --- a/objdiff-gui/src/views/config.rs +++ b/objdiff-gui/src/views/config.rs @@ -380,7 +380,7 @@ fn object_context_ui(ui: &mut egui::Ui, object: &ObjectConfig) { .on_hover_text("Open the source file in the default editor") .clicked() { - log::info!("Opening file {}", source_path); + log::info!("Opening file {source_path}"); if let Err(e) = open::that_detached(source_path.as_str()) { log::error!("Failed to open source file: {e}"); } @@ -509,7 +509,7 @@ fn format_path(path: &Option, appearance: &Appearance) -> R .and_then(|home| check_path_buf(home).ok()) .and_then(|home| dir.strip_prefix(&home).ok()) { - format!("~{}{}", MAIN_SEPARATOR, rel) + format!("~{MAIN_SEPARATOR}{rel}") } else { dir.to_string() } @@ -808,7 +808,7 @@ fn split_obj_config_ui( for (idx, glob) in state.config.watch_patterns.iter().enumerate() { ui.horizontal(|ui| { ui.label( - RichText::new(format!("{}", glob)) + RichText::new(format!("{glob}")) .color(appearance.text_color) .family(FontFamily::Monospace), ); diff --git a/objdiff-gui/src/views/diff.rs b/objdiff-gui/src/views/diff.rs index ba8c5c4..92fbcb7 100644 --- a/objdiff-gui/src/views/diff.rs +++ b/objdiff-gui/src/views/diff.rs @@ -390,14 +390,14 @@ pub fn diff_view_ui( let mut needs_separator = false; if let Some(match_percent) = symbol_diff.match_percent { let response = ui.label( - RichText::new(format!("{:.2}%", match_percent)) + RichText::new(format!("{match_percent:.2}%")) .font(appearance.code_font.clone()) .color(match_color_for_symbol(match_percent, appearance)), ); if let Some((diff_score, max_score)) = symbol_diff.diff_score { response.on_hover_ui_at_pointer(|ui| { ui.label( - RichText::new(format!("Score: {}/{}", diff_score, max_score)) + RichText::new(format!("Score: {diff_score}/{max_score}")) .font(appearance.code_font.clone()) .color(appearance.text_color), ); diff --git a/objdiff-gui/src/views/function_diff.rs b/objdiff-gui/src/views/function_diff.rs index 34e0817..1fce2d6 100644 --- a/objdiff-gui/src/views/function_diff.rs +++ b/objdiff-gui/src/views/function_diff.rs @@ -146,17 +146,17 @@ fn diff_text_ui( let label_text = match segment.text { DiffText::Basic(text) => text.to_string(), DiffText::Line(num) => format!("{num} "), - DiffText::Address(addr) => format!("{:x}:", addr), + DiffText::Address(addr) => format!("{addr:x}:"), DiffText::Opcode(mnemonic, _op) => format!("{mnemonic} "), DiffText::Argument(arg) => match arg { InstructionArgValue::Signed(v) => format!("{:#x}", ReallySigned(v)), - InstructionArgValue::Unsigned(v) => format!("{:#x}", v), + InstructionArgValue::Unsigned(v) => format!("{v:#x}"), InstructionArgValue::Opaque(v) => v.into_owned(), }, DiffText::BranchDest(addr) => format!("{addr:x}"), DiffText::Symbol(sym) => sym.demangled_name.as_ref().unwrap_or(&sym.name).clone(), DiffText::Addend(addend) => match addend.cmp(&0i64) { - Ordering::Greater => format!("+{:#x}", addend), + Ordering::Greater => format!("+{addend:#x}"), Ordering::Less => format!("-{:#x}", -addend), _ => String::new(), }, diff --git a/objdiff-gui/src/views/graphics.rs b/objdiff-gui/src/views/graphics.rs index fcfa114..60eeaf4 100644 --- a/objdiff-gui/src/views/graphics.rs +++ b/objdiff-gui/src/views/graphics.rs @@ -157,7 +157,7 @@ pub fn graphics_window( state.should_relaunch = true; } Err(e) => { - log::error!("Failed to save graphics config: {:?}", e); + log::error!("Failed to save graphics config: {e:?}"); state.graphics_config.desired_backend = prev_backend; } } diff --git a/objdiff-gui/src/views/jobs.rs b/objdiff-gui/src/views/jobs.rs index a9f5272..b829c20 100644 --- a/objdiff-gui/src/views/jobs.rs +++ b/objdiff-gui/src/views/jobs.rs @@ -37,7 +37,7 @@ pub fn jobs_ui(ui: &mut egui::Ui, jobs: &mut JobQueue, appearance: &Appearance) bar.ui(ui); const STATUS_LENGTH: usize = 80; if let Some(err) = &status.error { - let err_string = format!("{:#}", err); + let err_string = format!("{err:#}"); ui.colored_label( appearance.delete_color, if err_string.len() > STATUS_LENGTH - 10 { @@ -119,7 +119,7 @@ pub fn jobs_menu_ui(ui: &mut egui::Ui, jobs: &mut JobQueue, appearance: &Appeara } Ordering::Greater => { spinner.ui(ui); - clicked |= ui.link(format!("{} running", running_jobs)).clicked(); + clicked |= ui.link(format!("{running_jobs} running")).clicked(); } _ => (), } @@ -135,9 +135,7 @@ pub fn jobs_menu_ui(ui: &mut egui::Ui, jobs: &mut JobQueue, appearance: &Appeara } Ordering::Greater => { clicked |= ui - .link( - RichText::new(format!("{} errors", error_jobs)).color(appearance.delete_color), - ) + .link(RichText::new(format!("{error_jobs} errors")).color(appearance.delete_color)) .clicked(); } _ => (), diff --git a/objdiff-gui/src/views/symbol_diff.rs b/objdiff-gui/src/views/symbol_diff.rs index 51df0b8..9063be8 100644 --- a/objdiff-gui/src/views/symbol_diff.rs +++ b/objdiff-gui/src/views/symbol_diff.rs @@ -281,7 +281,7 @@ impl DiffViewState { if let Some(source_path) = state.config.selected_obj.as_ref().and_then(|obj| obj.source_path.as_ref()) { - log::info!("Opening file {}", source_path); + log::info!("Opening file {source_path}"); open::that_detached(source_path.as_str()).unwrap_or_else(|err| { log::error!("Failed to open source file: {err}"); }); @@ -361,7 +361,11 @@ impl DiffViewState { } } - fn resolve_symbol(&self, symbol_idx: Option, column: usize) -> Option { + fn resolve_symbol( + &self, + symbol_idx: Option, + column: usize, + ) -> Option> { let symbol_idx = symbol_idx?; let result = self.build.as_deref()?; let (obj, diff) = match column { diff --git a/objdiff-wasm/package-lock.json b/objdiff-wasm/package-lock.json index 838d521..9c8ed5b 100644 --- a/objdiff-wasm/package-lock.json +++ b/objdiff-wasm/package-lock.json @@ -1,12 +1,12 @@ { "name": "objdiff-wasm", - "version": "3.0.0-beta.10", + "version": "3.0.0-beta.11", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "objdiff-wasm", - "version": "3.0.0-beta.10", + "version": "3.0.0-beta.11", "license": "MIT OR Apache-2.0", "devDependencies": { "@biomejs/biome": "^1.9.3", diff --git a/objdiff-wasm/package.json b/objdiff-wasm/package.json index 44bc52d..ac3c1d2 100644 --- a/objdiff-wasm/package.json +++ b/objdiff-wasm/package.json @@ -1,6 +1,6 @@ { "name": "objdiff-wasm", - "version": "3.0.0-beta.10", + "version": "3.0.0-beta.11", "description": "A local diffing tool for decompilation projects.", "author": { "name": "Luke Street",