Move variant ctor creation into the brg

This commit is contained in:
Oli Scherer
2026-04-20 14:45:04 +02:00
parent af3e34bf65
commit 797e68f240
2 changed files with 9 additions and 13 deletions
@@ -1504,7 +1504,13 @@ pub(crate) fn brg_visit_variant(&mut self, variant: &'a ast::Variant) {
};
// Define a constructor name in the value namespace.
if let Some(ctor_node_id) = variant.data.ctor_node_id() {
if let Some((ctor_kind, ctor_node_id)) = CtorKind::from_ast(&variant.data) {
self.create_def(
ctor_node_id,
None,
DefKind::Ctor(CtorOf::Variant, ctor_kind),
variant.span,
);
let feed = self.r.feed(ctor_node_id);
let ctor_def_id = feed.key();
let ctor_res = self.res(ctor_def_id);
+2 -12
View File
@@ -7,8 +7,8 @@
use rustc_expand::expand::AstFragment;
use rustc_hir as hir;
use rustc_hir::Target;
use rustc_hir::def::DefKind;
use rustc_hir::def::Namespace::{TypeNS, ValueNS};
use rustc_hir::def::{CtorKind, CtorOf, DefKind};
use rustc_hir::def_id::LocalDefId;
use rustc_middle::span_bug;
use rustc_span::{Span, Symbol, sym};
@@ -295,17 +295,7 @@ fn visit_variant(&mut self, v: &'a Variant) {
return;
}
let def = self.create_def(v.id, Some(v.ident.name), DefKind::Variant, v.span);
self.with_parent(def, |this| {
if let Some((ctor_kind, ctor_node_id)) = CtorKind::from_ast(&v.data) {
this.create_def(
ctor_node_id,
None,
DefKind::Ctor(CtorOf::Variant, ctor_kind),
v.span,
);
}
this.brg_visit_variant(v);
});
self.with_parent(def, |this| this.brg_visit_variant(v));
}
fn visit_where_predicate(&mut self, pred: &'a WherePredicate) {