From 5efff3393b48253801945cf2d6cb25e1af71a1ef Mon Sep 17 00:00:00 2001 From: ismailarilik Date: Mon, 5 May 2025 19:06:15 +0300 Subject: [PATCH] Handle `rustc_query_system` cases of `rustc::potential_query_instability` lint --- compiler/rustc_query_system/src/dep_graph/graph.rs | 2 ++ compiler/rustc_query_system/src/dep_graph/serialized.rs | 2 ++ compiler/rustc_query_system/src/lib.rs | 2 +- compiler/rustc_query_system/src/query/job.rs | 4 ++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs index 3ae56cef2c421..d4217e0aa5499 100644 --- a/compiler/rustc_query_system/src/dep_graph/graph.rs +++ b/compiler/rustc_query_system/src/dep_graph/graph.rs @@ -1433,6 +1433,8 @@ fn panic_on_forbidden_read(data: &DepGraphData, dep_node_index: DepN && let Some(nodes) = &data.current.nodes_in_current_session { // Try to find it among the nodes allocated so far in this session + // This is OK, there's only ever one node result possible so this is deterministic. + #[allow(rustc::potential_query_instability)] if let Some((node, _)) = nodes.lock().iter().find(|&(_, index)| *index == dep_node_index) { dep_node = Some(*node); } diff --git a/compiler/rustc_query_system/src/dep_graph/serialized.rs b/compiler/rustc_query_system/src/dep_graph/serialized.rs index f1b609a3ca906..79b99c52d0c01 100644 --- a/compiler/rustc_query_system/src/dep_graph/serialized.rs +++ b/compiler/rustc_query_system/src/dep_graph/serialized.rs @@ -784,6 +784,8 @@ impl EncoderState { ) { if let Some(record_stats) = &self.stats { let record_stats = record_stats.lock(); + // `stats` is sorted below so we can allow this lint here. + #[allow(rustc::potential_query_instability)] let mut stats: Vec<_> = record_stats.values().collect(); stats.sort_by_key(|s| -(s.node_counter as i64)); diff --git a/compiler/rustc_query_system/src/lib.rs b/compiler/rustc_query_system/src/lib.rs index b159b876c7e63..d55b07b898d2f 100644 --- a/compiler/rustc_query_system/src/lib.rs +++ b/compiler/rustc_query_system/src/lib.rs @@ -1,5 +1,5 @@ // tidy-alphabetical-start -#![allow(rustc::potential_query_instability, internal_features)] +#![allow(internal_features)] #![cfg_attr(bootstrap, feature(let_chains))] #![feature(assert_matches)] #![feature(core_intrinsics)] diff --git a/compiler/rustc_query_system/src/query/job.rs b/compiler/rustc_query_system/src/query/job.rs index 6321abc5087f5..1e79bd461d2a4 100644 --- a/compiler/rustc_query_system/src/query/job.rs +++ b/compiler/rustc_query_system/src/query/job.rs @@ -510,6 +510,10 @@ pub fn break_query_cycles( registry: &rayon_core::Registry, ) { let mut wakelist = Vec::new(); + // It is OK per the comments: + // - https://github.com/rust-lang/rust/pull/131200#issuecomment-2798854932 + // - https://github.com/rust-lang/rust/pull/131200#issuecomment-2798866392 + #[allow(rustc::potential_query_instability)] let mut jobs: Vec = query_map.keys().cloned().collect(); let mut found_cycle = false;