diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2021-08-29 16:25:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-29 16:25:28 +0200 |
| commit | 63cfbf5d9f402357c0eaf8923363a4ea26942ec0 (patch) | |
| tree | 13aee7bebdb9404ada3a59148e6807857b898e77 | |
| parent | 22973a884455fa2885699c1479603c8abe44232b (diff) | |
| parent | 5eb960c8d9b33caade6fc637b8258f5a25572461 (diff) | |
| download | rust-63cfbf5d9f402357c0eaf8923363a4ea26942ec0.tar.gz rust-63cfbf5d9f402357c0eaf8923363a4ea26942ec0.zip | |
Rollup merge of #85534 - csmoe:demagnle-assert, r=michaelwoerister
add rustc-demangle assertion on mangled symbol cc https://github.com/rust-lang/rust/issues/60705#issuecomment-844880365 r? `@michaelwoerister`
| -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 551309f4a8c..220c9f7e2ec 100644 --- a/compiler/rustc_symbol_mangling/src/lib.rs +++ b/compiler/rustc_symbol_mangling/src/lib.rs @@ -246,10 +246,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 { |
