|
1 | | -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
2 | 1 | use rustc_serialize::Decoder; |
3 | 2 | use rustc_serialize::{Decodable, Encodable}; |
4 | 3 | use std::fmt; |
5 | 4 | use std::ops::ControlFlow; |
6 | 5 |
|
7 | 6 | use crate::fold::{FallibleTypeFolder, TypeFoldable}; |
8 | 7 | use crate::visit::{TypeVisitable, TypeVisitor}; |
9 | | -use crate::{HashStableContext, Interner}; |
| 8 | +use crate::Interner; |
10 | 9 | use crate::{TyDecoder, TyEncoder}; |
11 | 10 |
|
12 | 11 | /// A clause is something that can appear in where bounds or be inferred |
13 | 12 | /// by implied bounds. |
14 | 13 | #[derive(derivative::Derivative)] |
15 | 14 | #[derivative(Clone(bound = ""), Hash(bound = ""))] |
| 15 | +#[derive(HashStable_NoContext)] |
16 | 16 | pub enum ClauseKind<I: Interner> { |
17 | 17 | /// Corresponds to `where Foo: Bar<A, B, C>`. `Foo` here would be |
18 | 18 | /// the `Self` type of the trait reference and `A`, `B`, and `C` |
@@ -81,33 +81,6 @@ fn clause_kind_discriminant<I: Interner>(value: &ClauseKind<I>) -> usize { |
81 | 81 | } |
82 | 82 | } |
83 | 83 |
|
84 | | -impl<CTX: HashStableContext, I: Interner> HashStable<CTX> for ClauseKind<I> |
85 | | -where |
86 | | - I::Ty: HashStable<CTX>, |
87 | | - I::Const: HashStable<CTX>, |
88 | | - I::GenericArg: HashStable<CTX>, |
89 | | - I::TraitPredicate: HashStable<CTX>, |
90 | | - I::ProjectionPredicate: HashStable<CTX>, |
91 | | - I::TypeOutlivesPredicate: HashStable<CTX>, |
92 | | - I::RegionOutlivesPredicate: HashStable<CTX>, |
93 | | -{ |
94 | | - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { |
95 | | - clause_kind_discriminant(self).hash_stable(hcx, hasher); |
96 | | - match self { |
97 | | - ClauseKind::Trait(p) => p.hash_stable(hcx, hasher), |
98 | | - ClauseKind::RegionOutlives(p) => p.hash_stable(hcx, hasher), |
99 | | - ClauseKind::TypeOutlives(p) => p.hash_stable(hcx, hasher), |
100 | | - ClauseKind::Projection(p) => p.hash_stable(hcx, hasher), |
101 | | - ClauseKind::ConstArgHasType(c, t) => { |
102 | | - c.hash_stable(hcx, hasher); |
103 | | - t.hash_stable(hcx, hasher); |
104 | | - } |
105 | | - ClauseKind::WellFormed(t) => t.hash_stable(hcx, hasher), |
106 | | - ClauseKind::ConstEvaluatable(c) => c.hash_stable(hcx, hasher), |
107 | | - } |
108 | | - } |
109 | | -} |
110 | | - |
111 | 84 | impl<I: Interner> TypeFoldable<I> for ClauseKind<I> |
112 | 85 | where |
113 | 86 | I::Ty: TypeFoldable<I>, |
@@ -220,6 +193,7 @@ where |
220 | 193 |
|
221 | 194 | #[derive(derivative::Derivative)] |
222 | 195 | #[derivative(Clone(bound = ""), Hash(bound = ""))] |
| 196 | +#[derive(HashStable_NoContext)] |
223 | 197 | pub enum PredicateKind<I: Interner> { |
224 | 198 | /// Prove a clause |
225 | 199 | Clause(ClauseKind<I>), |
@@ -310,43 +284,6 @@ fn predicate_kind_discriminant<I: Interner>(value: &PredicateKind<I>) -> usize { |
310 | 284 | } |
311 | 285 | } |
312 | 286 |
|
313 | | -impl<CTX: HashStableContext, I: Interner> HashStable<CTX> for PredicateKind<I> |
314 | | -where |
315 | | - I::DefId: HashStable<CTX>, |
316 | | - I::Const: HashStable<CTX>, |
317 | | - I::GenericArgs: HashStable<CTX>, |
318 | | - I::Term: HashStable<CTX>, |
319 | | - I::CoercePredicate: HashStable<CTX>, |
320 | | - I::SubtypePredicate: HashStable<CTX>, |
321 | | - I::ClosureKind: HashStable<CTX>, |
322 | | - ClauseKind<I>: HashStable<CTX>, |
323 | | -{ |
324 | | - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { |
325 | | - predicate_kind_discriminant(self).hash_stable(hcx, hasher); |
326 | | - match self { |
327 | | - PredicateKind::Clause(p) => p.hash_stable(hcx, hasher), |
328 | | - PredicateKind::ObjectSafe(d) => d.hash_stable(hcx, hasher), |
329 | | - PredicateKind::ClosureKind(d, g, k) => { |
330 | | - d.hash_stable(hcx, hasher); |
331 | | - g.hash_stable(hcx, hasher); |
332 | | - k.hash_stable(hcx, hasher); |
333 | | - } |
334 | | - PredicateKind::Subtype(p) => p.hash_stable(hcx, hasher), |
335 | | - PredicateKind::Coerce(p) => p.hash_stable(hcx, hasher), |
336 | | - PredicateKind::ConstEquate(c1, c2) => { |
337 | | - c1.hash_stable(hcx, hasher); |
338 | | - c2.hash_stable(hcx, hasher); |
339 | | - } |
340 | | - PredicateKind::Ambiguous => {} |
341 | | - PredicateKind::AliasRelate(t1, t2, r) => { |
342 | | - t1.hash_stable(hcx, hasher); |
343 | | - t2.hash_stable(hcx, hasher); |
344 | | - r.hash_stable(hcx, hasher); |
345 | | - } |
346 | | - } |
347 | | - } |
348 | | -} |
349 | | - |
350 | 287 | impl<I: Interner> TypeFoldable<I> for PredicateKind<I> |
351 | 288 | where |
352 | 289 | I::DefId: TypeFoldable<I>, |
@@ -496,7 +433,7 @@ where |
496 | 433 | } |
497 | 434 |
|
498 | 435 | #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)] |
499 | | -#[derive(HashStable_Generic, Encodable, Decodable)] |
| 436 | +#[derive(HashStable_NoContext, Encodable, Decodable)] |
500 | 437 | pub enum AliasRelationDirection { |
501 | 438 | Equate, |
502 | 439 | Subtype, |
|
0 commit comments