Rust v0 symbols can have a .suffix because if compiler transformations. These can be ignored it the demangled name. Which is what this patch implements). But an alternative implementation could be to follow what C++ does and represent these as [clone .suffix] tagged onto the demangled name. But this seems somewhat confusing since it results in a demangled name that cannot be mangled again. And it would mean trying to decode compiler internal naming.
https://bugs.kde.org/show_bug.cgi?id=445916 https://github.com/rust-lang/rust/issues/60705 libiberty/Changelog * rust-demangle.c (rust_demangle_callback): Ignore everything after '.' char in sym for v0. * testsuite/rust-demangle-expected: Add new .suffix testcase. --- libiberty/rust-demangle.c | 4 ++++ libiberty/testsuite/rust-demangle-expected | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c index 449941b56dc1..dee9eb64df79 100644 --- a/libiberty/rust-demangle.c +++ b/libiberty/rust-demangle.c @@ -1340,6 +1340,10 @@ rust_demangle_callback (const char *mangled, int options, /* Rust symbols (v0) use only [_0-9a-zA-Z] characters. */ for (p = rdm.sym; *p; p++) { + /* Rust v0 symbols can have '.' suffixes, ignore those. */ + if (rdm.version == 0 && *p == '.') + break; + rdm.sym_len++; if (*p == '_' || ISALNUM (*p)) diff --git a/libiberty/testsuite/rust-demangle-expected b/libiberty/testsuite/rust-demangle-expected index 7dca315d0054..bc32ed85f882 100644 --- a/libiberty/testsuite/rust-demangle-expected +++ b/libiberty/testsuite/rust-demangle-expected @@ -295,3 +295,9 @@ _RMCs4fqI2P2rA04_13const_genericINtB0_4CharKc2202_E --format=auto _RNvNvMCs4fqI2P2rA04_13const_genericINtB4_3FooKpE3foo3FOO <const_generic::Foo<_>>::foo::FOO +# +# Suffixes +# +--format=rust +_RNvMs0_NtCs5l0EXMQXRMU_21rustc_data_structures17obligation_forestINtB5_16ObligationForestNtNtNtCsdozMG8X9FIu_21rustc_trait_selection6traits7fulfill26PendingPredicateObligationE22register_obligation_atB1v_.llvm.8517020237817239694 +<rustc_data_structures::obligation_forest::ObligationForest<rustc_trait_selection::traits::fulfill::PendingPredicateObligation>>::register_obligation_at -- 2.18.4