diff options
| author | csmoe <csmoe@msn.com> | 2021-05-21 10:11:40 +0800 |
|---|---|---|
| committer | csmoe <csmoe@msn.com> | 2021-08-27 21:18:20 +0800 |
| commit | 5eb960c8d9b33caade6fc637b8258f5a25572461 (patch) | |
| tree | e070c8cab5a6b6432b4c45894bc8fc6d68b2aa6a | |
| parent | be8450eec8fa635a9132f799012fed83ba59121e (diff) | |
| download | rust-5eb960c8d9b33caade6fc637b8258f5a25572461.tar.gz rust-5eb960c8d9b33caade6fc637b8258f5a25572461.zip | |
add rustc-demangle assertion on mangled symbol
| -rw-r--r-- | compiler/rustc_symbol_mangling/src/lib.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/compiler/rustc_symbol_mangling/src/lib.rs b/compiler/rustc_symbol_mangling/src/lib.rs index 7fb24ad1ed8..bea6cc12ad8 100644 --- a/compiler/rustc_symbol_mangling/src/lib.rs +++ b/compiler/rustc_symbol_mangling/src/lib.rs @@ -250,10 +250,18 @@ fn compute_symbol_name( tcx.symbol_mangling_version(mangling_version_crate) }; - match mangling_version { + let symbol = match mangling_version { SymbolManglingVersion::Legacy => legacy::mangle(tcx, instance, instantiating_crate), SymbolManglingVersion::V0 => v0::mangle(tcx, instance, instantiating_crate), - } + }; + + debug_assert!( + rustc_demangle::try_demangle(&symbol).is_ok(), + "compute_symbol_name: `{}` cannot be demangled", + symbol + ); + + symbol } fn is_generic(substs: SubstsRef<'_>) -> bool { |
