|
1 | 1 | use std::assert_matches::assert_matches; |
| 2 | +use std::collections::hash_map::Entry; |
2 | 3 | use std::fmt::Debug; |
3 | 4 | use std::hash::Hash; |
4 | 5 | use std::marker::PhantomData; |
5 | 6 | use std::sync::Arc; |
6 | 7 | use std::sync::atomic::Ordering; |
7 | 8 |
|
8 | 9 | use rustc_data_structures::fingerprint::Fingerprint; |
9 | | -use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, IndexEntry}; |
| 10 | +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
10 | 11 | use rustc_data_structures::profiling::{QueryInvocationId, SelfProfilerRef}; |
11 | 12 | use rustc_data_structures::sharded::{self, Sharded}; |
12 | 13 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
@@ -1053,7 +1054,7 @@ rustc_index::newtype_index! { |
1053 | 1054 | /// first, and `data` second. |
1054 | 1055 | pub(super) struct CurrentDepGraph<D: Deps> { |
1055 | 1056 | encoder: GraphEncoder<D>, |
1056 | | - new_node_to_index: Sharded<FxIndexMap<DepNode, DepNodeIndex>>, |
| 1057 | + new_node_to_index: Sharded<FxHashMap<DepNode, DepNodeIndex>>, |
1057 | 1058 | prev_index_to_index: Lock<IndexVec<SerializedDepNodeIndex, Option<DepNodeIndex>>>, |
1058 | 1059 |
|
1059 | 1060 | /// 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> { |
1123 | 1124 | previous, |
1124 | 1125 | ), |
1125 | 1126 | new_node_to_index: Sharded::new(|| { |
1126 | | - FxIndexMap::with_capacity_and_hasher( |
| 1127 | + FxHashMap::with_capacity_and_hasher( |
1127 | 1128 | new_node_count_estimate / sharded::shards(), |
1128 | 1129 | Default::default(), |
1129 | 1130 | ) |
@@ -1158,8 +1159,8 @@ impl<D: Deps> CurrentDepGraph<D> { |
1158 | 1159 | current_fingerprint: Fingerprint, |
1159 | 1160 | ) -> DepNodeIndex { |
1160 | 1161 | 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) => { |
1163 | 1164 | let dep_node_index = self.encoder.send(key, current_fingerprint, edges); |
1164 | 1165 | entry.insert(dep_node_index); |
1165 | 1166 | dep_node_index |
@@ -1388,6 +1389,8 @@ fn panic_on_forbidden_read<D: Deps>(data: &DepGraphData<D>, dep_node_index: DepN |
1388 | 1389 | if dep_node.is_none() { |
1389 | 1390 | // Try to find it among the new nodes |
1390 | 1391 | 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)] |
1391 | 1394 | if let Some((node, _)) = shard.iter().find(|(_, index)| **index == dep_node_index) { |
1392 | 1395 | dep_node = Some(*node); |
1393 | 1396 | break; |
|
0 commit comments