def collector: Set correct namespace in DefPathData for foreign types

This commit is contained in:
Vadim Petrochenkov 2023-11-28 15:43:07 +03:00
parent f0dc906319
commit 84de641484
2 changed files with 11 additions and 17 deletions

View File

@ -194,25 +194,19 @@ fn visit_use_tree(&mut self, use_tree: &'a UseTree, id: NodeId, _nested: bool) {
visit::walk_use_tree(self, use_tree, id);
}
fn visit_foreign_item(&mut self, foreign_item: &'a ForeignItem) {
let def_kind = match foreign_item.kind {
ForeignItemKind::Static(_, mt, _) => DefKind::Static(mt),
ForeignItemKind::Fn(_) => DefKind::Fn,
ForeignItemKind::TyAlias(_) => DefKind::ForeignTy,
ForeignItemKind::MacCall(_) => return self.visit_macro_invoc(foreign_item.id),
fn visit_foreign_item(&mut self, fi: &'a ForeignItem) {
let (def_data, def_kind) = match fi.kind {
ForeignItemKind::Static(_, mt, _) => {
(DefPathData::ValueNs(fi.ident.name), DefKind::Static(mt))
}
ForeignItemKind::Fn(_) => (DefPathData::ValueNs(fi.ident.name), DefKind::Fn),
ForeignItemKind::TyAlias(_) => (DefPathData::TypeNs(fi.ident.name), DefKind::ForeignTy),
ForeignItemKind::MacCall(_) => return self.visit_macro_invoc(fi.id),
};
// FIXME: The namespace is incorrect for foreign types.
let def = self.create_def(
foreign_item.id,
DefPathData::ValueNs(foreign_item.ident.name),
def_kind,
foreign_item.span,
);
let def = self.create_def(fi.id, def_data, def_kind, fi.span);
self.with_parent(def, |this| {
visit::walk_foreign_item(this, foreign_item);
});
self.with_parent(def, |this| visit::walk_foreign_item(this, fi));
}
fn visit_variant(&mut self, v: &'a Variant) {

View File

@ -1,4 +1,4 @@
error: symbol-name(_RMCsCRATE_HASH_13foreign_typesINtB<REF>_5CheckNvB<REF>_11ForeignTypeE)
error: symbol-name(_RMCsCRATE_HASH_13foreign_typesINtB<REF>_5CheckNtB<REF>_11ForeignTypeE)
--> $DIR/foreign-types.rs:13:1
|
LL | #[rustc_symbol_name]