Skip to content

Apply clippy::uninlined_format_args fixes #486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn main() {

// do_some_work();

println!("{:?}", bt);
println!("{bt:?}");
}
```

Expand Down
7 changes: 2 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,15 @@ fn build_android() {
let expansion = match cc::Build::new().file(&android_api_c).try_expand() {
Ok(result) => result,
Err(e) => {
eprintln!(
"warning: android version detection failed while running C compiler: {}",
e
);
eprintln!("warning: android version detection failed while running C compiler: {e}");
return;
}
};
let expansion = match std::str::from_utf8(&expansion) {
Ok(s) => s,
Err(_) => return,
};
eprintln!("expanded android version detection:\n{}", expansion);
eprintln!("expanded android version detection:\n{expansion}");
let i = match expansion.find(MARKER) {
Some(i) => i,
None => return,
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
4 changes: 2 additions & 2 deletions crates/debuglink/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn main() {
let expect = std::path::Path::new(&crate_dir).join("src/main.rs");

let bt = backtrace::Backtrace::new();
println!("{:?}", bt);
println!("{bt:?}");

let mut found_main = false;

Expand All @@ -20,7 +20,7 @@ fn main() {
}

if let Some(name) = symbols[0].name() {
let name = format!("{:#}", name);
let name = format!("{name:#}");
if name == "debuglink::main" {
found_main = true;
let filename = symbols[0].filename().unwrap();
Expand Down
3 changes: 1 addition & 2 deletions crates/macos_frames_test/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ fn backtrace_no_dsym() {
let executable_name = dsym_path.file_name().unwrap().to_str().unwrap().to_string();
assert!(dsym_path.pop()); // Pop executable
dsym_path.push(format!(
"{}.dSYM/Contents/Resources/DWARF/{0}",
executable_name
"{executable_name}.dSYM/Contents/Resources/DWARF/{executable_name}"
));
let _ = fs::OpenOptions::new()
.read(false)
Expand Down
2 changes: 1 addition & 1 deletion examples/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn print() {
}

if let Some(name) = symbol.name() {
print!(" - {}", name);
print!(" - {name}");
} else {
print!(" - <unknown>");
}
Expand Down
4 changes: 2 additions & 2 deletions src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ impl Backtrace {
/// use backtrace::Backtrace;
///
/// let mut current_backtrace = Backtrace::new_unresolved();
/// println!("{:?}", current_backtrace); // no symbol names
/// println!("{current_backtrace:?}"); // no symbol names
/// current_backtrace.resolve();
/// println!("{:?}", current_backtrace); // symbol names now present
/// println!("{current_backtrace:?}"); // symbol names now present
/// ```
///
/// # Required features
Expand Down
10 changes: 5 additions & 5 deletions src/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,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 @@ -252,8 +252,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 Down Expand Up @@ -282,11 +282,11 @@ impl BacktraceFrameFmt<'_, '_, '_> {
// 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 Down
2 changes: 1 addition & 1 deletion src/print/fuchsia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ struct HexSlice<'a> {
impl fmt::Display for HexSlice<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for byte in self.bytes {
write!(f, "{:02x}", byte)?;
write!(f, "{byte:02x}")?;
}
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/symbolize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ cfg_if::cfg_if! {
// it outwards.
if let Some(ref cpp) = self.cpp_demangled.0 {
let mut s = String::new();
if write!(s, "{}", cpp).is_ok() {
if write!(s, "{cpp}").is_ok() {
return s.fmt(f)
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/accuracy/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ 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() {
Expand Down
4 changes: 2 additions & 2 deletions tests/current-exe-mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn main() {
println!("test result: ignored");
}
Err(EarlyExit::IoError(e)) => {
println!("{} parent encoutered IoError: {:?}", file!(), e);
println!("{} parent encountered IoError: {:?}", file!(), e);
panic!();
}
}
Expand Down Expand Up @@ -74,7 +74,7 @@ fn parent() -> Result<(), EarlyExit> {

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

let mut found_my_name = false;

Expand Down
2 changes: 1 addition & 1 deletion tests/long_fn_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn test_long_fn_name() {
// It's actually longer since it also includes `::`, `<>` and the
// name of the current module
let bt = S::<S<S<S<S<S<S<S<S<S<i32>>>>>>>>>>::new();
println!("{:?}", bt);
println!("{bt:?}");

let mut found_long_name_frame = false;

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 @@ -111,16 +111,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 @@ -268,12 +268,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 @@ -295,7 +295,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