@@ -102,7 +102,7 @@ pub fn poly_project_and_unify_type<'cx,'tcx>(
102
102
103
103
/// Compute result of projecting an associated type and unify it with
104
104
/// `obligation.predicate.ty` (if we can).
105
- pub fn project_and_unify_type < ' cx , ' tcx > (
105
+ fn project_and_unify_type < ' cx , ' tcx > (
106
106
selcx : & mut SelectionContext < ' cx , ' tcx > ,
107
107
obligation : & ProjectionObligation < ' tcx > )
108
108
-> Result < Option < Vec < PredicateObligation < ' tcx > > > , MismatchedProjectionTypes < ' tcx > >
@@ -135,9 +135,19 @@ pub fn normalize<'a,'b,'tcx,T>(selcx: &'a mut SelectionContext<'b,'tcx>,
135
135
cause : ObligationCause < ' tcx > ,
136
136
value : & T )
137
137
-> Normalized < ' tcx , T >
138
- where T : TypeFoldable < ' tcx > + HasProjectionTypes + Clone
138
+ where T : TypeFoldable < ' tcx > + HasProjectionTypes + Clone + Repr < ' tcx >
139
139
{
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) ;
141
151
let result = normalizer. fold ( value) ;
142
152
Normalized {
143
153
value : result,
@@ -278,9 +288,10 @@ fn opt_normalize_projection_type<'a,'b,'tcx>(
278
288
// an impl, where-clause etc) and hence we must
279
289
// re-normalize it
280
290
281
- debug ! ( "normalize_projection_type: projected_ty={} depth={}" ,
291
+ debug ! ( "normalize_projection_type: projected_ty={} depth={} obligations={} " ,
282
292
projected_ty. repr( selcx. tcx( ) ) ,
283
- depth) ;
293
+ depth,
294
+ obligations. repr( selcx. tcx( ) ) ) ;
284
295
285
296
if ty:: type_has_projection ( projected_ty) {
286
297
let tcx = selcx. tcx ( ) ;
@@ -644,3 +655,20 @@ impl<'tcx> Repr<'tcx> for ProjectionTyCandidate<'tcx> {
644
655
}
645
656
}
646
657
}
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