@@ -29,7 +29,7 @@ use rustc_index::vec::IndexVec;
2929use rustc_macros:: HashStable ;
3030use smallvec:: SmallVec ;
3131use std:: iter;
32- use std:: ops:: Index ;
32+ use std:: ops:: { ControlFlow , Index } ;
3333
3434/// A "canonicalized" type `V` is one where all free inference
3535/// variables have been rewritten to "canonical vars". These are
@@ -44,6 +44,21 @@ 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+
56+ impl < ' tcx > ty:: TypeVisitable < ' tcx > for CanonicalVarInfos < ' tcx > {
57+ fn visit_with < V : ty:: TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> ControlFlow < V :: BreakTy > {
58+ self . iter ( ) . try_for_each ( |t| t. visit_with ( visitor) )
59+ }
60+ }
61+
4762/// A set of values corresponding to the canonical variables from some
4863/// `Canonical`. You can give these values to
4964/// `canonical_value.substitute` to substitute them into the canonical
@@ -305,12 +320,6 @@ TrivialTypeTraversalAndLiftImpls! {
305320 }
306321}
307322
308- TrivialTypeTraversalImpls ! {
309- for <' tcx> {
310- crate :: infer:: canonical:: CanonicalVarInfos <' tcx>,
311- }
312- }
313-
314323impl < ' tcx > CanonicalVarValues < ' tcx > {
315324 #[ inline]
316325 pub fn len ( & self ) -> usize {
0 commit comments