@@ -102,7 +102,7 @@ pub fn poly_project_and_unify_type<'cx,'tcx>(
102102
103103/// Compute result of projecting an associated type and unify it with
104104/// `obligation.predicate.ty` (if we can).
105- pub fn project_and_unify_type < ' cx , ' tcx > (
105+ fn project_and_unify_type < ' cx , ' tcx > (
106106 selcx : & mut SelectionContext < ' cx , ' tcx > ,
107107 obligation : & ProjectionObligation < ' tcx > )
108108 -> Result < Option < Vec < PredicateObligation < ' tcx > > > , MismatchedProjectionTypes < ' tcx > >
@@ -135,9 +135,19 @@ pub fn normalize<'a,'b,'tcx,T>(selcx: &'a mut SelectionContext<'b,'tcx>,
135135 cause : ObligationCause < ' tcx > ,
136136 value : & T )
137137 -> Normalized < ' tcx , T >
138- where T : TypeFoldable < ' tcx > + HasProjectionTypes + Clone
138+ where T : TypeFoldable < ' tcx > + HasProjectionTypes + Clone + Repr < ' tcx >
139139{
140- let mut normalizer = AssociatedTypeNormalizer :: new ( selcx, cause, 0 ) ;
140+ normalize_with_depth ( selcx, cause, 0 , value)
141+ }
142+
143+ pub fn normalize_with_depth < ' a , ' b , ' tcx , T > ( selcx : & ' a mut SelectionContext < ' b , ' tcx > ,
144+ cause : ObligationCause < ' tcx > ,
145+ depth : uint ,
146+ value : & T )
147+ -> Normalized < ' tcx , T >
148+ where T : TypeFoldable < ' tcx > + HasProjectionTypes + Clone + Repr < ' tcx >
149+ {
150+ let mut normalizer = AssociatedTypeNormalizer :: new ( selcx, cause, depth) ;
141151 let result = normalizer. fold ( value) ;
142152 Normalized {
143153 value : result,
@@ -278,9 +288,10 @@ fn opt_normalize_projection_type<'a,'b,'tcx>(
278288 // an impl, where-clause etc) and hence we must
279289 // re-normalize it
280290
281- debug ! ( "normalize_projection_type: projected_ty={} depth={}" ,
291+ debug ! ( "normalize_projection_type: projected_ty={} depth={} obligations={} " ,
282292 projected_ty. repr( selcx. tcx( ) ) ,
283- depth) ;
293+ depth,
294+ obligations. repr( selcx. tcx( ) ) ) ;
284295
285296 if ty:: type_has_projection ( projected_ty) {
286297 let tcx = selcx. tcx ( ) ;
@@ -644,3 +655,20 @@ impl<'tcx> Repr<'tcx> for ProjectionTyCandidate<'tcx> {
644655 }
645656 }
646657}
658+
659+ impl < ' tcx , T : TypeFoldable < ' tcx > > TypeFoldable < ' tcx > for Normalized < ' tcx , T > {
660+ fn fold_with < F : TypeFolder < ' tcx > > ( & self , folder : & mut F ) -> Normalized < ' tcx , T > {
661+ Normalized {
662+ value : self . value . fold_with ( folder) ,
663+ obligations : self . obligations . fold_with ( folder) ,
664+ }
665+ }
666+ }
667+
668+ impl < ' tcx , T : Repr < ' tcx > > Repr < ' tcx > for Normalized < ' tcx , T > {
669+ fn repr ( & self , tcx : & ty:: ctxt < ' tcx > ) -> String {
670+ format ! ( "Normalized({},{})" ,
671+ self . value. repr( tcx) ,
672+ self . obligations. repr( tcx) )
673+ }
674+ }
0 commit comments