Skip to content

Commit

Permalink
Apply clippy::uninlined_format_args fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Jul 2, 2023
1 parent e1c49fb commit 9172eb4
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ fn build_android() {
let expansion = match cc::Build::new().file("src/android-api.c").try_expand() {
Ok(result) => result,
Err(e) => {
println!("failed to run C compiler: {}", e);
println!("failed to run C compiler: {e}");
return;
}
};
let expansion = match std::str::from_utf8(&expansion) {
Ok(s) => s,
Err(_) => return,
};
println!("expanded android version detection:\n{}", expansion);
println!("expanded android version detection:\n{expansion}");
let marker = "APIVERSION";
let i = match expansion.find(marker) {
Some(i) => i,
Expand Down
4 changes: 2 additions & 2 deletions crates/cpp_smoke_test/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ fn smoke_test_cpp() {
.take(2)
.collect();

println!("actual names = {:#?}", names);
println!("actual names = {names:#?}");

let expected = [
"void space::templated_trampoline<void (*)()>(void (*)())",
"cpp_trampoline",
];
println!("expected names = {:#?}", expected);
println!("expected names = {expected:#?}");

assert_eq!(names.len(), expected.len());
for (actual, expected) in names.iter().zip(expected.iter()) {
Expand Down
6 changes: 3 additions & 3 deletions examples/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn print() {
let mut cnt = 0;
backtrace::trace(|frame| {
let ip = frame.ip();
print!("frame #{:<2} - {:#02$x}", cnt, ip as usize, HEX_WIDTH);
print!("frame #{cnt:<2} - {:#0HEX_WIDTH$x}", ip as usize);
cnt += 1;

let mut resolved = false;
Expand All @@ -33,13 +33,13 @@ fn print() {
}

if let Some(name) = symbol.name() {
print!(" - {}", name);
print!(" - {name}");
} else {
print!(" - <unknown>");
}
if let Some(file) = symbol.filename() {
if let Some(l) = symbol.lineno() {
print!("\n{:13}{:4$}@ {}:{}", "", "", file.display(), l, HEX_WIDTH);
print!("\n{:13}{:HEX_WIDTH$}@ {}:{l}", "", "", file.display());
}
}
println!("");
Expand Down
14 changes: 7 additions & 7 deletions src/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ impl BacktraceFrameFmt<'_, '_, '_> {
if self.symbol_index == 0 {
write!(self.fmt.fmt, "{:4}: ", self.fmt.frame_index)?;
if let PrintFmt::Full = self.fmt.format {
write!(self.fmt.fmt, "{:1$?} - ", frame_ip, HEX_WIDTH)?;
write!(self.fmt.fmt, "{frame_ip:HEX_WIDTH$?} - ")?;
}
} else {
write!(self.fmt.fmt, " ")?;
Expand All @@ -260,8 +260,8 @@ impl BacktraceFrameFmt<'_, '_, '_> {
// more information if we're a full backtrace. Here we also handle
// symbols which don't have a name,
match (symbol_name, &self.fmt.format) {
(Some(name), PrintFmt::Short) => write!(self.fmt.fmt, "{:#}", name)?,
(Some(name), PrintFmt::Full) => write!(self.fmt.fmt, "{}", name)?,
(Some(name), PrintFmt::Short) => write!(self.fmt.fmt, "{name:#}")?,
(Some(name), PrintFmt::Full) => write!(self.fmt.fmt, "{name}")?,
(None, _) | (_, PrintFmt::__Nonexhaustive) => write!(self.fmt.fmt, "<unknown>")?,
}
self.fmt.fmt.write_str("\n")?;
Expand All @@ -283,18 +283,18 @@ impl BacktraceFrameFmt<'_, '_, '_> {
// Filename/line are printed on lines under the symbol name, so print
// some appropriate whitespace to sort of right-align ourselves.
if let PrintFmt::Full = self.fmt.format {
write!(self.fmt.fmt, "{:1$}", "", HEX_WIDTH)?;
write!(self.fmt.fmt, "{:HEX_WIDTH$}", "")?;
}
write!(self.fmt.fmt, " at ")?;

// Delegate to our internal callback to print the filename and then
// print out the line number.
(self.fmt.print_path)(self.fmt.fmt, file)?;
write!(self.fmt.fmt, ":{}", line)?;
write!(self.fmt.fmt, ":{line}")?;

// Add column number, if available.
if let Some(colno) = colno {
write!(self.fmt.fmt, ":{}", colno)?;
write!(self.fmt.fmt, ":{colno}")?;
}

write!(self.fmt.fmt, "\n")?;
Expand All @@ -305,7 +305,7 @@ impl BacktraceFrameFmt<'_, '_, '_> {
// We only care about the first symbol of a frame
if self.symbol_index == 0 {
self.fmt.fmt.write_str("{{{bt:")?;
write!(self.fmt.fmt, "{}:{:?}", self.fmt.frame_index, frame_ip)?;
write!(self.fmt.fmt, "{}:{frame_ip:?}", self.fmt.frame_index)?;
self.fmt.fmt.write_str("}}}\n")?;
}
Ok(())
Expand Down
6 changes: 3 additions & 3 deletions tests/accuracy/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@ fn verify(filelines: &[Pos]) {
println!("-----------------------------------");
println!("looking for:");
for (file, line) in filelines.iter().rev() {
println!("\t{}:{}", file, line);
println!("\t{file}:{line}");
}
println!("found:\n{:?}", trace);
println!("found:\n{trace:?}");
let mut symbols = trace.frames().iter().flat_map(|frame| frame.symbols());
let mut iter = filelines.iter().rev();
while let Some((file, line)) = iter.next() {
loop {
let sym = match symbols.next() {
Some(sym) => sym,
None => panic!("failed to find {}:{}", file, line),
None => panic!("{}", "failed to find {file}:{line}"),
};
if let Some(filename) = sym.filename() {
if let Some(lineno) = sym.lineno() {
Expand Down
4 changes: 2 additions & 2 deletions tests/skip_inner_frames.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn backtrace_new_unresolved_should_start_with_call_site_trace() {
}
let mut b = Backtrace::new_unresolved();
b.resolve();
println!("{:?}", b);
println!("{b:?}");

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

Expand All @@ -34,7 +34,7 @@ fn backtrace_new_should_start_with_call_site_trace() {
return;
}
let b = Backtrace::new();
println!("{:?}", b);
println!("{b:?}");

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

Expand Down
12 changes: 6 additions & 6 deletions tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ fn smoke_test_frames() {
backtrace::resolve_frame(frame, |sym| {
print!("symbol ip:{:?} address:{:?} ", frame.ip(), frame.symbol_address());
if let Some(name) = sym.name() {
print!("name:{} ", name);
print!("name:{name} ");
}
if let Some(file) = sym.filename() {
print!("file:{} ", file.display());
}
if let Some(lineno) = sym.lineno() {
print!("lineno:{} ", lineno);
print!("lineno:{lineno} ");
}
if let Some(colno) = sym.colno() {
print!("colno:{} ", colno);
print!("colno:{colno} ");
}
println!();
});
Expand Down Expand Up @@ -257,12 +257,12 @@ fn sp_smoke_test() {

if refs.len() < 5 {
recursive_stack_references(refs);
eprintln!("exiting: {}", x);
eprintln!("exiting: {x}");
return;
}

backtrace::trace(make_trace_closure(refs));
eprintln!("exiting: {}", x);
eprintln!("exiting: {x}");
}

// NB: the following `make_*` functions are pulled out of line, rather than
Expand All @@ -284,7 +284,7 @@ fn sp_smoke_test() {
sym.name()
.and_then(|name| name.as_str())
.map_or(false, |name| {
eprintln!("name = {}", name);
eprintln!("name = {name}");
name.contains("recursive_stack_references")
})
});
Expand Down

0 comments on commit 9172eb4

Please sign in to comment.