1
Fork 0

Rollup merge of #92316 - petrochenkov:extmangle, r=wesleywiser

mangling_v0: Skip extern blocks during mangling

There's no need to include the dummy `Nt` into the symbol name, items in extern blocks belong to their parent modules for all purposes except for inheriting the ABI and attributes.

Follow up to https://github.com/rust-lang/rust/pull/92032

(There's also a drive-by fix to the `rust-demangler` tool's tests, which don't run on CI, I initially attempted using them for testing this PR.)
This commit is contained in:
Matthias Krüger 2022-01-19 19:19:45 +01:00 committed by GitHub
commit 715cda2e81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 19 deletions

View file

@ -772,9 +772,9 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
disambiguated_data: &DisambiguatedDefPathData,
) -> Result<Self::Path, Self::Error> {
let ns = match disambiguated_data.data {
// FIXME: It shouldn't be necessary to add anything for extern block segments,
// but we add 't' for backward compatibility.
DefPathData::ForeignMod => 't',
// Extern block segments can be skipped, names from extern blocks
// are effectively living in their parent modules.
DefPathData::ForeignMod => return print_prefix(self),
// Uppercase categories are more stable than lowercase ones.
DefPathData::TypeNs(_) => 't',