Handle rustc_query_system cases of rustc::potential_query_instability lint by ismailarilik · Pull Request #131200 · rust-lang/rust (original) (raw)

Current state (I think largely matching what was reported before):

warning: using `iter` can result in unstable query results
    --> compiler/rustc_query_system/src/dep_graph/graph.rs:1432:47
     |
1432 |         if let Some((node, _)) = nodes.lock().iter().find(|&(_, index)| *index == dep_node_index) {
     |                                               ^^^^

Per #131200 (comment) this is OK, there's only ever one node result possible so this is deterministic. This is in code that's going to panic immediately afterwards anyway so it doesn't really matter what we do here.

warning: using `values` can result in unstable query results
   --> compiler/rustc_query_system/src/dep_graph/serialized.rs:665:50
    |
665 |             let mut stats: Vec<_> = record_stats.values().collect();
    |                                                  ^^^^^^

This is just stat-dumping code that can't have any effect on query stability. So also fine.

warning: using `keys` can result in unstable query results
   --> compiler/rustc_query_system/src/query/job.rs:512:47
    |
512 |     let mut jobs: Vec<QueryJobId> = query_map.keys().cloned().collect();
    |                                               ^^^^

This I'm less sure about -- @Zoxc is maybe most familiar with our cycle-breaking code, I seem to recall some recent work on that for parallel compilation as well?

I think the next step here is to either open a new PR or rebase this one, but not doing any structure modifications, just allowing the lints for all three cases with a FIXME comment on the 3rd one unless we hear otherwise from someone with more knowledge.