Skip to content

Commit 870d7c2

Browse files
committed
Allow lint for a reasonable iteration
1 parent f34e703 commit 870d7c2

File tree

1 file changed

+8
-5
lines changed
  • compiler/rustc_query_system/src/dep_graph

1 file changed

+8
-5
lines changed

compiler/rustc_query_system/src/dep_graph/graph.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use std::assert_matches::assert_matches;
2+
use std::collections::hash_map::Entry;
23
use std::fmt::Debug;
34
use std::hash::Hash;
45
use std::marker::PhantomData;
56
use std::sync::Arc;
67
use std::sync::atomic::Ordering;
78

89
use rustc_data_structures::fingerprint::Fingerprint;
9-
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, IndexEntry};
10+
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1011
use rustc_data_structures::profiling::{QueryInvocationId, SelfProfilerRef};
1112
use rustc_data_structures::sharded::{self, Sharded};
1213
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
@@ -1053,7 +1054,7 @@ rustc_index::newtype_index! {
10531054
/// first, and `data` second.
10541055
pub(super) struct CurrentDepGraph<D: Deps> {
10551056
encoder: GraphEncoder<D>,
1056-
new_node_to_index: Sharded<FxIndexMap<DepNode, DepNodeIndex>>,
1057+
new_node_to_index: Sharded<FxHashMap<DepNode, DepNodeIndex>>,
10571058
prev_index_to_index: Lock<IndexVec<SerializedDepNodeIndex, Option<DepNodeIndex>>>,
10581059

10591060
/// This is used to verify that fingerprints do not change between the creation of a node
@@ -1123,7 +1124,7 @@ impl<D: Deps> CurrentDepGraph<D> {
11231124
previous,
11241125
),
11251126
new_node_to_index: Sharded::new(|| {
1126-
FxIndexMap::with_capacity_and_hasher(
1127+
FxHashMap::with_capacity_and_hasher(
11271128
new_node_count_estimate / sharded::shards(),
11281129
Default::default(),
11291130
)
@@ -1158,8 +1159,8 @@ impl<D: Deps> CurrentDepGraph<D> {
11581159
current_fingerprint: Fingerprint,
11591160
) -> DepNodeIndex {
11601161
let dep_node_index = match self.new_node_to_index.lock_shard_by_value(&key).entry(key) {
1161-
IndexEntry::Occupied(entry) => *entry.get(),
1162-
IndexEntry::Vacant(entry) => {
1162+
Entry::Occupied(entry) => *entry.get(),
1163+
Entry::Vacant(entry) => {
11631164
let dep_node_index = self.encoder.send(key, current_fingerprint, edges);
11641165
entry.insert(dep_node_index);
11651166
dep_node_index
@@ -1388,6 +1389,8 @@ fn panic_on_forbidden_read<D: Deps>(data: &DepGraphData<D>, dep_node_index: DepN
13881389
if dep_node.is_none() {
13891390
// Try to find it among the new nodes
13901391
for shard in data.current.new_node_to_index.lock_shards() {
1392+
// This is OK, as there can be at most one `dep_node` with the given `dep_node_index`
1393+
#[allow(rustc::potential_query_instability)]
13911394
if let Some((node, _)) = shard.iter().find(|(_, index)| **index == dep_node_index) {
13921395
dep_node = Some(*node);
13931396
break;

0 commit comments

Comments
 (0)