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
}

tests/accuracy/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ fn verify(filelines: &[Pos]) {
9696
println!("-----------------------------------");
9797
println!("looking for:");
9898
for (file, line) in filelines.iter().rev() {
99-
println!("\t{}:{}", file, line);
99+
println!("\t{file}:{line}");
100100
}
101-
println!("found:\n{:?}", trace);
101+
println!("found:\n{trace:?}");
102102
let mut symbols = trace.frames().iter().flat_map(|frame| frame.symbols());
103103
let mut iter = filelines.iter().rev();
104104
while let Some((file, line)) = iter.next() {

tests/current-exe-mismatch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn main() {
2020
println!("test result: ignored");
2121
}
2222
Err(EarlyExit::IoError(e)) => {
23-
println!("{} parent encoutered IoError: {:?}", file!(), e);
23+
println!("{} parent encountered IoError: {:?}", file!(), e);
2424
panic!();
2525
}
2626
}
@@ -74,7 +74,7 @@ fn parent() -> Result<(), EarlyExit> {
7474

7575
fn child() -> Result<(), EarlyExit> {
7676
let bt = backtrace::Backtrace::new();
77-
println!("{:?}", bt);
77+
println!("{bt:?}");
7878

7979
let mut found_my_name = false;
8080

tests/long_fn_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn test_long_fn_name() {
2525
// It's actually longer since it also includes `::`, `<>` and the
2626
// name of the current module
2727
let bt = S::<S<S<S<S<S<S<S<S<S<i32>>>>>>>>>>::new();
28-
println!("{:?}", bt);
28+
println!("{bt:?}");
2929

3030
let mut found_long_name_frame = false;
3131

tests/skip_inner_frames.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn backtrace_new_unresolved_should_start_with_call_site_trace() {
1818
}
1919
let mut b = Backtrace::new_unresolved();
2020
b.resolve();
21-
println!("{:?}", b);
21+
println!("{b:?}");
2222

2323
assert!(!b.frames().is_empty());
2424

@@ -34,7 +34,7 @@ fn backtrace_new_should_start_with_call_site_trace() {
3434
return;
3535
}
3636
let b = Backtrace::new();
37-
println!("{:?}", b);
37+
println!("{b:?}");
3838

3939
assert!(!b.frames().is_empty());
4040

tests/smoke.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,16 @@ fn smoke_test_frames() {
112112
backtrace::resolve_frame(frame, |sym| {
113113
print!("symbol ip:{:?} address:{:?} ", frame.ip(), frame.symbol_address());
114114
if let Some(name) = sym.name() {
115-
print!("name:{} ", name);
115+
print!("name:{name} ");
116116
}
117117
if let Some(file) = sym.filename() {
118118
print!("file:{} ", file.display());
119119
}
120120
if let Some(lineno) = sym.lineno() {
121-
print!("lineno:{} ", lineno);
121+
print!("lineno:{lineno} ");
122122
}
123123
if let Some(colno) = sym.colno() {
124-
print!("colno:{} ", colno);
124+
print!("colno:{colno} ");
125125
}
126126
println!();
127127
});
@@ -269,12 +269,12 @@ fn sp_smoke_test() {
269269

270270
if refs.len() < 5 {
271271
recursive_stack_references(refs);
272-
eprintln!("exiting: {}", x);
272+
eprintln!("exiting: {x}");
273273
return;
274274
}
275275

276276
backtrace::trace(make_trace_closure(refs));
277-
eprintln!("exiting: {}", x);
277+
eprintln!("exiting: {x}");
278278
}
279279

280280
// NB: the following `make_*` functions are pulled out of line, rather than
@@ -296,7 +296,7 @@ fn sp_smoke_test() {
296296
sym.name()
297297
.and_then(|name| name.as_str())
298298
.map_or(false, |name| {
299-
eprintln!("name = {}", name);
299+
eprintln!("name = {name}");
300300
name.contains("recursive_stack_references")
301301
})
302302
});

0 commit comments

Comments
 (0)