about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/context.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-07-04 10:23:18 +0000
committerbors <bors@rust-lang.org>2025-07-04 10:23:18 +0000
commit556d20a834126d2d0ac20743b9792b8474d6d03c (patch)
tree5818857dedfe725669bafe6641266a9055877de4 /compiler/rustc_middle/src/ty/context.rs
parent1b61d43bdbf875183b1f436302d62ff93f9a6bba (diff)
parent992fa62118d61c0df27cc0f8d5e22cb7d5bc51c0 (diff)
downloadrust-556d20a834126d2d0ac20743b9792b8474d6d03c.tar.gz
rust-556d20a834126d2d0ac20743b9792b8474d6d03c.zip
Auto merge of #143247 - cjgillot:metadata-no-red, r=petrochenkov
Avoid depending on forever-red DepNode when encoding metadata.

Split from https://github.com/rust-lang/rust/pull/114669 for perf

r? `@petrochenkov`
Diffstat (limited to 'compiler/rustc_middle/src/ty/context.rs')
-rw-r--r--compiler/rustc_middle/src/ty/context.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index efa47b57cf3..8aa50d14faa 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -2058,9 +2058,8 @@ impl<'tcx> TyCtxt<'tcx> {
     }
 
     pub fn iter_local_def_id(self) -> impl Iterator<Item = LocalDefId> {
-        // Create a dependency to the red node to be sure we re-execute this when the amount of
-        // definitions change.
-        self.dep_graph.read_index(DepNodeIndex::FOREVER_RED_NODE);
+        // Depend on the `analysis` query to ensure compilation if finished.
+        self.ensure_ok().analysis(());
 
         let definitions = &self.untracked.definitions;
         gen {
@@ -2080,9 +2079,8 @@ impl<'tcx> TyCtxt<'tcx> {
     }
 
     pub fn def_path_table(self) -> &'tcx rustc_hir::definitions::DefPathTable {
-        // Create a dependency to the crate to be sure we re-execute this when the amount of
-        // definitions change.
-        self.dep_graph.read_index(DepNodeIndex::FOREVER_RED_NODE);
+        // Depend on the `analysis` query to ensure compilation if finished.
+        self.ensure_ok().analysis(());
 
         // Freeze definitions once we start iterating on them, to prevent adding new ones
         // while iterating. If some query needs to add definitions, it should be `ensure`d above.