Skip to content

Commit 3acbb65

Browse files
authored
Apply clippy::uninlined_format_args fixes (#486)
* Apply clippy::uninlined_format_args fix * Addressed feedback and added a few more * also did one minor spelling change in a print statement in `current-exe-mismatch.rs`
1 parent 4dea00c commit 3acbb65

File tree

15 files changed

+31
-35
lines changed

15 files changed

+31
-35
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn main() {
2727

2828
// do_some_work();
2929

30-
println!("{:?}", bt);
30+
println!("{bt:?}");
3131
}
3232
```
3333

build.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,15 @@ fn build_android() {
2828
let expansion = match cc::Build::new().file(&android_api_c).try_expand() {
2929
Ok(result) => result,
3030
Err(e) => {
31-
eprintln!(
32-
"warning: android version detection failed while running C compiler: {}",
33-
e
34-
);
31+
eprintln!("warning: android version detection failed while running C compiler: {e}");
3532
return;
3633
}
3734
};
3835
let expansion = match std::str::from_utf8(&expansion) {
3936
Ok(s) => s,
4037
Err(_) => return,
4138
};
42-
eprintln!("expanded android version detection:\n{}", expansion);
39+
eprintln!("expanded android version detection:\n{expansion}");
4340
let i = match expansion.find(MARKER) {
4441
Some(i) => i,
4542
None => return,

crates/cpp_smoke_test/tests/smoke.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ fn smoke_test_cpp() {
4949
.take(2)
5050
.collect();
5151

52-
println!("actual names = {:#?}", names);
52+
println!("actual names = {names:#?}");
5353

5454
let expected = [
5555
"void space::templated_trampoline<void (*)()>(void (*)())",
5656
"cpp_trampoline",
5757
];
58-
println!("expected names = {:#?}", expected);
58+
println!("expected names = {expected:#?}");
5959

6060
assert_eq!(names.len(), expected.len());
6161
for (actual, expected) in names.iter().zip(expected.iter()) {

crates/debuglink/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn main() {
99
let expect = std::path::Path::new(&crate_dir).join("src/main.rs");
1010

1111
let bt = backtrace::Backtrace::new();
12-
println!("{:?}", bt);
12+
println!("{bt:?}");
1313

1414
let mut found_main = false;
1515

@@ -20,7 +20,7 @@ fn main() {
2020
}
2121

2222
if let Some(name) = symbols[0].name() {
23-
let name = format!("{:#}", name);
23+
let name = format!("{name:#}");
2424
if name == "debuglink::main" {
2525
found_main = true;
2626
let filename = symbols[0].filename().unwrap();

crates/macos_frames_test/tests/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ fn backtrace_no_dsym() {
1515
let executable_name = dsym_path.file_name().unwrap().to_str().unwrap().to_string();
1616
assert!(dsym_path.pop()); // Pop executable
1717
dsym_path.push(format!(
18-
"{}.dSYM/Contents/Resources/DWARF/{0}",
19-
executable_name
18+
"{executable_name}.dSYM/Contents/Resources/DWARF/{executable_name}"
2019
));
2120
let _ = fs::OpenOptions::new()
2221
.read(false)

examples/raw.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn print() {
3333
}
3434

3535
if let Some(name) = symbol.name() {
36-
print!(" - {}", name);
36+
print!(" - {name}");
3737
} else {
3838
print!(" - <unknown>");
3939
}

src/capture.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ impl Backtrace {
174174
/// use backtrace::Backtrace;
175175
///
176176
/// let mut current_backtrace = Backtrace::new_unresolved();
177-
/// println!("{:?}", current_backtrace); // no symbol names
177+
/// println!("{current_backtrace:?}"); // no symbol names
178178
/// current_backtrace.resolve();
179-
/// println!("{:?}", current_backtrace); // symbol names now present
179+
/// println!("{current_backtrace:?}"); // symbol names now present
180180
/// ```
181181
///
182182
/// # Required features

src/print.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl BacktraceFrameFmt<'_, '_, '_> {
239239
if self.symbol_index == 0 {
240240
write!(self.fmt.fmt, "{:4}: ", self.fmt.frame_index)?;
241241
if let PrintFmt::Full = self.fmt.format {
242-
write!(self.fmt.fmt, "{:1$?} - ", frame_ip, HEX_WIDTH)?;
242+
write!(self.fmt.fmt, "{frame_ip:HEX_WIDTH$?} - ")?;
243243
}
244244
} else {
245245
write!(self.fmt.fmt, " ")?;
@@ -252,8 +252,8 @@ impl BacktraceFrameFmt<'_, '_, '_> {
252252
// more information if we're a full backtrace. Here we also handle
253253
// symbols which don't have a name,
254254
match (symbol_name, &self.fmt.format) {
255-
(Some(name), PrintFmt::Short) => write!(self.fmt.fmt, "{:#}", name)?,
256-
(Some(name), PrintFmt::Full) => write!(self.fmt.fmt, "{}", name)?,
255+
(Some(name), PrintFmt::Short) => write!(self.fmt.fmt, "{name:#}")?,
256+
(Some(name), PrintFmt::Full) => write!(self.fmt.fmt, "{name}")?,
257257
(None, _) | (_, PrintFmt::__Nonexhaustive) => write!(self.fmt.fmt, "<unknown>")?,
258258
}
259259
self.fmt.fmt.write_str("\n")?;
@@ -282,11 +282,11 @@ impl BacktraceFrameFmt<'_, '_, '_> {
282282
// Delegate to our internal callback to print the filename and then
283283
// print out the line number.
284284
(self.fmt.print_path)(self.fmt.fmt, file)?;
285-
write!(self.fmt.fmt, ":{}", line)?;
285+
write!(self.fmt.fmt, ":{line}")?;
286286

287287
// Add column number, if available.
288288
if let Some(colno) = colno {
289-
write!(self.fmt.fmt, ":{}", colno)?;
289+
write!(self.fmt.fmt, ":{colno}")?;
290290
}
291291

292292
write!(self.fmt.fmt, "\n")?;

src/print/fuchsia.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ struct HexSlice<'a> {
312312
impl fmt::Display for HexSlice<'_> {
313313
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
314314
for byte in self.bytes {
315-
write!(f, "{:02x}", byte)?;
315+
write!(f, "{byte:02x}")?;
316316
}
317317
Ok(())
318318
}

src/symbolize/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ cfg_if::cfg_if! {
421421
// it outwards.
422422
if let Some(ref cpp) = self.cpp_demangled.0 {
423423
let mut s = String::new();
424-
if write!(s, "{}", cpp).is_ok() {
424+
if write!(s, "{cpp}").is_ok() {
425425
return s.fmt(f)
426426
}
427427
}

0 commit comments

Comments
 (0)