Skip to content

Commit 55f9aed

Browse files
committed
Move all the heavy lifting from TyCtxtAt::create_def into TyCtxt::create_def
1 parent 2e900ed commit 55f9aed

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

compiler/rustc_middle/src/ty/context.rs

+17-13
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,22 @@ impl<'tcx> TyCtxtAt<'tcx> {
10461046
name: Symbol,
10471047
def_kind: DefKind,
10481048
) -> TyCtxtFeed<'tcx, LocalDefId> {
1049+
let feed = self.tcx.create_def(parent, name, def_kind);
1050+
1051+
feed.def_span(self.span);
1052+
feed
1053+
}
1054+
}
1055+
1056+
impl<'tcx> TyCtxt<'tcx> {
1057+
/// `tcx`-dependent operations performed for every created definition.
1058+
pub fn create_def(
1059+
self,
1060+
parent: LocalDefId,
1061+
name: Symbol,
1062+
def_kind: DefKind,
1063+
) -> TyCtxtFeed<'tcx, LocalDefId> {
1064+
let data = def_kind.def_path_data(name);
10491065
// The following call has the side effect of modifying the tables inside `definitions`.
10501066
// These very tables are relied on by the incr. comp. engine to decode DepNodes and to
10511067
// decode the on-disk cache.
@@ -1060,18 +1076,6 @@ impl<'tcx> TyCtxtAt<'tcx> {
10601076
// This is fine because:
10611077
// - those queries are `eval_always` so we won't miss their result changing;
10621078
// - this write will have happened before these queries are called.
1063-
let def_id = self.tcx.create_def(parent, name, def_kind);
1064-
1065-
let feed = self.tcx.feed_local_def_id(def_id);
1066-
feed.def_span(self.span);
1067-
feed
1068-
}
1069-
}
1070-
1071-
impl<'tcx> TyCtxt<'tcx> {
1072-
/// `tcx`-dependent operations performed for every created definition.
1073-
pub fn create_def(self, parent: LocalDefId, name: Symbol, def_kind: DefKind) -> LocalDefId {
1074-
let data = def_kind.def_path_data(name);
10751079
let def_id = self.untracked.definitions.write().create_def(parent, data);
10761080

10771081
// This function modifies `self.definitions` using a side-effect.
@@ -1091,7 +1095,7 @@ impl<'tcx> TyCtxt<'tcx> {
10911095
feed.visibility(ty::Visibility::Restricted(parent_mod));
10921096
}
10931097

1094-
def_id
1098+
feed
10951099
}
10961100

10971101
pub fn iter_local_def_id(self) -> impl Iterator<Item = LocalDefId> + 'tcx {

compiler/rustc_resolve/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ impl<'tcx> Resolver<'_, 'tcx> {
12451245
);
12461246

12471247
// FIXME: remove `def_span` body, pass in the right spans here and call `tcx.at().create_def()`
1248-
let def_id = self.tcx.create_def(parent, name, def_kind);
1248+
let def_id = self.tcx.create_def(parent, name, def_kind).def_id();
12491249

12501250
// Create the definition.
12511251
if expn_id != ExpnId::root() {

0 commit comments

Comments
 (0)