|
1 | | -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
2 | 1 | use std::fmt; |
3 | 2 | use std::ops::ControlFlow; |
4 | 3 |
|
5 | 4 | use crate::fold::{FallibleTypeFolder, TypeFoldable}; |
6 | 5 | use crate::visit::{TypeVisitable, TypeVisitor}; |
7 | | -use crate::{HashStableContext, Interner}; |
| 6 | +use crate::Interner; |
8 | 7 |
|
9 | 8 | /// A clause is something that can appear in where bounds or be inferred |
10 | 9 | /// by implied bounds. |
11 | 10 | #[derive(derivative::Derivative)] |
12 | 11 | #[derivative(Clone(bound = ""), Hash(bound = ""))] |
13 | | -#[derive(TyEncodable, TyDecodable)] |
| 12 | +#[derive(TyEncodable, TyDecodable, HashStable_NoContext)] |
14 | 13 | pub enum ClauseKind<I: Interner> { |
15 | 14 | /// Corresponds to `where Foo: Bar<A, B, C>`. `Foo` here would be |
16 | 15 | /// the `Self` type of the trait reference and `A`, `B`, and `C` |
@@ -67,45 +66,6 @@ impl<I: Interner> PartialEq for ClauseKind<I> { |
67 | 66 |
|
68 | 67 | impl<I: Interner> Eq for ClauseKind<I> {} |
69 | 68 |
|
70 | | -fn clause_kind_discriminant<I: Interner>(value: &ClauseKind<I>) -> usize { |
71 | | - match value { |
72 | | - ClauseKind::Trait(_) => 0, |
73 | | - ClauseKind::RegionOutlives(_) => 1, |
74 | | - ClauseKind::TypeOutlives(_) => 2, |
75 | | - ClauseKind::Projection(_) => 3, |
76 | | - ClauseKind::ConstArgHasType(_, _) => 4, |
77 | | - ClauseKind::WellFormed(_) => 5, |
78 | | - ClauseKind::ConstEvaluatable(_) => 6, |
79 | | - } |
80 | | -} |
81 | | - |
82 | | -impl<CTX: HashStableContext, I: Interner> HashStable<CTX> for ClauseKind<I> |
83 | | -where |
84 | | - I::Ty: HashStable<CTX>, |
85 | | - I::Const: HashStable<CTX>, |
86 | | - I::GenericArg: HashStable<CTX>, |
87 | | - I::TraitPredicate: HashStable<CTX>, |
88 | | - I::ProjectionPredicate: HashStable<CTX>, |
89 | | - I::TypeOutlivesPredicate: HashStable<CTX>, |
90 | | - I::RegionOutlivesPredicate: HashStable<CTX>, |
91 | | -{ |
92 | | - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { |
93 | | - clause_kind_discriminant(self).hash_stable(hcx, hasher); |
94 | | - match self { |
95 | | - ClauseKind::Trait(p) => p.hash_stable(hcx, hasher), |
96 | | - ClauseKind::RegionOutlives(p) => p.hash_stable(hcx, hasher), |
97 | | - ClauseKind::TypeOutlives(p) => p.hash_stable(hcx, hasher), |
98 | | - ClauseKind::Projection(p) => p.hash_stable(hcx, hasher), |
99 | | - ClauseKind::ConstArgHasType(c, t) => { |
100 | | - c.hash_stable(hcx, hasher); |
101 | | - t.hash_stable(hcx, hasher); |
102 | | - } |
103 | | - ClauseKind::WellFormed(t) => t.hash_stable(hcx, hasher), |
104 | | - ClauseKind::ConstEvaluatable(c) => c.hash_stable(hcx, hasher), |
105 | | - } |
106 | | - } |
107 | | -} |
108 | | - |
109 | 69 | impl<I: Interner> TypeFoldable<I> for ClauseKind<I> |
110 | 70 | where |
111 | 71 | I::Ty: TypeFoldable<I>, |
@@ -161,7 +121,7 @@ where |
161 | 121 |
|
162 | 122 | #[derive(derivative::Derivative)] |
163 | 123 | #[derivative(Clone(bound = ""), Hash(bound = ""))] |
164 | | -#[derive(TyEncodable, TyDecodable)] |
| 124 | +#[derive(TyEncodable, TyDecodable, HashStable_NoContext)] |
165 | 125 | pub enum PredicateKind<I: Interner> { |
166 | 126 | /// Prove a clause |
167 | 127 | Clause(ClauseKind<I>), |
@@ -239,56 +199,6 @@ impl<I: Interner> PartialEq for PredicateKind<I> { |
239 | 199 |
|
240 | 200 | impl<I: Interner> Eq for PredicateKind<I> {} |
241 | 201 |
|
242 | | -fn predicate_kind_discriminant<I: Interner>(value: &PredicateKind<I>) -> usize { |
243 | | - match value { |
244 | | - PredicateKind::Clause(_) => 0, |
245 | | - PredicateKind::ObjectSafe(_) => 1, |
246 | | - PredicateKind::ClosureKind(_, _, _) => 2, |
247 | | - PredicateKind::Subtype(_) => 3, |
248 | | - PredicateKind::Coerce(_) => 4, |
249 | | - PredicateKind::ConstEquate(_, _) => 5, |
250 | | - PredicateKind::Ambiguous => 6, |
251 | | - PredicateKind::AliasRelate(_, _, _) => 7, |
252 | | - } |
253 | | -} |
254 | | - |
255 | | -impl<CTX: HashStableContext, I: Interner> HashStable<CTX> for PredicateKind<I> |
256 | | -where |
257 | | - I::DefId: HashStable<CTX>, |
258 | | - I::Const: HashStable<CTX>, |
259 | | - I::GenericArgs: HashStable<CTX>, |
260 | | - I::Term: HashStable<CTX>, |
261 | | - I::CoercePredicate: HashStable<CTX>, |
262 | | - I::SubtypePredicate: HashStable<CTX>, |
263 | | - I::ClosureKind: HashStable<CTX>, |
264 | | - ClauseKind<I>: HashStable<CTX>, |
265 | | -{ |
266 | | - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { |
267 | | - predicate_kind_discriminant(self).hash_stable(hcx, hasher); |
268 | | - match self { |
269 | | - PredicateKind::Clause(p) => p.hash_stable(hcx, hasher), |
270 | | - PredicateKind::ObjectSafe(d) => d.hash_stable(hcx, hasher), |
271 | | - PredicateKind::ClosureKind(d, g, k) => { |
272 | | - d.hash_stable(hcx, hasher); |
273 | | - g.hash_stable(hcx, hasher); |
274 | | - k.hash_stable(hcx, hasher); |
275 | | - } |
276 | | - PredicateKind::Subtype(p) => p.hash_stable(hcx, hasher), |
277 | | - PredicateKind::Coerce(p) => p.hash_stable(hcx, hasher), |
278 | | - PredicateKind::ConstEquate(c1, c2) => { |
279 | | - c1.hash_stable(hcx, hasher); |
280 | | - c2.hash_stable(hcx, hasher); |
281 | | - } |
282 | | - PredicateKind::Ambiguous => {} |
283 | | - PredicateKind::AliasRelate(t1, t2, r) => { |
284 | | - t1.hash_stable(hcx, hasher); |
285 | | - t2.hash_stable(hcx, hasher); |
286 | | - r.hash_stable(hcx, hasher); |
287 | | - } |
288 | | - } |
289 | | - } |
290 | | -} |
291 | | - |
292 | 202 | impl<I: Interner> TypeFoldable<I> for PredicateKind<I> |
293 | 203 | where |
294 | 204 | I::DefId: TypeFoldable<I>, |
@@ -361,7 +271,7 @@ where |
361 | 271 | } |
362 | 272 |
|
363 | 273 | #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)] |
364 | | -#[derive(HashStable_Generic, Encodable, Decodable)] |
| 274 | +#[derive(HashStable_NoContext, Encodable, Decodable)] |
365 | 275 | pub enum AliasRelationDirection { |
366 | 276 | Equate, |
367 | 277 | Subtype, |
|
0 commit comments