Skip to content

Commit a0371dd

Browse files
committed
Cargo clippy & cargo deny fixes
1 parent 771a141 commit a0371dd

File tree

12 files changed

+56
-62
lines changed

12 files changed

+56
-62
lines changed

deny.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ allow = [
8080
"MPL-2.0",
8181
"Unicode-DFS-2016",
8282
"Zlib",
83+
"0BSD",
8384
]
8485
# List of explictly disallowed licenses
8586
# See https://spdx.org/licenses/ for list of possible licenses
@@ -203,7 +204,7 @@ allow-git = []
203204

204205
[sources.allow-org]
205206
# 1 or more github.com organizations to allow git sources for
206-
github = ["encounter", "terorie"]
207+
github = ["encounter"]
207208
# 1 or more gitlab.com organizations to allow git sources for
208209
#gitlab = [""]
209210
# 1 or more bitbucket.org organizations to allow git sources for

src/app.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,8 @@ impl eframe::App for App {
333333
for (idx, color) in view_state.view_config.diff_colors.iter_mut().enumerate() {
334334
ui.horizontal(|ui| {
335335
ui.color_edit_button_srgba(color);
336-
if num_colors > 1 {
337-
if ui.small_button("-").clicked() {
338-
remove_at = Some(idx);
339-
}
336+
if num_colors > 1 && ui.small_button("-").clicked() {
337+
remove_at = Some(idx);
340338
}
341339
});
342340
}
@@ -483,7 +481,7 @@ impl eframe::App for App {
483481
if let Some(project_dir) = &config.project_dir {
484482
match create_watcher(self.modified.clone(), project_dir) {
485483
Ok(watcher) => self.watcher = Some(watcher),
486-
Err(e) => eprintln!("Failed to create watcher: {}", e),
484+
Err(e) => eprintln!("Failed to create watcher: {e}"),
487485
}
488486
config.project_dir_change = false;
489487
self.modified.store(true, Ordering::Relaxed);
@@ -534,7 +532,7 @@ fn create_watcher(
534532
}
535533
}
536534
}
537-
Err(e) => println!("watch error: {:?}", e),
535+
Err(e) => println!("watch error: {e:?}"),
538536
})?;
539537
watcher.watch(project_dir, RecursiveMode::Recursive)?;
540538
Ok(watcher)

