about summary refs log tree commit diff
path: root/src/librustc_data_structures/sharded.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-11-15 09:37:24 +0000
committerbors <bors@rust-lang.org>2019-11-15 09:37:24 +0000
commitce36ab2b064c2aa716084d79717c64cc04bb6532 (patch)
tree77f5ba79a6eda736ab42329b9294a8e4c91fe259 /src/librustc_data_structures/sharded.rs
parent9e8c4e6fb1c952048fb823e59f4c9c6487bf9a58 (diff)
parenta173353daa657d90fff06e6223f48ee383bf9d13 (diff)
Auto merge of #66438 - JohnTitor:rollup-qpv3wia, r=JohnTitor
Rollup of 12 pull requests

Successful merges:

 - #65557 (rename Error::iter_chain() and remove Error::iter_sources())
 - #66013 (Avoid hashing the key twice in `get_query()`.)
 - #66306 (Remove cannot mutate statics in initializer of another static error)
 - #66338 (Update mdbook.)
 - #66388 (Do not ICE on recovery from unmet associated type bound obligation)
 - #66390 (Fix ICE when trying to suggest `Type<>` instead of `Type()`)
 - #66391 (Do not ICE in `if` without `else` in `async fn`)
 - #66398 (Remove some stack frames from `.async` calls)
 - #66410 (miri: helper methods for max values of machine's usize/isize)
 - #66418 (Link to tracking issue in HIR const-check error code description)
 - #66419 (Don't warn labels beginning with `_` on unused_labels lint)
 - #66428 (Cleanup unused function)

Failed merges:

r? @ghost
Diffstat (limited to 'src/librustc_data_structures/sharded.rs')
-rw-r--r--src/librustc_data_structures/sharded.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/librustc_data_structures/sharded.rs b/src/librustc_data_structures/sharded.rs
index 2f972eeccdc..a28a5e0f041 100644
--- a/src/librustc_data_structures/sharded.rs
+++ b/src/librustc_data_structures/sharded.rs
@@ -60,6 +60,7 @@ impl<T> Sharded<T> {
         }
     }
 
+    /// The shard is selected by hashing `val` with `FxHasher`.
     #[inline]
     pub fn get_shard_by_value<K: Hash + ?Sized>(&self, val: &K) -> &Lock<T> {
         if SHARDS == 1 {
@@ -69,6 +70,11 @@ impl<T> Sharded<T> {
         }
     }
 
+    /// Get a shard with a pre-computed hash value. If `get_shard_by_value` is
+    /// ever used in combination with `get_shard_by_hash` on a single `Sharded`
+    /// instance, then `hash` must be computed with `FxHasher`. Otherwise,
+    /// `hash` can be computed with any hasher, so long as that hasher is used
+    /// consistently for each `Sharded` instance.
     #[inline]
     pub fn get_shard_by_hash(&self, hash: u64) -> &Lock<T> {
         let hash_len = mem::size_of::<usize>();