Skip to content

Commit dccdb4d

Browse files
authored
Upgrade cpp_demangle to the latest version. (#732)
cpp_demangle 0.5.0 drops the `Display` impl on the `Symbol` object because it can subtly violate the `Display` contract. The recommended replacement is `Symbol::demangle`. Changelog: https://github.com/gimli-rs/cpp_demangle/blob/0.5.0/CHANGELOG.md#050
1 parent 50fe434 commit dccdb4d

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ rustc-demangle = "0.1.24"
3434
serde = { version = "1.0", optional = true, features = ['derive'] }
3535

3636
# Optionally demangle C++ frames' symbols in backtraces.
37-
cpp_demangle = { default-features = false, version = "0.4.0", optional = true, features = [
37+
cpp_demangle = { default-features = false, version = "0.5.0", optional = true, features = [
3838
"alloc",
3939
] }
4040

src/symbolize/mod.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,13 @@ impl<'a> fmt::Display for SymbolName<'a> {
373373

374374
#[cfg(feature = "cpp_demangle")]
375375
{
376+
// This may fail to print if the demangled symbol isn't actually
377+
// valid, so handle the error here gracefully by not propagating
378+
// it outwards.
376379
if let Some(ref cpp) = self.cpp_demangled.0 {
377-
return cpp.fmt(f);
380+
if let Ok(s) = cpp.demangle() {
381+
return s.fmt(f);
382+
}
378383
}
379384
}
380385

@@ -390,14 +395,11 @@ impl<'a> fmt::Debug for SymbolName<'a> {
390395

391396
#[cfg(all(feature = "std", feature = "cpp_demangle"))]
392397
{
393-
use std::fmt::Write;
394-
395-
// This may to print if the demangled symbol isn't actually
398+
// This may fail to print if the demangled symbol isn't actually
396399
// valid, so handle the error here gracefully by not propagating
397400
// it outwards.
398401
if let Some(ref cpp) = self.cpp_demangled.0 {
399-
let mut s = String::new();
400-
if write!(s, "{cpp}").is_ok() {
402+
if let Ok(s) = cpp.demangle() {
401403
return s.fmt(f);
402404
}
403405
}

0 commit comments

Comments
 (0)