src/diff.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ use crate::{
1414

1515
fn no_diff_code(
1616
arch: ObjArchitecture,
17-
data: &Vec<u8>,
17+
data: &[u8],
1818
symbol: &mut ObjSymbol,
19-
relocs: &Vec<ObjReloc>,
19+
relocs: &[ObjReloc],
2020
) -> Result<()> {
2121
let code =
2222
&data[symbol.section_address as usize..(symbol.section_address + symbol.size) as usize];
@@ -241,7 +241,7 @@ fn arg_eq(
241241
) -> bool {
242242
return match left {
243243
ObjInsArg::PpcArg(l) => match right {
244-
ObjInsArg::PpcArg(r) => format!("{}", l) == format!("{}", r),
244+
ObjInsArg::PpcArg(r) => format!("{l}") == format!("{r}"),
245245
_ => false,
246246
},
247247
ObjInsArg::Reloc => {
@@ -312,10 +312,10 @@ fn compare_ins(
312312
state.diff_count += 1;
313313
}
314314
let a_str = match a {
315-
ObjInsArg::PpcArg(arg) => format!("{}", arg),
315+
ObjInsArg::PpcArg(arg) => format!("{arg}"),
316316
ObjInsArg::Reloc | ObjInsArg::RelocWithBase => String::new(),
317317
ObjInsArg::MipsArg(str) => str.clone(),
318-
ObjInsArg::BranchOffset(arg) => format!("{}", arg),
318+
ObjInsArg::BranchOffset(arg) => format!("{arg}"),
319319
};
320320
let a_diff = if let Some(idx) = state.left_args_idx.get(&a_str) {
321321
ObjInsArgDiff { idx: *idx }
@@ -326,10 +326,10 @@ fn compare_ins(
326326
ObjInsArgDiff { idx }
327327
};
328328
let b_str = match b {
329-
ObjInsArg::PpcArg(arg) => format!("{}", arg),
329+
ObjInsArg::PpcArg(arg) => format!("{arg}"),
330330
ObjInsArg::Reloc | ObjInsArg::RelocWithBase => String::new(),
331331
ObjInsArg::MipsArg(str) => str.clone(),
332-
ObjInsArg::BranchOffset(arg) => format!("{}", arg),
332+
ObjInsArg::BranchOffset(arg) => format!("{arg}"),
333333
};
334334
let b_diff = if let Some(idx) = state.right_args_idx.get(&b_str) {
335335
ObjInsArgDiff { idx: *idx }

src/jobs/objdiff.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn run_make(cwd: &Path, arg: &Path, config: &AppConfig) -> BuildStatus {
6767
let stderr = from_utf8(&output.stderr).context("Failed to process stderr")?;
6868
Ok(BuildStatus {
6969
success: output.status.code().unwrap_or(-1) == 0,
70-
log: format!("{}\n{}", stdout, stderr),
70+
log: format!("{stdout}\n{stderr}"),
7171
})
7272
})() {
7373
Ok(status) => status,
@@ -102,26 +102,26 @@ fn run_build(
102102

103103
let total = if config.build_target { 5 } else { 4 };
104104
let first_status = if config.build_target {
105-
update_status(status, format!("Building target {}", obj_path), 0, total, &cancel)?;
105+
update_status(status, format!("Building target {obj_path}"), 0, total, &cancel)?;
106106
run_make(project_dir, target_path_rel, &config)
107107
} else {
108108
BuildStatus { success: true, log: String::new() }
109109
};
110110

111-
update_status(status, format!("Building base {}", obj_path), 1, total, &cancel)?;
111+
update_status(status, format!("Building base {obj_path}"), 1, total, &cancel)?;
112112
let second_status = run_make(project_dir, base_path_rel, &config);
113113

114114
let time = OffsetDateTime::now_utc();
115115

116116
let mut first_obj = if first_status.success {
117-
update_status(status, format!("Loading target {}", obj_path), 2, total, &cancel)?;
117+
update_status(status, format!("Loading target {obj_path}"), 2, total, &cancel)?;
118118
Some(elf::read(&target_path)?)
119119
} else {
120120
None
121121
};
122122

123123
let mut second_obj = if second_status.success {
124-
update_status(status, format!("Loading base {}", obj_path), 3, total, &cancel)?;
124+
update_status(status, format!("Loading base {obj_path}"), 3, total, &cancel)?;
125125
Some(elf::read(&base_path)?)
126126
} else {
127127
None

src/jobs/update.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn run_update(status: &Status, cancel: Receiver<()>) -> Result<Box<UpdateResult>
2626
.assets
2727
.iter()
2828
.find(|a| a.name == BIN_NAME)
29-
.ok_or(anyhow::Error::msg(formatcp!("No release asset for {}", BIN_NAME)))?;
29+
.ok_or_else(|| anyhow::Error::msg(formatcp!("No release asset for {}", BIN_NAME)))?;
3030

3131
update_status(status, "Downloading release".to_string(), 1, 3, &cancel)?;
3232
let tmp_dir = tempfile::Builder::new().prefix("update").tempdir_in(current_dir()?)?;
@@ -46,7 +46,7 @@ fn run_update(status: &Status, cancel: Receiver<()>) -> Result<Box<UpdateResult>
4646
{
4747
use std::os::unix::fs::PermissionsExt;
4848
let mut perms = fs::metadata(&target_file)?.permissions();
49-
perms.set_mode(0755);
49+
perms.set_mode(0o755);
5050
fs::set_permissions(&target_file, perms)?;
5151
}
5252

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn main() {
3535
let result = exec::Command::new(path)
3636
.args(&std::env::args().collect::<Vec<String>>())
3737
.exec();
38-
eprintln!("Failed to relaunch: {:?}", result);
38+
eprintln!("Failed to relaunch: {result:?}");
3939
} else {
4040
let result = std::process::Command::new(path)
4141
.args(std::env::args())

src/obj/elf.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ fn to_obj_section_kind(kind: SectionKind) -> ObjSectionKind {
2222
SectionKind::Text => ObjSectionKind::Code,
2323
SectionKind::Data | SectionKind::ReadOnlyData => ObjSectionKind::Data,
2424
SectionKind::UninitializedData => ObjSectionKind::Bss,
25-
_ => panic!("Unhandled section kind {:?}", kind),
25+
_ => panic!("Unhandled section kind {kind:?}"),
2626
}
2727
}
2828

2929
fn to_obj_symbol(obj_file: &File<'_>, symbol: &Symbol<'_, '_>, addend: i64) -> Result<ObjSymbol> {
3030
let mut name = symbol.name().context("Failed to process symbol name")?;
3131
if name.is_empty() {
32-
println!("Found empty sym: {:?}", symbol);
32+
println!("Found empty sym: {symbol:?}");
3333
name = "?";
3434
}
3535
let mut flags = ObjSymbolFlagSet(ObjSymbolFlags::none());
@@ -220,8 +220,7 @@ fn relocations_by_section(
220220
R_PPC_EMB_SDA21 => ObjRelocKind::PpcEmbSda21,
221221
_ => {
222222
return Err(anyhow::Error::msg(format!(
223-
"Unhandled PPC relocation type: {}",
224-
kind
223+
"Unhandled PPC relocation type: {kind}"
225224
)))
226225
}
227226
},
@@ -231,8 +230,7 @@ fn relocations_by_section(
231230
R_MIPS_LO16 => ObjRelocKind::MipsLo16,
232231
_ => {
233232
return Err(anyhow::Error::msg(format!(
234-
"Unhandled MIPS relocation type: {}",
235-
kind
233+
"Unhandled MIPS relocation type: {kind}"
236234
)))
237235
}
238236
},
@@ -271,8 +269,7 @@ fn relocations_by_section(
271269
let addend = reloc.addend();
272270
if addend < 0 {
273271
return Err(anyhow::Error::msg(format!(
274-
"Negative addend in section reloc: {}",
275-
addend
272+
"Negative addend in section reloc: {addend}"
276273
)));
277274
}
278275
addend as u32

src/views/config.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,13 @@ pub fn config_ui(ui: &mut egui::Ui, config: &Arc<RwLock<AppConfig>>, view_state:
8181
if state.update_available {
8282
ui.colored_label(Color32::LIGHT_GREEN, "Update available");
8383
ui.horizontal(|ui| {
84-
if state.found_binary {
85-
if ui
84+
if state.found_binary && ui
8685
.button("Automatic")
8786
.on_hover_text_at_pointer(
8887
"Automatically download and replace the current build",
8988
)
90-
.clicked()
91-
{
92-
view_state.jobs.push(queue_update());
93-
}
89+
.clicked() {
90+
view_state.jobs.push(queue_update());
9491
}
9592
if ui
9693
.button("Manual")

src/views/data_diff.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn data_row_ui(ui: &mut egui::Ui, address: usize, diffs: &[ObjDataDiff], config:
2323
}
2424
let mut job = LayoutJob::default();
2525
write_text(
26-
format!("{:08X}: ", address).as_str(),
26+
format!("{address:08X}: ").as_str(),
2727
Color32::GRAY,
2828
&mut job,
2929
config.code_font.clone(),
@@ -44,7 +44,7 @@ fn data_row_ui(ui: &mut egui::Ui, address: usize, diffs: &[ObjDataDiff], config:
4444
} else {
4545
let mut text = String::new();
4646
for byte in &diff.data {
47-
text.push_str(format!("{:02X} ", byte).as_str());
47+
text.push_str(format!("{byte:02X} ").as_str());
4848
cur_addr += 1;
4949
if cur_addr % 8 == 0 {
5050
text.push(' ');

src/views/function_diff.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,43 +20,43 @@ fn write_reloc_name(reloc: &ObjReloc, color: Color32, job: &mut LayoutJob, font_
2020
let name = reloc.target.demangled_name.as_ref().unwrap_or(&reloc.target.name);
2121
write_text(name, Color32::LIGHT_GRAY, job, font_id.clone());
2222
if reloc.target.addend != 0 {
23-
write_text(&format!("+{:X}", reloc.target.addend), color, job, font_id.clone());
23+
write_text(&format!("+{:X}", reloc.target.addend), color, job, font_id);
2424
}
2525
}
2626

2727
fn write_reloc(reloc: &ObjReloc, color: Color32, job: &mut LayoutJob, font_id: FontId) {
2828
match reloc.kind {
2929
ObjRelocKind::PpcAddr16Lo => {
3030
write_reloc_name(reloc, color, job, font_id.clone());
31-
write_text("@l", color, job, font_id.clone());
31+
write_text("@l", color, job, font_id);
3232
}
3333
ObjRelocKind::PpcAddr16Hi => {
3434
write_reloc_name(reloc, color, job, font_id.clone());
35-
write_text("@h", color, job, font_id.clone());
35+
write_text("@h", color, job, font_id);
3636
}
3737
ObjRelocKind::PpcAddr16Ha => {
3838
write_reloc_name(reloc, color, job, font_id.clone());
39-
write_text("@ha", color, job, font_id.clone());
39+
write_text("@ha", color, job, font_id);
4040
}
4141
ObjRelocKind::PpcEmbSda21 => {
4242
write_reloc_name(reloc, color, job, font_id.clone());
43-
write_text("@sda21", color, job, font_id.clone());
43+
write_text("@sda21", color, job, font_id);
4444
}
4545
ObjRelocKind::MipsHi16 => {
4646
write_text("%hi(", color, job, font_id.clone());
4747
write_reloc_name(reloc, color, job, font_id.clone());
48-
write_text(")", color, job, font_id.clone());
48+
write_text(")", color, job, font_id);
4949
}
5050
ObjRelocKind::MipsLo16 => {
5151
write_text("%lo(", color, job, font_id.clone());
5252
write_reloc_name(reloc, color, job, font_id.clone());
53-
write_text(")", color, job, font_id.clone());
53+
write_text(")", color, job, font_id);
5454
}
5555
ObjRelocKind::Absolute
5656
| ObjRelocKind::PpcRel24
5757
| ObjRelocKind::PpcRel14
5858
| ObjRelocKind::Mips26 => {
59-
write_reloc_name(reloc, color, job, font_id.clone());
59+
write_reloc_name(reloc, color, job, font_id);
6060
}
6161
};
6262
}
@@ -102,16 +102,16 @@ fn write_ins(
102102
match arg {
103103
ObjInsArg::PpcArg(arg) => match arg {
104104
Argument::Offset(val) => {
105-
write_text(&format!("{}", val), color, job, config.code_font.clone());
105+
write_text(&format!("{val}"), color, job, config.code_font.clone());
106106
write_text("(", base_color, job, config.code_font.clone());
107107
writing_offset = true;
108108
continue;
109109
}
110110
Argument::Uimm(_) | Argument::Simm(_) => {
111-
write_text(&format!("{}", arg), color, job, config.code_font.clone());
111+
write_text(&format!("{arg}"), color, job, config.code_font.clone());
112112
}
113113
_ => {
114-
write_text(&format!("{}", arg), color, job, config.code_font.clone());
114+
write_text(&format!("{arg}"), color, job, config.code_font.clone());
115115
}
116116
},
117117
ObjInsArg::Reloc => {
@@ -133,7 +133,7 @@ fn write_ins(
133133
}
134134
ObjInsArg::BranchOffset(offset) => {
135135
let addr = offset + ins.address as i32 - base_addr as i32;
136-
write_text(&format!("{:x}", addr), color, job, config.code_font.clone());
136+
write_text(&format!("{addr:x}"), color, job, config.code_font.clone());
137137
}
138138
}
139139
if writing_offset {
@@ -171,7 +171,7 @@ fn ins_hover_ui(ui: &mut egui::Ui, ins: &ObjIns) {
171171
ui.label(format!("Relocation type: {:?}", reloc.kind));
172172
ui.colored_label(Color32::WHITE, format!("Name: {}", reloc.target.name));
173173
if let Some(section) = &reloc.target_section {
174-
ui.colored_label(Color32::WHITE, format!("Section: {}", section));
174+
ui.colored_label(Color32::WHITE, format!("Section: {section}"));
175175
ui.colored_label(Color32::WHITE, format!("Address: {:x}", reloc.target.address));
176176
ui.colored_label(Color32::WHITE, format!("Size: {:x}", reloc.target.size));
177177
} else {
@@ -192,8 +192,8 @@ fn ins_context_menu(ui: &mut egui::Ui, ins: &ObjIns) {
192192
if let ObjInsArg::PpcArg(arg) = arg {
193193
match arg {
194194
Argument::Uimm(v) => {
195-
if ui.button(format!("Copy \"{}\"", v)).clicked() {
196-
ui.output().copied_text = format!("{}", v);
195+
if ui.button(format!("Copy \"{v}\"")).clicked() {
196+
ui.output().copied_text = format!("{v}");
197197
ui.close_menu();
198198
}
199199
if ui.button(format!("Copy \"{}\"", v.0)).clicked() {
@@ -202,8 +202,8 @@ fn ins_context_menu(ui: &mut egui::Ui, ins: &ObjIns) {
202202
}
203203
}
204204
Argument::Simm(v) => {
205-
if ui.button(format!("Copy \"{}\"", v)).clicked() {
206-
ui.output().copied_text = format!("{}", v);
205+
if ui.button(format!("Copy \"{v}\"")).clicked() {
206+
ui.output().copied_text = format!("{v}");
207207
ui.close_menu();
208208
}
209209
if ui.button(format!("Copy \"{}\"", v.0)).clicked() {
@@ -212,8 +212,8 @@ fn ins_context_menu(ui: &mut egui::Ui, ins: &ObjIns) {
212212
}
213213
}
214214
Argument::Offset(v) => {
215-
if ui.button(format!("Copy \"{}\"", v)).clicked() {
216-
ui.output().copied_text = format!("{}", v);
215+
if ui.button(format!("Copy \"{v}\"")).clicked() {
216+
ui.output().copied_text = format!("{v}");
217217
ui.close_menu();
218218
}
219219
if ui.button(format!("Copy \"{}\"", v.0)).clicked() {
@@ -227,7 +227,7 @@ fn ins_context_menu(ui: &mut egui::Ui, ins: &ObjIns) {
227227
}
228228
if let Some(reloc) = &ins.reloc {
229229
if let Some(name) = &reloc.target.demangled_name {
230-
if ui.button(format!("Copy \"{}\"", name)).clicked() {
230+
if ui.button(format!("Copy \"{name}\"")).clicked() {
231231
ui.output().copied_text = name.clone();
232232
ui.close_menu();
233233
}
@@ -399,7 +399,7 @@ pub fn function_diff_ui(ui: &mut egui::Ui, view_state: &mut ViewState) -> bool {
399399
{
400400
ui.colored_label(
401401
match_color_for_symbol(match_percent),
402-
&format!("{:.0}%", match_percent),
402+
&format!("{match_percent:.0}%"),
403403
);
404404
}
405405
ui.label("Diff base:");

src/views/jobs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn jobs_ui(ui: &mut egui::Ui, view_state: &mut ViewState) {
1515
if job.handle.is_some() {
1616
job.should_remove = true;
1717
if let Err(e) = job.cancel.send(()) {
18-
eprintln!("Failed to cancel job: {:?}", e);
18+
eprintln!("Failed to cancel job: {e:?}");
1919
}
2020
} else {
2121
remove_job = Some(idx);

0 commit comments

Comments
 (0)