clippy fixes & version bump

This commit is contained in:
Luke Street 2025-07-07 14:56:41 -06:00
parent bd3ed0d5ad
commit 8756eee07b
29 changed files with 89 additions and 105 deletions

8
Cargo.lock generated
View File

@ -3373,7 +3373,7 @@ dependencies = [
[[package]] [[package]]
name = "objdiff-cli" name = "objdiff-cli"
version = "3.0.0-beta.10" version = "3.0.0-beta.11"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"argp", "argp",
@ -3396,7 +3396,7 @@ dependencies = [
[[package]] [[package]]
name = "objdiff-core" name = "objdiff-core"
version = "3.0.0-beta.10" version = "3.0.0-beta.11"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arm-attr", "arm-attr",
@ -3450,7 +3450,7 @@ dependencies = [
[[package]] [[package]]
name = "objdiff-gui" name = "objdiff-gui"
version = "3.0.0-beta.10" version = "3.0.0-beta.11"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cfg-if", "cfg-if",
@ -3486,7 +3486,7 @@ dependencies = [
[[package]] [[package]]
name = "objdiff-wasm" name = "objdiff-wasm"
version = "3.0.0-beta.10" version = "3.0.0-beta.11"
dependencies = [ dependencies = [
"log", "log",
"objdiff-core", "objdiff-core",

View File

@ -14,7 +14,7 @@ strip = "debuginfo"
codegen-units = 1 codegen-units = 1
[workspace.package] [workspace.package]
version = "3.0.0-beta.10" version = "3.0.0-beta.11"
authors = ["Luke Street <luke@street.dev>"] authors = ["Luke Street <luke@street.dev>"]
edition = "2024" edition = "2024"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"

View File

@ -203,14 +203,10 @@ fn run_oneshot(
let output_format = OutputFormat::from_option(args.format.as_deref())?; let output_format = OutputFormat::from_option(args.format.as_deref())?;
let (diff_config, mapping_config) = build_config_from_args(args)?; let (diff_config, mapping_config) = build_config_from_args(args)?;
let target = target_path let target = target_path
.map(|p| { .map(|p| obj::read::read(p.as_ref(), &diff_config).with_context(|| format!("Loading {p}")))
obj::read::read(p.as_ref(), &diff_config).with_context(|| format!("Loading {}", p))
})
.transpose()?; .transpose()?;
let base = base_path let base = base_path
.map(|p| { .map(|p| obj::read::read(p.as_ref(), &diff_config).with_context(|| format!("Loading {p}")))
obj::read::read(p.as_ref(), &diff_config).with_context(|| format!("Loading {}", p))
})
.transpose()?; .transpose()?;
let result = let result =
diff::diff_objs(target.as_ref(), base.as_ref(), None, &diff_config, &mapping_config)?; diff::diff_objs(target.as_ref(), base.as_ref(), None, &diff_config, &mapping_config)?;
@ -399,7 +395,7 @@ fn run_interactive(
stdout(), stdout(),
EnterAlternateScreen, EnterAlternateScreen,
EnableMouseCapture, EnableMouseCapture,
SetTitle(format!("{} - objdiff", symbol_name)), SetTitle(format!("{symbol_name} - objdiff")),
)?; )?;
let backend = CrosstermBackend::new(stdout()); let backend = CrosstermBackend::new(stdout());
let mut terminal = Terminal::new(backend)?; let mut terminal = Terminal::new(backend)?;

View File

@ -177,16 +177,14 @@ fn report_object(
.target_path .target_path
.as_ref() .as_ref()
.map(|p| { .map(|p| {
obj::read::read(p.as_ref(), diff_config) obj::read::read(p.as_ref(), diff_config).with_context(|| format!("Failed to open {p}"))
.with_context(|| format!("Failed to open {}", p))
}) })
.transpose()?; .transpose()?;
let base = object let base = object
.base_path .base_path
.as_ref() .as_ref()
.map(|p| { .map(|p| {
obj::read::read(p.as_ref(), diff_config) obj::read::read(p.as_ref(), diff_config).with_context(|| format!("Failed to open {p}"))
.with_context(|| format!("Failed to open {}", p))
}) })
.transpose()?; .transpose()?;
let result = let result =
@ -433,8 +431,8 @@ fn read_report(path: &Utf8PlatformPath) -> Result<Report> {
std::io::stdin().read_to_end(&mut data)?; std::io::stdin().read_to_end(&mut data)?;
return Report::parse(&data).with_context(|| "Failed to load report from stdin"); 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 = let mmap =
unsafe { memmap2::Mmap::map(&file) }.with_context(|| format!("Failed to map {}", 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)) Report::parse(mmap.as_ref()).with_context(|| format!("Failed to load report {path}"))
} }

View File

@ -87,7 +87,7 @@ impl UiView for FunctionDiffUi {
.and_then(|(_, _, d)| d.match_percent) .and_then(|(_, _, d)| d.match_percent)
{ {
line_r.spans.push(Span::styled( line_r.spans.push(Span::styled(
format!("{:.2}% ", percent), format!("{percent:.2}% "),
Style::new().fg(match_percent_color(percent)), Style::new().fg(match_percent_color(percent)),
)); ));
} }
@ -97,7 +97,7 @@ impl UiView for FunctionDiffUi {
.and_then(|t| t.format(&state.time_format).ok()) .and_then(|t| t.format(&state.time_format).ok())
.unwrap_or_else(|| "N/A".to_string()); .unwrap_or_else(|| "N/A".to_string());
line_r.spans.push(Span::styled( line_r.spans.push(Span::styled(
format!("Last reload: {}", reload_time), format!("Last reload: {reload_time}"),
Style::new().fg(Color::White), Style::new().fg(Color::White),
)); ));
line_r.spans.push(Span::styled( line_r.spans.push(Span::styled(
@ -538,7 +538,7 @@ impl FunctionDiffUi {
let label_text = match segment.text { let label_text = match segment.text {
DiffText::Basic(text) => text.to_string(), DiffText::Basic(text) => text.to_string(),
DiffText::Line(num) => format!("{num} "), DiffText::Line(num) => format!("{num} "),
DiffText::Address(addr) => format!("{:x}:", addr), DiffText::Address(addr) => format!("{addr:x}:"),
DiffText::Opcode(mnemonic, _op) => format!("{mnemonic} "), DiffText::Opcode(mnemonic, _op) => format!("{mnemonic} "),
DiffText::Argument(arg) => arg.to_string(), DiffText::Argument(arg) => arg.to_string(),
DiffText::BranchDest(addr) => format!("{addr:x}"), DiffText::BranchDest(addr) => format!("{addr:x}"),
@ -546,7 +546,7 @@ impl FunctionDiffUi {
sym.demangled_name.as_ref().unwrap_or(&sym.name).clone() sym.demangled_name.as_ref().unwrap_or(&sym.name).clone()
} }
DiffText::Addend(addend) => match addend.cmp(&0i64) { DiffText::Addend(addend) => match addend.cmp(&0i64) {
Ordering::Greater => format!("+{:#x}", addend), Ordering::Greater => format!("+{addend:#x}"),
Ordering::Less => format!("-{:#x}", -addend), Ordering::Less => format!("-{:#x}", -addend),
_ => String::new(), _ => String::new(),
}, },

View File

@ -60,10 +60,10 @@ pub struct ConfigGroup {
} }
fn build_doc(name: &str, description: Option<&str>) -> TokenStream { 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] }; let mut out = quote! { #[doc = #doc] };
if let Some(description) = description { if let Some(description) = description {
doc = format!(" {}", description); doc = format!(" {description}");
out.extend(quote! { #[doc = ""] }); out.extend(quote! { #[doc = ""] });
out.extend(quote! { #[doc = #doc] }); out.extend(quote! { #[doc = #doc] });
} }
@ -443,9 +443,9 @@ pub fn generate_diff_config() {
} }
impl core::fmt::Display for ConfigPropertyValue { impl core::fmt::Display for ConfigPropertyValue {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self { match *self {
ConfigPropertyValue::Boolean(value) => write!(f, "{}", value), ConfigPropertyValue::Boolean(value) => write!(f, "{value}"),
ConfigPropertyValue::Choice(value) => write!(f, "{}", value), ConfigPropertyValue::Choice(value) => f.write_str(value),
} }
} }
} }

View File

@ -575,7 +575,7 @@ fn push_args(
arg_cb(InstructionPart::basic("}"))?; arg_cb(InstructionPart::basic("}"))?;
} }
args::Argument::CoprocNum(value) => { args::Argument::CoprocNum(value) => {
arg_cb(InstructionPart::opaque(format!("p{}", value)))?; arg_cb(InstructionPart::opaque(format!("p{value}")))?;
} }
args::Argument::ShiftImm(shift) => { args::Argument::ShiftImm(shift) => {
arg_cb(InstructionPart::opaque(shift.op.to_string()))?; arg_cb(InstructionPart::opaque(shift.op.to_string()))?;

View File

@ -2268,7 +2268,7 @@ where Cb: FnMut(InstructionPart<'static>) {
push_plain(args, "]"); push_plain(args, "]");
push_separator(args); push_separator(args);
// TODO does 31 have to be handled separate? // 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 // Fall back to original logic
Operand::SIMDRegister(_, _) Operand::SIMDRegister(_, _)

View File

@ -66,8 +66,8 @@ impl DataType {
pub fn display_labels(&self, endian: object::Endianness, bytes: &[u8]) -> Vec<String> { pub fn display_labels(&self, endian: object::Endianness, bytes: &[u8]) -> Vec<String> {
let mut strs = Vec::new(); let mut strs = Vec::new();
for (literal, label_override) in self.display_literals(endian, bytes) { for (literal, label_override) in self.display_literals(endian, bytes) {
let label = label_override.unwrap_or_else(|| format!("{}", self)); let label = label_override.unwrap_or_else(|| format!("{self}"));
strs.push(format!("{}: {}", label, literal)) strs.push(format!("{label}: {literal}"))
} }
strs strs
} }
@ -100,7 +100,7 @@ impl DataType {
match self { match self {
DataType::Int8 => { DataType::Int8 => {
let i = i8::from_ne_bytes(bytes.try_into().unwrap()); 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 { if i < 0 {
strs.push((format!("{:#x}", ReallySigned(i)), None)); strs.push((format!("{:#x}", ReallySigned(i)), None));
@ -108,7 +108,7 @@ impl DataType {
} }
DataType::Int16 => { DataType::Int16 => {
let i = endian.read_i16_bytes(bytes.try_into().unwrap()); 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 { if i < 0 {
strs.push((format!("{:#x}", ReallySigned(i)), None)); strs.push((format!("{:#x}", ReallySigned(i)), None));
@ -116,7 +116,7 @@ impl DataType {
} }
DataType::Int32 => { DataType::Int32 => {
let i = endian.read_i32_bytes(bytes.try_into().unwrap()); 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 { if i < 0 {
strs.push((format!("{:#x}", ReallySigned(i)), None)); strs.push((format!("{:#x}", ReallySigned(i)), None));
@ -124,7 +124,7 @@ impl DataType {
} }
DataType::Int64 => { DataType::Int64 => {
let i = endian.read_i64_bytes(bytes.try_into().unwrap()); 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 { if i < 0 {
strs.push((format!("{:#x}", ReallySigned(i)), None)); strs.push((format!("{:#x}", ReallySigned(i)), None));
@ -151,16 +151,16 @@ impl DataType {
)); ));
} }
DataType::Bytes => { DataType::Bytes => {
strs.push((format!("{:#?}", bytes), None)); strs.push((format!("{bytes:#?}"), None));
} }
DataType::String => { DataType::String => {
if let Ok(cstr) = CStr::from_bytes_until_nul(bytes) { 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') { if let Some(nul_idx) = bytes.iter().position(|&c| c == b'\0') {
let (cow, _, had_errors) = SHIFT_JIS.decode(&bytes[..nul_idx]); let (cow, _, had_errors) = SHIFT_JIS.decode(&bytes[..nul_idx]);
if !had_errors { 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. // Only add the Shift JIS string if it's different from the ASCII string.
if !strs.iter().any(|x| x.0 == str) { if !strs.iter().any(|x| x.0 == str) {
strs.push((str, Some("Shift JIS".into()))); strs.push((str, Some("Shift JIS".into())));

View File

@ -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 // -i is safe because it's at most a 16 bit constant in the i32
{ {
if *i >= 0 { if *i >= 0 {
write!(f, "0x{:x}", i) write!(f, "0x{i:x}")
} else { } else {
write!(f, "-0x{:x}", -i) write!(f, "-0x{:x}", -i)
} }

View File

@ -461,16 +461,14 @@ fn decode_exception_info(
// Decode the extab data // Decode the extab data
let Some(extab_data) = extab_section.data_range(extab_start_addr, extab.size())? else { 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; continue;
}; };
let data = match decode_extab(extab_data) { let data = match decode_extab(extab_data) {
Ok(decoded_data) => decoded_data, Ok(decoded_data) => decoded_data,
Err(e) => { Err(e) => {
log::warn!( log::warn!(
"Exception table decoding failed for function {}, reason: {}", "Exception table decoding failed for function {extab_func_name}, reason: {e}"
extab_func_name,
e
); );
return Ok(None); return Ok(None);
} }

View File

@ -197,7 +197,7 @@ fn match_ni_f(
} }
_ => { _ => {
parts.push(InstructionPart::basic(".word 0x")); 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 */")); parts.push(InstructionPart::basic(" /* unknown instruction */"));
} }
} }

View File

@ -109,7 +109,7 @@ impl Arch for ArchSuperH {
); );
parts.push(InstructionPart::basic(" /* ")); parts.push(InstructionPart::basic(" /* "));
parts.push(InstructionPart::basic("0x")); parts.push(InstructionPart::basic("0x"));
parts.push(InstructionPart::basic(format!("{:04X}", data))); parts.push(InstructionPart::basic(format!("{data:04X}")));
parts.push(InstructionPart::basic(" */")); parts.push(InstructionPart::basic(" */"));
} else if value.size == 4 && value.address as usize + 3 < symbol_data.len() { } else if value.size == 4 && value.address as usize + 3 < symbol_data.len() {
let data = u32::from_be_bytes( let data = u32::from_be_bytes(
@ -119,7 +119,7 @@ impl Arch for ArchSuperH {
); );
parts.push(InstructionPart::basic(" /* ")); parts.push(InstructionPart::basic(" /* "));
parts.push(InstructionPart::basic("0x")); parts.push(InstructionPart::basic("0x"));
parts.push(InstructionPart::basic(format!("{:08X}", data))); parts.push(InstructionPart::basic(format!("{data:08X}")));
parts.push(InstructionPart::basic(" */")); parts.push(InstructionPart::basic(" */"));
} }
} }

View File

@ -442,7 +442,7 @@ impl From<LegacyReportItem> for ReportItem {
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
fn serialize_hex<S>(x: &Option<u64>, s: S) -> Result<S::Ok, S::Error> fn serialize_hex<S>(x: &Option<u64>, s: S) -> Result<S::Ok, S::Error>
where S: serde::Serializer { 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")] #[cfg(feature = "serde")]

View File

@ -388,7 +388,7 @@ pub fn symbol_context(obj: &Object, symbol_index: usize) -> Vec<ContextItem> {
if symbol.section.is_some() { if symbol.section.is_some() {
if let Some(address) = symbol.virtual_address { if let Some(address) = symbol.virtual_address {
out.push(ContextItem::Copy { out.push(ContextItem::Copy {
value: format!("{:x}", address), value: format!("{address:x}"),
label: Some("virtual address".to_string()), label: Some("virtual address".to_string()),
}); });
} }
@ -405,7 +405,7 @@ pub fn symbol_hover(
) -> Vec<HoverItem> { ) -> Vec<HoverItem> {
let symbol = &obj.symbols[symbol_index]; let symbol = &obj.symbols[symbol_index];
let addend_str = match addend.cmp(&0i64) { let addend_str = match addend.cmp(&0i64) {
Ordering::Greater => format!("+{:x}", addend), Ordering::Greater => format!("+{addend:x}"),
Ordering::Less => format!("-{:x}", -addend), Ordering::Less => format!("-{:x}", -addend),
_ => String::new(), _ => String::new(),
}; };
@ -456,7 +456,7 @@ pub fn symbol_hover(
if let Some(address) = symbol.virtual_address { if let Some(address) = symbol.virtual_address {
out.push(HoverItem::Text { out.push(HoverItem::Text {
label: "Virtual address".into(), label: "Virtual address".into(),
value: format!("{:x}", address), value: format!("{address:x}"),
color: override_color.clone().unwrap_or(HoverItemColor::Special), color: override_color.clone().unwrap_or(HoverItemColor::Special),
}); });
} }
@ -526,7 +526,7 @@ pub fn instruction_context(
let mut out = Vec::new(); let mut out = Vec::new();
let mut hex_string = String::new(); let mut hex_string = String::new();
for byte in resolved.code { 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.push(ContextItem::Copy { value: hex_string, label: Some("instruction bytes".to_string()) });
out.append(&mut obj.arch.instruction_context(obj, resolved)); out.append(&mut obj.arch.instruction_context(obj, resolved));
@ -609,7 +609,7 @@ pub fn instruction_hover(
out.push(HoverItem::Separator); out.push(HoverItem::Separator);
for (literal, label_override) in literals { for (literal, label_override) in literals {
out.push(HoverItem::Text { out.push(HoverItem::Text {
label: label_override.unwrap_or_else(|| format!("{}", ty)), label: label_override.unwrap_or_else(|| format!("{ty}")),
value: literal, value: literal,
color: HoverItemColor::Normal, color: HoverItemColor::Normal,
}); });

View File

@ -506,11 +506,7 @@ fn apply_symbol_mappings(
.map_or(SectionKind::Unknown, |s| s.kind); .map_or(SectionKind::Unknown, |s| s.kind);
if left_section_kind != right_section_kind { if left_section_kind != right_section_kind {
log::warn!( log::warn!(
"Symbol section kind mismatch: {} ({:?}) vs {} ({:?})", "Symbol section kind mismatch: {left_name} ({left_section_kind:?}) vs {right_name} ({right_section_kind:?})"
left_name,
left_section_kind,
right_name,
right_section_kind
); );
continue; continue;
} }

View File

@ -79,7 +79,7 @@ fn run_build(
Some(target_path_rel) if config.build_target => { Some(target_path_rel) if config.build_target => {
update_status( update_status(
context, context,
format!("Building target {}", target_path_rel), format!("Building target {target_path_rel}"),
step_idx, step_idx,
total, total,
&cancel, &cancel,
@ -94,7 +94,7 @@ fn run_build(
Some(base_path_rel) if config.build_base => { Some(base_path_rel) if config.build_base => {
update_status( update_status(
context, context,
format!("Building base {}", base_path_rel), format!("Building base {base_path_rel}"),
step_idx, step_idx,
total, total,
&cancel, &cancel,
@ -111,7 +111,7 @@ fn run_build(
Some(target_path) if first_status.success => { Some(target_path) if first_status.success => {
update_status( update_status(
context, context,
format!("Loading target {}", target_path), format!("Loading target {target_path}"),
step_idx, step_idx,
total, total,
&cancel, &cancel,
@ -122,8 +122,8 @@ fn run_build(
Err(e) => { Err(e) => {
first_status = BuildStatus { first_status = BuildStatus {
success: false, success: false,
stdout: format!("Loading object '{}'", target_path), stdout: format!("Loading object '{target_path}'"),
stderr: format!("{:#}", e), stderr: format!("{e:#}"),
..Default::default() ..Default::default()
}; };
None None
@ -139,21 +139,15 @@ fn run_build(
let second_obj = match &config.base_path { let second_obj = match &config.base_path {
Some(base_path) if second_status.success => { Some(base_path) if second_status.success => {
update_status( update_status(context, format!("Loading base {base_path}"), step_idx, total, &cancel)?;
context,
format!("Loading base {}", base_path),
step_idx,
total,
&cancel,
)?;
step_idx += 1; step_idx += 1;
match read::read(base_path.as_ref(), &config.diff_obj_config) { match read::read(base_path.as_ref(), &config.diff_obj_config) {
Ok(obj) => Some(obj), Ok(obj) => Some(obj),
Err(e) => { Err(e) => {
second_status = BuildStatus { second_status = BuildStatus {
success: false, success: false,
stdout: format!("Loading object '{}'", base_path), stdout: format!("Loading object '{base_path}'"),
stderr: format!("{:#}", e), stderr: format!("{e:#}"),
..Default::default() ..Default::default()
}; };
None None

View File

@ -169,8 +169,8 @@ impl fmt::Display for InstructionArgValue<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
InstructionArgValue::Signed(v) => write!(f, "{:#x}", ReallySigned(*v)), InstructionArgValue::Signed(v) => write!(f, "{:#x}", ReallySigned(*v)),
InstructionArgValue::Unsigned(v) => write!(f, "{:#x}", v), InstructionArgValue::Unsigned(v) => write!(f, "{v:#x}"),
InstructionArgValue::Opaque(v) => write!(f, "{}", v), InstructionArgValue::Opaque(v) => write!(f, "{v}"),
} }
} }
} }
@ -298,7 +298,7 @@ impl Object {
&self, &self,
symbol_index: usize, symbol_index: usize,
ins_ref: InstructionRef, ins_ref: InstructionRef,
) -> Option<ResolvedInstructionRef> { ) -> Option<ResolvedInstructionRef<'_>> {
let symbol = self.symbols.get(symbol_index)?; let symbol = self.symbols.get(symbol_index)?;
let section_index = symbol.section?; let section_index = symbol.section?;
let section = self.sections.get(section_index)?; let section = self.sections.get(section_index)?;

View File

@ -42,7 +42,7 @@ fn map_symbol(
(symbol.kind(), symbol.section_index().and_then(|i| file.section_by_index(i).ok())) (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")?; 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 // 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 // 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 // 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 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; *unique_id += 1;
if section_indices.len() <= section.index().0 { if section_indices.len() <= section.index().0 {
@ -378,7 +378,7 @@ fn map_section_relocations(
} }
object::RelocationTarget::Absolute => { object::RelocationTarget::Absolute => {
let section_name = obj_section.name()?; 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; continue;
} }
_ => bail!("Unhandled relocation target: {:?}", reloc.target()), _ => 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 line_number = read_u32(obj_file, &mut section_data)?;
let statement_pos = read_u16(obj_file, &mut section_data)?; let statement_pos = read_u16(obj_file, &mut section_data)?;
if statement_pos != 0xFFFF { 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; let address_delta = read_u32(obj_file, &mut section_data)? as u64;
out_section.line_info.insert(base_address + address_delta, line_number); out_section.line_info.insert(base_address + address_delta, line_number);

View File

@ -25,7 +25,7 @@ pub fn load_font_family(
) -> Option<LoadedFontFamily> { ) -> Option<LoadedFontFamily> {
let family_handle = source.select_family_by_name(name).ok()?; let family_handle = source.select_family_by_name(name).ok()?;
if family_handle.fonts().is_empty() { if family_handle.fonts().is_empty() {
log::warn!("No fonts found for family '{}'", name); log::warn!("No fonts found for family '{name}'");
return None; return None;
} }
let handles = family_handle.fonts().to_vec(); 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) { match font_kit::loaders::default::Font::from_handle(handle) {
Ok(font) => loaded.push(font), Ok(font) => loaded.push(font),
Err(err) => { Err(err) => {
log::warn!("Failed to load font '{}': {}", name, err); log::warn!("Failed to load font '{name}': {err}");
return None; return None;
} }
} }
@ -89,7 +89,7 @@ pub fn load_font_if_needed(
egui::FontFamily::Name(v) => v, egui::FontFamily::Name(v) => v,
}; };
let family = load_font_family(source, family_name) 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(); let default_fonts = fonts.families.get(&base_family).cloned().unwrap_or_default();
// FIXME clean up // FIXME clean up
let default_font_ref = family.fonts.get(family.default_index).unwrap(); let default_font_ref = family.fonts.get(family.default_index).unwrap();

View File

@ -141,7 +141,7 @@ impl Appearance {
) { ) {
Ok(()) => self.ui_font = next_ui_font, Ok(()) => self.ui_font = next_ui_font,
Err(e) => { 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, Ok(()) => self.code_font = next_code_font,
Err(e) => { Err(e) => {
log::error!("Failed to load font: {}", e) log::error!("Failed to load font: {e}")
} }
} }
} }
@ -172,7 +172,7 @@ impl Appearance {
) { ) {
Ok(_) => {} Ok(_) => {}
Err(e) => { Err(e) => {
log::error!("Failed to load font: {}", e); log::error!("Failed to load font: {e}");
// Revert to default // Revert to default
self.ui_font = DEFAULT_UI_FONT; self.ui_font = DEFAULT_UI_FONT;
} }
@ -186,7 +186,7 @@ impl Appearance {
) { ) {
Ok(_) => {} Ok(_) => {}
Err(e) => { Err(e) => {
log::error!("Failed to load font: {}", e); log::error!("Failed to load font: {e}");
// Revert to default // Revert to default
self.code_font = DEFAULT_CODE_FONT; self.code_font = DEFAULT_CODE_FONT;
} }

View File

@ -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") .on_hover_text("Open the source file in the default editor")
.clicked() .clicked()
{ {
log::info!("Opening file {}", source_path); log::info!("Opening file {source_path}");
if let Err(e) = open::that_detached(source_path.as_str()) { if let Err(e) = open::that_detached(source_path.as_str()) {
log::error!("Failed to open source file: {e}"); log::error!("Failed to open source file: {e}");
} }
@ -509,7 +509,7 @@ fn format_path(path: &Option<Utf8PlatformPathBuf>, appearance: &Appearance) -> R
.and_then(|home| check_path_buf(home).ok()) .and_then(|home| check_path_buf(home).ok())
.and_then(|home| dir.strip_prefix(&home).ok()) .and_then(|home| dir.strip_prefix(&home).ok())
{ {
format!("~{}{}", MAIN_SEPARATOR, rel) format!("~{MAIN_SEPARATOR}{rel}")
} else { } else {
dir.to_string() dir.to_string()
} }
@ -808,7 +808,7 @@ fn split_obj_config_ui(
for (idx, glob) in state.config.watch_patterns.iter().enumerate() { for (idx, glob) in state.config.watch_patterns.iter().enumerate() {
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.label( ui.label(
RichText::new(format!("{}", glob)) RichText::new(format!("{glob}"))
.color(appearance.text_color) .color(appearance.text_color)
.family(FontFamily::Monospace), .family(FontFamily::Monospace),
); );

View File

@ -390,14 +390,14 @@ pub fn diff_view_ui(
let mut needs_separator = false; let mut needs_separator = false;
if let Some(match_percent) = symbol_diff.match_percent { if let Some(match_percent) = symbol_diff.match_percent {
let response = ui.label( let response = ui.label(
RichText::new(format!("{:.2}%", match_percent)) RichText::new(format!("{match_percent:.2}%"))
.font(appearance.code_font.clone()) .font(appearance.code_font.clone())
.color(match_color_for_symbol(match_percent, appearance)), .color(match_color_for_symbol(match_percent, appearance)),
); );
if let Some((diff_score, max_score)) = symbol_diff.diff_score { if let Some((diff_score, max_score)) = symbol_diff.diff_score {
response.on_hover_ui_at_pointer(|ui| { response.on_hover_ui_at_pointer(|ui| {
ui.label( ui.label(
RichText::new(format!("Score: {}/{}", diff_score, max_score)) RichText::new(format!("Score: {diff_score}/{max_score}"))
.font(appearance.code_font.clone()) .font(appearance.code_font.clone())
.color(appearance.text_color), .color(appearance.text_color),
); );

View File

@ -146,17 +146,17 @@ fn diff_text_ui(
let label_text = match segment.text { let label_text = match segment.text {
DiffText::Basic(text) => text.to_string(), DiffText::Basic(text) => text.to_string(),
DiffText::Line(num) => format!("{num} "), DiffText::Line(num) => format!("{num} "),
DiffText::Address(addr) => format!("{:x}:", addr), DiffText::Address(addr) => format!("{addr:x}:"),
DiffText::Opcode(mnemonic, _op) => format!("{mnemonic} "), DiffText::Opcode(mnemonic, _op) => format!("{mnemonic} "),
DiffText::Argument(arg) => match arg { DiffText::Argument(arg) => match arg {
InstructionArgValue::Signed(v) => format!("{:#x}", ReallySigned(v)), 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(), InstructionArgValue::Opaque(v) => v.into_owned(),
}, },
DiffText::BranchDest(addr) => format!("{addr:x}"), DiffText::BranchDest(addr) => format!("{addr:x}"),
DiffText::Symbol(sym) => sym.demangled_name.as_ref().unwrap_or(&sym.name).clone(), DiffText::Symbol(sym) => sym.demangled_name.as_ref().unwrap_or(&sym.name).clone(),
DiffText::Addend(addend) => match addend.cmp(&0i64) { DiffText::Addend(addend) => match addend.cmp(&0i64) {
Ordering::Greater => format!("+{:#x}", addend), Ordering::Greater => format!("+{addend:#x}"),
Ordering::Less => format!("-{:#x}", -addend), Ordering::Less => format!("-{:#x}", -addend),
_ => String::new(), _ => String::new(),
}, },

View File

@ -157,7 +157,7 @@ pub fn graphics_window(
state.should_relaunch = true; state.should_relaunch = true;
} }
Err(e) => { 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; state.graphics_config.desired_backend = prev_backend;
} }
} }

View File

@ -37,7 +37,7 @@ pub fn jobs_ui(ui: &mut egui::Ui, jobs: &mut JobQueue, appearance: &Appearance)
bar.ui(ui); bar.ui(ui);
const STATUS_LENGTH: usize = 80; const STATUS_LENGTH: usize = 80;
if let Some(err) = &status.error { if let Some(err) = &status.error {
let err_string = format!("{:#}", err); let err_string = format!("{err:#}");
ui.colored_label( ui.colored_label(
appearance.delete_color, appearance.delete_color,
if err_string.len() > STATUS_LENGTH - 10 { 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 => { Ordering::Greater => {
spinner.ui(ui); 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 => { Ordering::Greater => {
clicked |= ui clicked |= ui
.link( .link(RichText::new(format!("{error_jobs} errors")).color(appearance.delete_color))
RichText::new(format!("{} errors", error_jobs)).color(appearance.delete_color),
)
.clicked(); .clicked();
} }
_ => (), _ => (),

View File

@ -281,7 +281,7 @@ impl DiffViewState {
if let Some(source_path) = if let Some(source_path) =
state.config.selected_obj.as_ref().and_then(|obj| obj.source_path.as_ref()) 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| { open::that_detached(source_path.as_str()).unwrap_or_else(|err| {
log::error!("Failed to open source file: {err}"); log::error!("Failed to open source file: {err}");
}); });
@ -361,7 +361,11 @@ impl DiffViewState {
} }
} }
fn resolve_symbol(&self, symbol_idx: Option<usize>, column: usize) -> Option<ResolvedSymbol> { fn resolve_symbol(
&self,
symbol_idx: Option<usize>,
column: usize,
) -> Option<ResolvedSymbol<'_>> {
let symbol_idx = symbol_idx?; let symbol_idx = symbol_idx?;
let result = self.build.as_deref()?; let result = self.build.as_deref()?;
let (obj, diff) = match column { let (obj, diff) = match column {

View File

@ -1,12 +1,12 @@
{ {
"name": "objdiff-wasm", "name": "objdiff-wasm",
"version": "3.0.0-beta.10", "version": "3.0.0-beta.11",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "objdiff-wasm", "name": "objdiff-wasm",
"version": "3.0.0-beta.10", "version": "3.0.0-beta.11",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"devDependencies": { "devDependencies": {
"@biomejs/biome": "^1.9.3", "@biomejs/biome": "^1.9.3",

View File

@ -1,6 +1,6 @@
{ {
"name": "objdiff-wasm", "name": "objdiff-wasm",
"version": "3.0.0-beta.10", "version": "3.0.0-beta.11",
"description": "A local diffing tool for decompilation projects.", "description": "A local diffing tool for decompilation projects.",
"author": { "author": {
"name": "Luke Street", "name": "Luke Street",