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 https://github.com/rust-lang/rust/pull/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`
This commit is contained in:
Matthias Krüger 2024-02-15 09:20:20 +01:00 committed by GitHub
commit f62d981a18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 14 deletions

View File

@ -1053,6 +1053,22 @@ pub fn create_def(
name: Symbol, name: Symbol,
def_kind: DefKind, def_kind: DefKind,
) -> TyCtxtFeed<'tcx, LocalDefId> { ) -> TyCtxtFeed<'tcx, LocalDefId> {
let feed = self.tcx.create_def(parent, name, def_kind);
feed.def_span(self.span);
feed
}
}
impl<'tcx> TyCtxt<'tcx> {
/// `tcx`-dependent operations performed for every created definition.
pub fn create_def(
self,
parent: LocalDefId,
name: Symbol,
def_kind: DefKind,
) -> TyCtxtFeed<'tcx, LocalDefId> {
let data = def_kind.def_path_data(name);
// The following call has the side effect of modifying the tables inside `definitions`. // The following call has the side effect of modifying the tables inside `definitions`.
// These very tables are relied on by the incr. comp. engine to decode DepNodes and to // These very tables are relied on by the incr. comp. engine to decode DepNodes and to
// decode the on-disk cache. // decode the on-disk cache.
@ -1067,18 +1083,6 @@ pub fn create_def(
// This is fine because: // This is fine because:
// - those queries are `eval_always` so we won't miss their result changing; // - those queries are `eval_always` so we won't miss their result changing;
// - this write will have happened before these queries are called. // - this write will have happened before these queries are called.
let def_id = self.tcx.create_def(parent, name, def_kind);
let feed = self.tcx.feed_local_def_id(def_id);
feed.def_span(self.span);
feed
}
}
impl<'tcx> TyCtxt<'tcx> {
/// `tcx`-dependent operations performed for every created definition.
pub fn create_def(self, parent: LocalDefId, name: Symbol, def_kind: DefKind) -> LocalDefId {
let data = def_kind.def_path_data(name);
let def_id = self.untracked.definitions.write().create_def(parent, data); let def_id = self.untracked.definitions.write().create_def(parent, data);
// This function modifies `self.definitions` using a side-effect. // This function modifies `self.definitions` using a side-effect.
@ -1098,7 +1102,7 @@ pub fn create_def(self, parent: LocalDefId, name: Symbol, def_kind: DefKind) ->
feed.visibility(ty::Visibility::Restricted(parent_mod)); feed.visibility(ty::Visibility::Restricted(parent_mod));
} }
def_id feed
} }
pub fn iter_local_def_id(self) -> impl Iterator<Item = LocalDefId> + 'tcx { pub fn iter_local_def_id(self) -> impl Iterator<Item = LocalDefId> + 'tcx {

View File

@ -1245,7 +1245,7 @@ fn create_def(
); );
// FIXME: remove `def_span` body, pass in the right spans here and call `tcx.at().create_def()` // FIXME: remove `def_span` body, pass in the right spans here and call `tcx.at().create_def()`
let def_id = self.tcx.create_def(parent, name, def_kind); let def_id = self.tcx.create_def(parent, name, def_kind).def_id();
// Create the definition. // Create the definition.
if expn_id != ExpnId::root() { if expn_id != ExpnId::root() {