-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hir: Do not introduce dummy type names for extern
blocks in def paths
#92032
Conversation
r? @oli-obk (rust-highfive has picked a reviewer for you, use r? to override) |
8a46c87
to
66e232f
Compare
Is this testable on master? |
This should be a pure refactoring (maybe with exception of some debug logging where |
@bors r+ rollup |
📌 Commit 66e232fcb27478ce9f0f404dfc24b09a8426cef0 has been approved by |
// Skip `::{{constructor}}` on tuple/unit structs. | ||
if let DefPathData::Ctor = disambiguated_data.data { | ||
// Skip `::{{extern}}` blocks and `::{{constructor}}` on tuple/unit structs. | ||
if let DefPathData::ForeignMod | DefPathData::Ctor = disambiguated_data.data { | ||
return Ok(self); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to remove the FIXME a couple of lines below, will fix tomorrow.
@bors r- |
// Filter out extern blocks | ||
(elem.data != DefPathData::ForeignMod).then(|| elem.data.to_string()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc #91948: How does this interact with that PR, specifically #91948 (comment)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When both PRs are merged this will turn into just elem.data.get_opt_name()
.
66e232f
to
fbe4f5e
Compare
Use a separate nameless `DefPathData` variant instead
fbe4f5e
to
0d61852
Compare
Updated with #92032 (comment) addressed. |
📌 Commit 0d61852 has been approved by |
…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#91858 (pass -Wl,-z,origin to set DF_ORIGIN when using rpath) - rust-lang#91923 (Remove `in_band_lifetimes` from `rustc_query_impl`) - rust-lang#91925 (Remove `in_band_lifetimes` from `rustc_privacy`) - rust-lang#91977 (Clean up search code and unify function returned values) - rust-lang#92018 (Fix typo in "new region bound" suggestion) - rust-lang#92022 (Eliminate duplicate codes of expected_found_bool) - rust-lang#92032 (hir: Do not introduce dummy type names for `extern` blocks in def paths) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
@@ -771,6 +771,10 @@ 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', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this code actually reachable? What will the demangled symbol look like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's reachable.
Functions and statics in foreign blocks are not mangled, but foreign types are mangled when they are used in any non-foreign symbols.
Something like
extern { type Type; }
fn foo(_arg: &Type) {}
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 rust-lang#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.)
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 rust-lang#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.)
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 rust-lang#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.)
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 rust-lang#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.)
Use a separate nameless
DefPathData
variant instead.Extracted from #91795.