@@ -44,6 +44,15 @@ pub struct Canonical<'tcx, V> {
4444
4545pub type CanonicalVarInfos < ' tcx > = & ' tcx List < CanonicalVarInfo < ' tcx > > ;
4646
47+ impl < ' tcx > ty:: TypeFoldable < ' tcx > for CanonicalVarInfos < ' tcx > {
48+ fn try_fold_with < F : ty:: FallibleTypeFolder < ' tcx > > (
49+ self ,
50+ folder : & mut F ,
51+ ) -> Result < Self , F :: Error > {
52+ ty:: util:: fold_list ( self , folder, |tcx, v| tcx. intern_canonical_var_infos ( v) )
53+ }
54+ }
55+
4756/// A set of values corresponding to the canonical variables from some
4857/// `Canonical`. You can give these values to
4958/// `canonical_value.substitute` to substitute them into the canonical
@@ -90,6 +99,7 @@ impl<'tcx> Default for OriginalQueryValues<'tcx> {
9099/// a copy of the canonical value in some other inference context,
91100/// with fresh inference variables replacing the canonical values.
92101#[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , TyDecodable , TyEncodable , HashStable ) ]
102+ #[ derive( TypeFoldable , TypeVisitable ) ]
93103pub struct CanonicalVarInfo < ' tcx > {
94104 pub kind : CanonicalVarKind < ' tcx > ,
95105}
@@ -115,6 +125,7 @@ impl<'tcx> CanonicalVarInfo<'tcx> {
115125/// in the type-theory sense of the term -- i.e., a "meta" type system
116126/// that analyzes type-like values.
117127#[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , TyDecodable , TyEncodable , HashStable ) ]
128+ #[ derive( TypeFoldable , TypeVisitable ) ]
118129pub enum CanonicalVarKind < ' tcx > {
119130 /// Some kind of type inference variable.
120131 Ty ( CanonicalTyVarKind ) ,
@@ -299,14 +310,7 @@ pub type QueryOutlivesConstraint<'tcx> = (
299310TrivialTypeTraversalAndLiftImpls ! {
300311 for <' tcx> {
301312 crate :: infer:: canonical:: Certainty ,
302- crate :: infer:: canonical:: CanonicalVarInfo <' tcx>,
303- crate :: infer:: canonical:: CanonicalVarKind <' tcx>,
304- }
305- }
306-
307- TrivialTypeTraversalImpls ! {
308- for <' tcx> {
309- crate :: infer:: canonical:: CanonicalVarInfos <' tcx>,
313+ crate :: infer:: canonical:: CanonicalTyVarKind ,
310314 }
311315}
312316
0 commit comments