mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-26 13:01:27 +03:00
Move variant ctor creation into the brg
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user