mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Stop creating ctor def ids for unions and move the ctor def id creation into the brg
This commit is contained in:
@@ -902,7 +902,7 @@ fn build_reduced_graph_for_item(&mut self, item: &'a Item) {
|
||||
|
||||
// If this is a tuple or unit struct, define a name
|
||||
// in the value namespace as well.
|
||||
if let Some(ctor_node_id) = vdata.ctor_node_id() {
|
||||
if let Some((ctor_kind, ctor_node_id)) = CtorKind::from_ast(vdata) {
|
||||
// If the structure is marked as non_exhaustive then lower the visibility
|
||||
// to within the crate.
|
||||
let mut ctor_vis = if vis.is_public()
|
||||
@@ -927,6 +927,14 @@ fn build_reduced_graph_for_item(&mut self, item: &'a Item) {
|
||||
}
|
||||
field_visibilities.push(field_vis.to_def_id());
|
||||
}
|
||||
// If this is a unit or tuple-like struct, register the constructor.
|
||||
self.create_def(
|
||||
ctor_node_id,
|
||||
None,
|
||||
DefKind::Ctor(CtorOf::Struct, ctor_kind),
|
||||
item.span,
|
||||
);
|
||||
|
||||
let feed = self.r.feed(ctor_node_id);
|
||||
let ctor_def_id = feed.key();
|
||||
let ctor_res = self.res(ctor_def_id);
|
||||
|
||||
@@ -191,24 +191,7 @@ fn visit_item(&mut self, i: &'a Item) {
|
||||
}
|
||||
|
||||
self.with_parent(def_id, |this| {
|
||||
this.with_impl_trait(ImplTraitContext::Existential, |this| {
|
||||
match i.kind {
|
||||
ItemKind::Struct(_, _, ref struct_def)
|
||||
| ItemKind::Union(_, _, ref struct_def) => {
|
||||
// If this is a unit or tuple-like struct, register the constructor.
|
||||
if let Some((ctor_kind, ctor_node_id)) = CtorKind::from_ast(struct_def) {
|
||||
this.create_def(
|
||||
ctor_node_id,
|
||||
None,
|
||||
DefKind::Ctor(CtorOf::Struct, ctor_kind),
|
||||
i.span,
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
this.brg_visit_item(i);
|
||||
})
|
||||
this.with_impl_trait(ImplTraitContext::Existential, |this| this.brg_visit_item(i))
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user