You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Audit and handle remaining cases of rustc::potential_query_instability lint (iterating HashMaps) #84447
The iteration order of a HashMap depends on the Hash value of the keys. In rustc, the Hash value of a key can change between compilation sessions, even if the HashStable value remains the same (e.g. DefId, Symbol, etc.). This means that iterating over a HashMap can cause a query to produce different results given the same (as determined by HashStable) input. This can be quite subtle, as demonstrated by #82272 (comment)
To eliminate this source of issues, we should make an internal rustc-only lint for iterating over a HashMap in any way. This will need to cover explicit method calls (e.g. .keys() and .values()), as well as any usage of the IntoIterator impl for HashMap.
Note that we don't want to ban the usage of HashMaps with unstable keys - as long as they're only used for lookup (and not iteration), it's much more efficient than repeatedly converting to the stable form of a key (e.g. DefId -> DefPathHash or Symbol -> String).
The lint exists since #89558, and has allowed on all compiler crates as rustc::potential_query_instability.
We now need to stop allowing it in the compiler.
Steps, for each crate except rustc_data_structures:
remove the allow(rustc::potential_query_instability) in lib.rs;
replace the FxHash{Map,Set} by FxIndex{Map,Set} where necessary.
Please reach out on zulip if there are any questions.
Poking this since it still unresolved. What work still needs be done to finish this? @ismailarilik@Aaron1011?
Reading through this issue, and the PR's / merges above, and probing around with grep, my current understanding is that there are still some areas with #[allow(...)], without justifying comments.
Specifically, these are the files with local allows missing justifying comments
Activity
bjorn3 commentedon Apr 23, 2021
#64131 added the
StableMapwrapper forFxHashMapthat doesn't expose the iteration order.jyn514 commentedon Apr 23, 2021
@bjorn3 see #84446
cjgillot commentedon Jul 5, 2022
The lint exists since #89558, and has allowed on all compiler crates as
rustc::potential_query_instability.We now need to stop allowing it in the compiler.
Steps, for each crate except
rustc_data_structures:allow(rustc::potential_query_instability)inlib.rs;FxHash{Map,Set}byFxIndex{Map,Set}where necessary.Please reach out on zulip if there are any questions.
fee1-dead commentedon Jul 7, 2022
@rustbot claim@rustbot release-assignment
NiklasJonsson commentedon Jul 8, 2022
It seems like no one is assigned to this and I'd like to give it a try so assigning myself.
@rustbot claim
126 remaining items
Caylub commentedon Jan 24, 2026
Poking this since it still unresolved. What work still needs be done to finish this? @ismailarilik @Aaron1011?
Reading through this issue, and the PR's / merges above, and probing around with grep, my current understanding is that there are still some areas with
#[allow(...)], without justifying comments.Specifically, these are the files with local allows missing justifying comments
[Updated, the list above, assuming github links to comments count as valid justifications]
Is adding justifying comments (or converting to
FxIndexMapwhere necessary) all that remains for this to be resolved?Auto merge of #125928 - michaelwoerister:fix-cgu-hashstable, r=oli-obk
Add rationale for intentional potential_query_instability allows
Rollup merge of rust-lang#153479 - xfq:issue-84447-20260306, r=davidtwco
Rollup merge of rust-lang#153479 - xfq:issue-84447-20260306, r=davidtwco
Rollup merge of rust-lang#153479 - xfq:issue-84447-20260306, r=davidtwco
Unrolled build for #153479
Rollup merge of #153479 - xfq:issue-84447-20260306, r=davidtwco
Rollup merge of #153479 - xfq:issue-84447-20260306, r=davidtwco
Rollup merge of #153479 - xfq:issue-84447-20260306, r=davidtwco
Rollup merge of #153479 - xfq:issue-84447-20260306, r=davidtwco
ismailarilik commentedon May 23, 2026
@rustbot release-assignment
JinRudy commentedon Jun 3, 2026
@rustbot claim