Skip to content

Commit 88d0e6b

Browse files
committed
cargo clippy --fix
1 parent f212b35 commit 88d0e6b

36 files changed

+181
-187
lines changed

src/analysis/cfa.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl AnalyzerState {
191191
};
192192
obj.add_symbol(
193193
ObjSymbol {
194-
name: format!("jumptable_{}", address_str),
194+
name: format!("jumptable_{address_str}"),
195195
address: addr.address as u64,
196196
section: Some(addr.section),
197197
size: size as u64,
@@ -275,7 +275,7 @@ impl AnalyzerState {
275275
let (section_index, _) = obj
276276
.sections
277277
.at_address(entry)
278-
.context(format!("Entry point {:#010X} outside of any section", entry))?;
278+
.context(format!("Entry point {entry:#010X} outside of any section"))?;
279279
self.process_function_at(obj, SectionAddress::new(section_index, entry))?;
280280
}
281281
// Locate bounds for referenced functions until none are left
@@ -530,7 +530,7 @@ pub fn locate_sda_bases(obj: &mut ObjInfo) -> Result<bool> {
530530
let (section_index, _) = obj
531531
.sections
532532
.at_address(entry as u32)
533-
.context(format!("Entry point {:#010X} outside of any section", entry))?;
533+
.context(format!("Entry point {entry:#010X} outside of any section"))?;
534534
let entry_addr = SectionAddress::new(section_index, entry as u32);
535535

536536
let mut executor = Executor::new(obj);
@@ -589,7 +589,7 @@ pub fn locate_bss_memsets(obj: &mut ObjInfo) -> Result<Vec<(u32, u32)>> {
589589
let (section_index, _) = obj
590590
.sections
591591
.at_address(entry as u32)
592-
.context(format!("Entry point {:#010X} outside of any section", entry))?;
592+
.context(format!("Entry point {entry:#010X} outside of any section"))?;
593593
let entry_addr = SectionAddress::new(section_index, entry as u32);
594594

595595
let mut executor = Executor::new(obj);

src/analysis/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ fn get_jump_table_entries(
183183
let (section_index, _) =
184184
obj.sections.at_address(entry_addr).with_context(|| {
185185
format!(
186-
"Invalid jump table entry {:#010X} at {:#010X}",
187-
entry_addr, cur_addr
186+
"Invalid jump table entry {entry_addr:#010X} at {cur_addr:#010X}"
188187
)
189188
})?;
190189
entries.push(SectionAddress::new(section_index, entry_addr));

src/analysis/pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl AnalysisPass for FindSaveRestSleds {
101101
for i in reg_start..reg_end {
102102
let addr = start + (i - reg_start) * step_size;
103103
state.known_symbols.entry(addr).or_default().push(ObjSymbol {
104-
name: format!("{}{}", label, i),
104+
name: format!("{label}{i}"),
105105
address: addr.address as u64,
106106
section: Some(start.section),
107107
size_known: true,

src/analysis/slices.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ impl FunctionSlices {
227227
})?;
228228
}
229229
self.check_epilogue(section, ins_addr, ins)
230-
.with_context(|| format!("While processing {:#010X}: {:#?}", function_start, self))?;
230+
.with_context(|| format!("While processing {function_start:#010X}: {self:#?}"))?;
231231
if !self.has_conditional_blr && is_conditional_blr(ins) {
232232
self.has_conditional_blr = true;
233233
}

src/analysis/tracker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ impl Tracker {
576576
let relocation_target = relocation_target_for(obj, from, None).ok().flatten();
577577
if !matches!(relocation_target, None | Some(RelocationTarget::External)) {
578578
// VM should have already handled this
579-
panic!("Relocation already exists for {:#010X} (from {:#010X})", addr, from);
579+
panic!("Relocation already exists for {addr:#010X} (from {from:#010X})");
580580
}
581581
}
582582
// Remainder of this function is for executable objects only
@@ -668,7 +668,7 @@ impl Tracker {
668668
0
669669
};
670670
let new_name =
671-
if module_id == 0 { name.to_string() } else { format!("{}:{}", name, module_id) };
671+
if module_id == 0 { name.to_string() } else { format!("{name}:{module_id}") };
672672
log::debug!("Renaming {} to {}", section.name, new_name);
673673
section.name = new_name;
674674
}

src/cmd/ar.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,16 @@ fn extract(args: ExtractArgs) -> Result<()> {
127127
}
128128
std::fs::create_dir_all(&out_dir)?;
129129
if !args.quiet {
130-
println!("Extracting {} to {}", path, out_dir);
130+
println!("Extracting {path} to {out_dir}");
131131
}
132132

133133
let mut file = open_file(path, false)?;
134134
let mut archive = ar::Archive::new(file.map()?);
135135
while let Some(entry) = archive.next_entry() {
136-
let mut entry = entry.with_context(|| format!("Processing entry in {}", path))?;
136+
let mut entry = entry.with_context(|| format!("Processing entry in {path}"))?;
137137
let file_name = std::str::from_utf8(entry.header().identifier())?;
138138
if !args.quiet && args.verbose {
139-
println!("\t{}", file_name);
139+
println!("\t{file_name}");
140140
}
141141
let mut file_path = out_dir.clone();
142142
for segment in file_name.split(&['/', '\\']) {
@@ -146,15 +146,15 @@ fn extract(args: ExtractArgs) -> Result<()> {
146146
std::fs::create_dir_all(parent)?;
147147
}
148148
let mut file = File::create(&file_path)
149-
.with_context(|| format!("Failed to create file {}", file_path))?;
149+
.with_context(|| format!("Failed to create file {file_path}"))?;
150150
std::io::copy(&mut entry, &mut file)?;
151151
file.flush()?;
152152

153153
num_files += 1;
154154
}
155155
}
156156
if !args.quiet {
157-
println!("Extracted {} files", num_files);
157+
println!("Extracted {num_files} files");
158158
}
159159
Ok(())
160160
}

src/cmd/dol.rs

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ pub fn info(args: InfoArgs) -> Result<()> {
536536

537537
println!("{}:", obj.name);
538538
if let Some(entry) = obj.entry {
539-
println!("Entry point: {:#010X}", entry);
539+
println!("Entry point: {entry:#010X}");
540540
}
541541
println!("\nSections:");
542542
println!("\t{: >10} | {: <10} | {: <10} | {: <10}", "Name", "Address", "Size", "File Off");
@@ -955,7 +955,7 @@ fn split_write_obj(
955955
DirBuilder::new()
956956
.recursive(true)
957957
.create(out_dir)
958-
.with_context(|| format!("Failed to create out dir '{}'", out_dir))?;
958+
.with_context(|| format!("Failed to create out dir '{out_dir}'"))?;
959959
let obj_dir = out_dir.join("obj");
960960
let entry = if module.obj.kind == ObjKind::Executable {
961961
module.obj.entry.and_then(|e| {
@@ -1056,9 +1056,8 @@ fn split_write_obj(
10561056
// Generate ldscript.lcf
10571057
let ldscript_template = if let Some(template_path) = &module.config.ldscript_template {
10581058
let template_path = template_path.with_encoding();
1059-
let template = fs::read_to_string(&template_path).with_context(|| {
1060-
format!("Failed to read linker script template '{}'", template_path)
1061-
})?;
1059+
let template = fs::read_to_string(&template_path)
1060+
.with_context(|| format!("Failed to read linker script template '{template_path}'"))?;
10621061
module.dep.push(template_path);
10631062
Some(template)
10641063
} else {
@@ -1076,8 +1075,7 @@ fn split_write_obj(
10761075
let out_path = asm_dir.join(asm_path_for_unit(&unit.name));
10771076

10781077
let mut w = buf_writer(&out_path)?;
1079-
write_asm(&mut w, split_obj)
1080-
.with_context(|| format!("Failed to write {}", out_path))?;
1078+
write_asm(&mut w, split_obj).with_context(|| format!("Failed to write {out_path}"))?;
10811079
w.flush()?;
10821080
}
10831081
}
@@ -1094,7 +1092,7 @@ fn write_if_changed(path: &Utf8NativePath, contents: &[u8]) -> Result<()> {
10941092
return Ok(());
10951093
}
10961094
}
1097-
fs::write(path, contents).with_context(|| format!("Failed to write file '{}'", path))?;
1095+
fs::write(path, contents).with_context(|| format!("Failed to write file '{path}'"))?;
10981096
Ok(())
10991097
}
11001098

@@ -2166,7 +2164,7 @@ impl ObjectBase {
21662164
}
21672165
base.join(path.with_encoding())
21682166
}
2169-
ObjectBase::Vfs(base, _) => Utf8NativePathBuf::from(format!("{}:{}", base, path)),
2167+
ObjectBase::Vfs(base, _) => Utf8NativePathBuf::from(format!("{base}:{path}")),
21702168
}
21712169
}
21722170

@@ -2183,7 +2181,7 @@ impl ObjectBase {
21832181
}
21842182
ObjectBase::Vfs(vfs_path, vfs) => {
21852183
open_file_with_fs(vfs.clone(), &path.with_encoding(), true)
2186-
.with_context(|| format!("Using disc image {}", vfs_path))
2184+
.with_context(|| format!("Using disc image {vfs_path}"))
21872185
}
21882186
}
21892187
}
@@ -2201,26 +2199,26 @@ pub fn find_object_base(config: &ProjectConfig) -> Result<ObjectBase> {
22012199
if let Some(base) = &config.object_base {
22022200
let base = base.with_encoding();
22032201
// Search for disc images in the object base directory
2204-
for result in fs::read_dir(&base).with_context(|| format!("Reading directory {}", base))? {
2205-
let entry = result.with_context(|| format!("Reading entry in directory {}", base))?;
2202+
for result in fs::read_dir(&base).with_context(|| format!("Reading directory {base}"))? {
2203+
let entry = result.with_context(|| format!("Reading entry in directory {base}"))?;
22062204
let Ok(path) = check_path_buf(entry.path()) else {
22072205
log::warn!("Path is not valid UTF-8: {:?}", entry.path());
22082206
continue;
22092207
};
22102208
let file_type =
2211-
entry.file_type().with_context(|| format!("Getting file type for {}", path))?;
2209+
entry.file_type().with_context(|| format!("Getting file type for {path}"))?;
22122210
let is_file = if file_type.is_symlink() {
22132211
// Also traverse symlinks to files
22142212
fs::metadata(&path)
2215-
.with_context(|| format!("Getting metadata for {}", path))?
2213+
.with_context(|| format!("Getting metadata for {path}"))?
22162214
.is_file()
22172215
} else {
22182216
file_type.is_file()
22192217
};
22202218
if is_file {
22212219
let mut file = open_file(&path, false)?;
22222220
let format = detect(file.as_mut())
2223-
.with_context(|| format!("Detecting file type for {}", path))?;
2221+
.with_context(|| format!("Detecting file type for {path}"))?;
22242222
match format {
22252223
FileFormat::Archive(ArchiveKind::Disc(format)) => {
22262224
let fs = open_fs(file, ArchiveKind::Disc(format))?;
@@ -2249,23 +2247,23 @@ fn extract_objects(config: &ProjectConfig, object_base: &ObjectBase) -> Result<U
22492247
{
22502248
let target_path = extracted_path(&target_dir, &config.base.object);
22512249
if !fs::exists(&target_path)
2252-
.with_context(|| format!("Failed to check path '{}'", target_path))?
2250+
.with_context(|| format!("Failed to check path '{target_path}'"))?
22532251
{
22542252
object_paths.push((&config.base.object, config.base.hash.as_deref(), target_path));
22552253
}
22562254
}
22572255
if let Some(selfile) = &config.selfile {
22582256
let target_path = extracted_path(&target_dir, selfile);
22592257
if !fs::exists(&target_path)
2260-
.with_context(|| format!("Failed to check path '{}'", target_path))?
2258+
.with_context(|| format!("Failed to check path '{target_path}'"))?
22612259
{
22622260
object_paths.push((selfile, config.selfile_hash.as_deref(), target_path));
22632261
}
22642262
}
22652263
for module_config in &config.modules {
22662264
let target_path = extracted_path(&target_dir, &module_config.object);
22672265
if !fs::exists(&target_path)
2268-
.with_context(|| format!("Failed to check path '{}'", target_path))?
2266+
.with_context(|| format!("Failed to check path '{target_path}'"))?
22692267
{
22702268
object_paths.push((&module_config.object, module_config.hash.as_deref(), target_path));
22712269
}
@@ -2284,12 +2282,12 @@ fn extract_objects(config: &ProjectConfig, object_base: &ObjectBase) -> Result<U
22842282
let mut file = object_base.open(source_path)?;
22852283
if let Some(parent) = target_path.parent() {
22862284
fs::create_dir_all(parent)
2287-
.with_context(|| format!("Failed to create directory '{}'", parent))?;
2285+
.with_context(|| format!("Failed to create directory '{parent}'"))?;
22882286
}
22892287
let mut out = fs::File::create(&target_path)
2290-
.with_context(|| format!("Failed to create file '{}'", target_path))?;
2288+
.with_context(|| format!("Failed to create file '{target_path}'"))?;
22912289
let hash_bytes = buf_copy_with_hash(&mut file, &mut out)
2292-
.with_context(|| format!("Failed to extract file '{}'", target_path))?;
2290+
.with_context(|| format!("Failed to extract file '{target_path}'"))?;
22932291
if let Some(hash) = hash {
22942292
check_hash_str(hash_bytes, hash).with_context(|| {
22952293
format!("Source file failed verification: '{}'", object_base.join(source_path))

src/cmd/dwarf.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,16 @@ fn dump(args: DumpArgs) -> Result<()> {
104104
// TODO make a basename method
105105
let name = name.trim_start_matches("D:").replace('\\', "/");
106106
let name = name.rsplit_once('/').map(|(_, b)| b).unwrap_or(&name);
107-
let file_path = out_path.join(format!("{}.txt", name));
107+
let file_path = out_path.join(format!("{name}.txt"));
108108
let mut file = buf_writer(&file_path)?;
109109
dump_debug_section(&args, &mut file, &obj_file, debug_section)?;
110110
file.flush()?;
111111
} else if args.no_color {
112-
println!("\n// File {}:", name);
112+
println!("\n// File {name}:");
113113
dump_debug_section(&args, &mut stdout(), &obj_file, debug_section)?;
114114
} else {
115115
let mut writer = HighlightWriter::new(syntax_set.clone(), syntax.clone(), theme);
116-
writeln!(writer, "\n// File {}:", name)?;
116+
writeln!(writer, "\n// File {name}:")?;
117117
dump_debug_section(&args, &mut writer, &obj_file, debug_section)?;
118118
}
119119
}
@@ -209,26 +209,25 @@ where
209209
}
210210
writeln!(w, "\n/*\n Compile unit: {}", unit.name)?;
211211
if let Some(producer) = unit.producer {
212-
writeln!(w, " Producer: {}", producer)?;
212+
writeln!(w, " Producer: {producer}")?;
213213
}
214214
if let Some(comp_dir) = unit.comp_dir {
215-
writeln!(w, " Compile directory: {}", comp_dir)?;
215+
writeln!(w, " Compile directory: {comp_dir}")?;
216216
}
217217
if let Some(language) = unit.language {
218-
writeln!(w, " Language: {}", language)?;
218+
writeln!(w, " Language: {language}")?;
219219
}
220220
if let (Some(start), Some(end)) = (unit.start_address, unit.end_address) {
221-
writeln!(w, " Code range: {:#010X} -> {:#010X}", start, end)?;
221+
writeln!(w, " Code range: {start:#010X} -> {end:#010X}")?;
222222
}
223223
if let Some(gcc_srcfile_name_offset) = unit.gcc_srcfile_name_offset {
224224
writeln!(
225225
w,
226-
" GCC Source File Name Offset: {:#010X}",
227-
gcc_srcfile_name_offset
226+
" GCC Source File Name Offset: {gcc_srcfile_name_offset:#010X}"
228227
)?;
229228
}
230229
if let Some(gcc_srcinfo_offset) = unit.gcc_srcinfo_offset {
231-
writeln!(w, " GCC Source Info Offset: {:#010X}", gcc_srcinfo_offset)?;
230+
writeln!(w, " GCC Source Info Offset: {gcc_srcinfo_offset:#010X}")?;
232231
}
233232
writeln!(w, "*/")?;
234233

@@ -269,7 +268,7 @@ where
269268
continue;
270269
}
271270
match tag_type_string(&info, &typedefs, &tag_type, child.is_erased) {
272-
Ok(s) => writeln!(w, "{}", s)?,
271+
Ok(s) => writeln!(w, "{s}")?,
273272
Err(e) => {
274273
log::error!(
275274
"Failed to emit tag {:X} (unit {}): {}",

src/cmd/elf.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,14 @@ fn disasm(args: DisasmArgs) -> Result<()> {
146146
let mut files_out = buf_writer(&args.out.join("link_order.txt"))?;
147147
for (unit, split_obj) in obj.link_order.iter().zip(&split_objs) {
148148
let out_name = file_stem_from_unit(&unit.name);
149-
let out_path = asm_dir.join(format!("{}.s", out_name));
149+
let out_path = asm_dir.join(format!("{out_name}.s"));
150150
log::info!("Writing {}", out_path);
151151

152152
let mut w = buf_writer(&out_path)?;
153153
write_asm(&mut w, split_obj)?;
154154
w.flush()?;
155155

156-
writeln!(files_out, "{}.o", out_name)?;
156+
writeln!(files_out, "{out_name}.o")?;
157157
}
158158
files_out.flush()?;
159159
}
@@ -402,7 +402,7 @@ fn signatures(args: SignaturesArgs) -> Result<()> {
402402
Ok(Some(signature)) => signature,
403403
Ok(None) => continue,
404404
Err(e) => {
405-
eprintln!("Failed: {:?}", e);
405+
eprintln!("Failed: {e:?}");
406406
continue;
407407
}
408408
};
@@ -545,13 +545,13 @@ fn info(args: InfoArgs) -> Result<()> {
545545
.context("While reading .note.split section")?;
546546
println!("\nSplit metadata (.note.split):");
547547
if let Some(generator) = &meta.generator {
548-
println!("\tGenerator: {}", generator);
548+
println!("\tGenerator: {generator}");
549549
}
550550
if let Some(module_name) = &meta.module_name {
551-
println!("\tModule name: {}", module_name);
551+
println!("\tModule name: {module_name}");
552552
}
553553
if let Some(module_id) = meta.module_id {
554-
println!("\tModule ID: {}", module_id);
554+
println!("\tModule ID: {module_id}");
555555
}
556556
if let Some(virtual_addresses) = &meta.virtual_addresses {
557557
println!("\tVirtual addresses:");

src/cmd/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ fn symbol(args: SymbolArgs) -> Result<()> {
175175
if let Some(vec) = entries.unit_references.get_vec(&symbol_ref) {
176176
println!("\nGenerated in TUs:");
177177
for x in vec {
178-
println!(">>> {}", x);
178+
println!(">>> {x}");
179179
}
180180
}
181181
println!("\n");

0 commit comments

Comments
 (0)