-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it's reachable. extern { type Type; }
fn foo(_arg: &Type) {} |
||
|
||
// Uppercase categories are more stable than lowercase ones. | ||
DefPathData::TypeNs(_) => 't', | ||
DefPathData::ValueNs(_) => 'v', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ use rustc_data_structures::fx::FxHashSet; | |
use rustc_hir as hir; | ||
use rustc_hir::def::{DefKind, Res}; | ||
use rustc_hir::def_id::DefId; | ||
use rustc_hir::definitions::DefPathData; | ||
use rustc_hir::Mutability; | ||
use rustc_metadata::creader::{CStore, LoadedMacro}; | ||
use rustc_middle::ty::{self, TyCtxt}; | ||
|
@@ -165,9 +166,8 @@ crate fn record_extern_fqn(cx: &mut DocContext<'_>, did: DefId, kind: ItemType) | |
let crate_name = cx.tcx.crate_name(did.krate).to_string(); | ||
|
||
let relative = cx.tcx.def_path(did).data.into_iter().filter_map(|elem| { | ||
// extern blocks have an empty name | ||
let s = elem.data.to_string(); | ||
if !s.is_empty() { Some(s) } else { None } | ||
// Filter out extern blocks | ||
(elem.data != DefPathData::ForeignMod).then(|| elem.data.to_string()) | ||
Comment on lines
+169
to
+170
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. When both PRs are merged this will turn into just |
||
}); | ||
let fqn = if let ItemType::Macro = kind { | ||
// Check to see if it is a macro 2.0 or built-in macro | ||
|
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.