Skip to content

Commit

Permalink
Addressed feedback and added a few more
Browse files Browse the repository at this point in the history
* also did one minor spelling change in a print statement in `current-exe-mismatch.rs`
  • Loading branch information
nyurik committed Jul 2, 2023
1 parent 9172eb4 commit a794c57
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 16 deletions.
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
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
4 changes: 2 additions & 2 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 #{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;
Expand All @@ -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!("");
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
4 changes: 2 additions & 2 deletions src/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ")?;

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, "{}:{frame_ip:?}", self.fmt.frame_index)?;
write!(self.fmt.fmt, "{}:{:?}", self.fmt.frame_index, frame_ip)?;
self.fmt.fmt.write_str("}}}\n")?;
}
Ok(())
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/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

0 comments on commit a794c57

Please sign in to comment.