1
1
use std:: fmt;
2
- use std:: hash;
2
+ use std:: hash:: Hash ;
3
3
use std:: ops:: ControlFlow ;
4
4
5
5
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
@@ -13,6 +13,13 @@ use crate::{HashStableContext, Interner, TyEncoder, UniverseIndex};
13
13
/// A "canonicalized" type `V` is one where all free inference
14
14
/// variables have been rewritten to "canonical vars". These are
15
15
/// numbered starting from 0 in order of first appearance.
16
+ #[ derive( derivative:: Derivative ) ]
17
+ #[ derivative(
18
+ Clone ( bound = "V: Clone" ) ,
19
+ PartialEq ( bound = "V: PartialEq" ) ,
20
+ Eq ( bound = "V: Eq" ) ,
21
+ Hash ( bound = "V: Hash" )
22
+ ) ]
16
23
pub struct Canonical < I : Interner , V > {
17
24
pub value : V ,
18
25
pub max_universe : UniverseIndex ,
@@ -59,14 +66,6 @@ impl<I: Interner, V> Canonical<I, V> {
59
66
}
60
67
}
61
68
62
- impl < I : Interner , V : hash:: Hash > hash:: Hash for Canonical < I , V > {
63
- fn hash < H : hash:: Hasher > ( & self , state : & mut H ) {
64
- self . value . hash ( state) ;
65
- self . max_universe . hash ( state) ;
66
- self . variables . hash ( state) ;
67
- }
68
- }
69
-
70
69
impl < CTX : HashStableContext , I : Interner , V : HashStable < CTX > > HashStable < CTX > for Canonical < I , V >
71
70
where
72
71
I :: CanonicalVars : HashStable < CTX > ,
78
77
}
79
78
}
80
79
81
- impl < I : Interner , V : Eq > Eq for Canonical < I , V > { }
82
-
83
- impl < I : Interner , V : PartialEq > PartialEq for Canonical < I , V > {
84
- fn eq ( & self , other : & Self ) -> bool {
85
- self . value == other. value
86
- && self . max_universe == other. max_universe
87
- && self . variables == other. variables
88
- }
89
- }
90
-
91
80
impl < I : Interner , V : fmt:: Display > fmt:: Display for Canonical < I , V > {
92
81
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
93
82
write ! (
@@ -108,16 +97,6 @@ impl<I: Interner, V: fmt::Debug> fmt::Debug for Canonical<I, V> {
108
97
}
109
98
}
110
99
111
- impl < I : Interner , V : Clone > Clone for Canonical < I , V > {
112
- fn clone ( & self ) -> Self {
113
- Canonical {
114
- value : self . value . clone ( ) ,
115
- max_universe : self . max_universe . clone ( ) ,
116
- variables : self . variables . clone ( ) ,
117
- }
118
- }
119
- }
120
-
121
100
impl < I : Interner , V : Copy > Copy for Canonical < I , V > where I :: CanonicalVars : Copy { }
122
101
123
102
impl < I : Interner , V : TypeFoldable < I > > TypeFoldable < I > for Canonical < I , V >
0 commit comments