Skip to content

Commit 6cf1fa7

Browse files
committed
Addressed feedback and added a few more
* also did one minor spelling change in a print statement in `current-exe-mismatch.rs`
1 parent 9172eb4 commit 6cf1fa7

File tree

11 files changed

+16
-17
lines changed

11 files changed

+16
-17
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

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn print() {
2121
let mut cnt = 0;
2222
backtrace::trace(|frame| {
2323
let ip = frame.ip();
24-
print!("frame #{cnt:<2} - {:#0HEX_WIDTH$x}", ip as usize);
24+
print!("frame #{:<2} - {:#02$x}", cnt, ip as usize, HEX_WIDTH);
2525
cnt += 1;
2626

2727
let mut resolved = false;
@@ -39,7 +39,7 @@ fn print() {
3939
}
4040
if let Some(file) = symbol.filename() {
4141
if let Some(l) = symbol.lineno() {
42-
print!("\n{:13}{:HEX_WIDTH$}@ {}:{l}", "", "", file.display());
42+
print!("\n{:13}{:4$}@ {}:{}", "", "", file.display(), l, HEX_WIDTH);
4343
}
4444
}
4545
println!("");

src/capture.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ impl Backtrace {
156156
/// use backtrace::Backtrace;
157157
///
158158
/// let mut current_backtrace = Backtrace::new_unresolved();
159-
/// println!("{:?}", current_backtrace); // no symbol names
159+
/// println!("{current_backtrace:?}"); // no symbol names
160160
/// current_backtrace.resolve();
161-
/// println!("{:?}", current_backtrace); // symbol names now present
161+
/// println!("{current_backtrace:?}"); // symbol names now present
162162
/// ```
163163
///
164164
/// # Required features

src/print.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl BacktraceFrameFmt<'_, '_, '_> {
283283
// Filename/line are printed on lines under the symbol name, so print
284284
// some appropriate whitespace to sort of right-align ourselves.
285285
if let PrintFmt::Full = self.fmt.format {
286-
write!(self.fmt.fmt, "{:HEX_WIDTH$}", "")?;
286+
write!(self.fmt.fmt, "{:1$}", "", HEX_WIDTH)?;
287287
}
288288
write!(self.fmt.fmt, " at ")?;
289289

@@ -305,7 +305,7 @@ impl BacktraceFrameFmt<'_, '_, '_> {
305305
// We only care about the first symbol of a frame
306306
if self.symbol_index == 0 {
307307
self.fmt.fmt.write_str("{{{bt:")?;
308-
write!(self.fmt.fmt, "{}:{frame_ip:?}", self.fmt.frame_index)?;
308+
write!(self.fmt.fmt, "{}:{:?}", self.fmt.frame_index, frame_ip)?;
309309
self.fmt.fmt.write_str("}}}\n")?;
310310
}
311311
Ok(())

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn verify(filelines: &[Pos]) {
103103
loop {
104104
let sym = match symbols.next() {
105105
Some(sym) => sym,
106-
None => panic!("{}", "failed to find {file}:{line}"),
106+
None => panic!("failed to find {}:{}", file, line),
107107
};
108108
if let Some(filename) = sym.filename() {
109109
if let Some(lineno) = sym.lineno() {

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

0 commit comments

Comments
 (0)