Skip to content

Commit f62d981

Browse files
authored
Rollup merge of #121084 - oli-obk:create_def_forever_red2, r=WaffleLapkin
Make sure `tcx.create_def` also depends on the forever red node, instead of just `tcx.at(span).create_def` oversight from #119136 Not actually an issue, because all uses of `tcx.create_def` were in the resolver, which is `eval_always`, but still good to harden against future uses of `create_def` cc `@petrochenkov` `@WaffleLapkin`
2 parents e5186aa + 55f9aed commit f62d981

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
@@ -1053,6 +1053,22 @@ impl<'tcx> TyCtxtAt<'tcx> {
10531053
name: Symbol,
10541054
def_kind: DefKind,
10551055
) -> TyCtxtFeed<'tcx, LocalDefId> {
1056+
let feed = self.tcx.create_def(parent, name, def_kind);
1057+
1058+
feed.def_span(self.span);
1059+
feed
1060+
}
1061+
}
1062+
1063+
impl<'tcx> TyCtxt<'tcx> {
1064+
/// `tcx`-dependent operations performed for every created definition.
1065+
pub fn create_def(
1066+
self,
1067+
parent: LocalDefId,
1068+
name: Symbol,
1069+
def_kind: DefKind,
1070+
) -> TyCtxtFeed<'tcx, LocalDefId> {
1071+
let data = def_kind.def_path_data(name);
10561072
// The following call has the side effect of modifying the tables inside `definitions`.
10571073
// These very tables are relied on by the incr. comp. engine to decode DepNodes and to
10581074
// decode the on-disk cache.
@@ -1067,18 +1083,6 @@ impl<'tcx> TyCtxtAt<'tcx> {
10671083
// This is fine because:
10681084
// - those queries are `eval_always` so we won't miss their result changing;
10691085
// - this write will have happened before these queries are called.
1070-
let def_id = self.tcx.create_def(parent, name, def_kind);
1071-
1072-
let feed = self.tcx.feed_local_def_id(def_id);
1073-
feed.def_span(self.span);
1074-
feed
1075-
}
1076-
}
1077-
1078-
impl<'tcx> TyCtxt<'tcx> {
1079-
/// `tcx`-dependent operations performed for every created definition.
1080-
pub fn create_def(self, parent: LocalDefId, name: Symbol, def_kind: DefKind) -> LocalDefId {
1081-
let data = def_kind.def_path_data(name);
10821086
let def_id = self.untracked.definitions.write().create_def(parent, data);
10831087

10841088
// This function modifies `self.definitions` using a side-effect.
@@ -1098,7 +1102,7 @@ impl<'tcx> TyCtxt<'tcx> {
10981102
feed.visibility(ty::Visibility::Restricted(parent_mod));
10991103
}
11001104

1101-
def_id
1105+
feed
11021106
}
11031107

11041108
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)