Skip to content

Commit 63cfbf5

Browse files
Rollup merge of #85534 - csmoe:demagnle-assert, r=michaelwoerister
add rustc-demangle assertion on mangled symbol cc #60705 (comment) r? `@michaelwoerister`
2 parents 22973a8 + 5eb960c commit 63cfbf5

File tree

1 file changed

+10
-2
lines changed
  • compiler/rustc_symbol_mangling/src

1 file changed

+10
-2
lines changed

compiler/rustc_symbol_mangling/src/lib.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,18 @@ fn compute_symbol_name(
246246
tcx.symbol_mangling_version(mangling_version_crate)
247247
};
248248

249-
match mangling_version {
249+
let symbol = match mangling_version {
250250
SymbolManglingVersion::Legacy => legacy::mangle(tcx, instance, instantiating_crate),
251251
SymbolManglingVersion::V0 => v0::mangle(tcx, instance, instantiating_crate),
252-
}
252+
};
253+
254+
debug_assert!(
255+
rustc_demangle::try_demangle(&symbol).is_ok(),
256+
"compute_symbol_name: `{}` cannot be demangled",
257+
symbol
258+
);
259+
260+
symbol
253261
}
254262

255263
fn is_generic(substs: SubstsRef<'_>) -> bool {

0 commit comments

Comments
 (0)