diff --git a/README.md b/README.md index cd80a697c..288b7d8f4 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ fn main() { // do_some_work(); - println!("{:?}", bt); + println!("{bt:?}"); } ``` diff --git a/crates/debuglink/src/main.rs b/crates/debuglink/src/main.rs index 99265ae9a..b0f4063d7 100644 --- a/crates/debuglink/src/main.rs +++ b/crates/debuglink/src/main.rs @@ -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; @@ -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(); diff --git a/crates/macos_frames_test/tests/main.rs b/crates/macos_frames_test/tests/main.rs index f0e905b24..5d74bdcc3 100644 --- a/crates/macos_frames_test/tests/main.rs +++ b/crates/macos_frames_test/tests/main.rs @@ -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) diff --git a/examples/raw.rs b/examples/raw.rs index fbf0791f9..95e17dbd5 100644 --- a/examples/raw.rs +++ b/examples/raw.rs @@ -21,7 +21,7 @@ fn print() { let mut cnt = 0; backtrace::trace(|frame| { let ip = frame.ip(); - print!("frame #{cnt:<2} - {:#0HEX_WIDTH$x}", ip as usize); + print!("frame #{:<2} - {:#02$x}", cnt, ip as usize, HEX_WIDTH); cnt += 1; let mut resolved = false; @@ -39,7 +39,7 @@ fn print() { } if let Some(file) = symbol.filename() { if let Some(l) = symbol.lineno() { - print!("\n{:13}{:HEX_WIDTH$}@ {}:{l}", "", "", file.display()); + print!("\n{:13}{:4$}@ {}:{}", "", "", file.display(), l, HEX_WIDTH); } } println!(""); diff --git a/src/capture.rs b/src/capture.rs index e0dd9c474..417ebd60b 100644 --- a/src/capture.rs +++ b/src/capture.rs @@ -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 diff --git a/src/print.rs b/src/print.rs index f7bd83923..d608c84f3 100644 --- a/src/print.rs +++ b/src/print.rs @@ -283,7 +283,7 @@ 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, "{:HEX_WIDTH$}", "")?; + write!(self.fmt.fmt, "{:1$}", "", HEX_WIDTH)?; } write!(self.fmt.fmt, " at ")?; @@ -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, "{}:{frame_ip:?}", self.fmt.frame_index)?; + write!(self.fmt.fmt, "{}:{:?}", self.fmt.frame_index, frame_ip)?; self.fmt.fmt.write_str("}}}\n")?; } Ok(()) diff --git a/src/print/fuchsia.rs b/src/print/fuchsia.rs index ce3f17862..6117bc8b3 100644 --- a/src/print/fuchsia.rs +++ b/src/print/fuchsia.rs @@ -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(()) } diff --git a/src/symbolize/mod.rs b/src/symbolize/mod.rs index dbc346522..b2518f388 100644 --- a/src/symbolize/mod.rs +++ b/src/symbolize/mod.rs @@ -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) } } diff --git a/tests/accuracy/main.rs b/tests/accuracy/main.rs index 4bccdcce0..fcfd5b31b 100644 --- a/tests/accuracy/main.rs +++ b/tests/accuracy/main.rs @@ -103,7 +103,7 @@ fn verify(filelines: &[Pos]) { 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() { diff --git a/tests/current-exe-mismatch.rs b/tests/current-exe-mismatch.rs index b655827fb..91741bad3 100644 --- a/tests/current-exe-mismatch.rs +++ b/tests/current-exe-mismatch.rs @@ -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!(); } } @@ -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; diff --git a/tests/long_fn_name.rs b/tests/long_fn_name.rs index fa4cfda15..4a03825b6 100644 --- a/tests/long_fn_name.rs +++ b/tests/long_fn_name.rs @@ -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::>>>>>>>>>::new(); - println!("{:?}", bt); + println!("{bt:?}"); let mut found_long_name_frame = false;