about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-06-01 09:22:01 +0000
committerbors <bors@rust-lang.org>2021-06-01 09:22:01 +0000
commit1160cf864f2a0014e3442367e1b96496bfbeadf4 (patch)
treee9fa8da926fdf33f4b0cd68b5267bf8c27ce8a01 /compiler/rustc_data_structures/src
parent80af6b091f6a4855be71bba1cd0c1ee9fd2a57a8 (diff)
parent0f0f3138cb80137b9277b29118c05dbff9a8915e (diff)
downloadrust-1160cf864f2a0014e3442367e1b96496bfbeadf4.tar.gz
rust-1160cf864f2a0014e3442367e1b96496bfbeadf4.zip
Auto merge of #85884 - rust-lang:revert-85153-qresolve, r=michaelwoerister
Revert "Reduce the amount of untracked state in TyCtxt"

Reverts rust-lang/rust#85153
Fixes https://github.com/rust-lang/rust/issues/85878

The performance hit is massive, and was not visible in the in-review perf run.

r? `@Aaron1011`
Diffstat (limited to 'compiler/rustc_data_structures/src')
-rw-r--r--compiler/rustc_data_structures/src/stable_hasher.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/compiler/rustc_data_structures/src/stable_hasher.rs b/compiler/rustc_data_structures/src/stable_hasher.rs
index 18b352cf3b0..ff28784a1dc 100644
--- a/compiler/rustc_data_structures/src/stable_hasher.rs
+++ b/compiler/rustc_data_structures/src/stable_hasher.rs
@@ -550,3 +550,35 @@ pub fn hash_stable_hashmap<HCX, K, V, R, SK, F>(
     entries.sort_unstable_by(|&(ref sk1, _), &(ref sk2, _)| sk1.cmp(sk2));
     entries.hash_stable(hcx, hasher);
 }
+
+/// A vector container that makes sure that its items are hashed in a stable
+/// order.
+#[derive(Debug)]
+pub struct StableVec<T>(Vec<T>);
+
+impl<T> StableVec<T> {
+    pub fn new(v: Vec<T>) -> Self {
+        StableVec(v)
+    }
+}
+
+impl<T> ::std::ops::Deref for StableVec<T> {
+    type Target = Vec<T>;
+
+    fn deref(&self) -> &Vec<T> {
+        &self.0
+    }
+}
+
+impl<T, HCX> HashStable<HCX> for StableVec<T>
+where
+    T: HashStable<HCX> + ToStableHashKey<HCX>,
+{
+    fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) {
+        let StableVec(ref v) = *self;
+
+        let mut sorted: Vec<_> = v.iter().map(|x| x.to_stable_hash_key(hcx)).collect();
+        sorted.sort_unstable();
+        sorted.hash_stable(hcx, hasher);
+    }
+}