@@ -50,14 +50,18 @@ pub type ProjectionTyObligation<'tcx> = Obligation<'tcx, ty::ProjectionTy<'tcx>>
5050pub ( super ) struct InProgress ;
5151
5252pub trait NormalizeExt < ' tcx > {
53+ /// Normalize a value using the `AssocTypeNormalizer`.
54+ ///
55+ /// This normalization should be used when the type contains inference variables or the
56+ /// projection may be fallible.
5357 fn normalize < T : TypeFoldable < ' tcx > > ( & self , t : T ) -> InferOk < ' tcx , T > ;
5458}
5559
5660impl < ' tcx > NormalizeExt < ' tcx > for At < ' _ , ' tcx > {
5761 fn normalize < T : TypeFoldable < ' tcx > > ( & self , value : T ) -> InferOk < ' tcx , T > {
5862 let mut selcx = SelectionContext :: new ( self . infcx ) ;
5963 let Normalized { value, obligations } =
60- normalize ( & mut selcx, self . param_env , self . cause . clone ( ) , value) ;
64+ normalize_with_depth ( & mut selcx, self . param_env , self . cause . clone ( ) , 0 , value) ;
6165 InferOk { value, obligations }
6266 }
6367}
@@ -303,37 +307,6 @@ fn project_and_unify_type<'cx, 'tcx>(
303307 }
304308}
305309
306- /// Normalizes any associated type projections in `value`, replacing
307- /// them with a fully resolved type where possible. The return value
308- /// combines the normalized result and any additional obligations that
309- /// were incurred as result.
310- pub ( crate ) fn normalize < ' a , ' b , ' tcx , T > (
311- selcx : & ' a mut SelectionContext < ' b , ' tcx > ,
312- param_env : ty:: ParamEnv < ' tcx > ,
313- cause : ObligationCause < ' tcx > ,
314- value : T ,
315- ) -> Normalized < ' tcx , T >
316- where
317- T : TypeFoldable < ' tcx > ,
318- {
319- let mut obligations = Vec :: new ( ) ;
320- let value = normalize_to ( selcx, param_env, cause, value, & mut obligations) ;
321- Normalized { value, obligations }
322- }
323-
324- pub ( crate ) fn normalize_to < ' a , ' b , ' tcx , T > (
325- selcx : & ' a mut SelectionContext < ' b , ' tcx > ,
326- param_env : ty:: ParamEnv < ' tcx > ,
327- cause : ObligationCause < ' tcx > ,
328- value : T ,
329- obligations : & mut Vec < PredicateObligation < ' tcx > > ,
330- ) -> T
331- where
332- T : TypeFoldable < ' tcx > ,
333- {
334- normalize_with_depth_to ( selcx, param_env, cause, 0 , value, obligations)
335- }
336-
337310/// As `normalize`, but with a custom depth.
338311pub ( crate ) fn normalize_with_depth < ' a , ' b , ' tcx , T > (
339312 selcx : & ' a mut SelectionContext < ' b , ' tcx > ,
@@ -2324,10 +2297,11 @@ fn confirm_impl_trait_in_trait_candidate<'tcx>(
23242297 } ,
23252298 ) ) ;
23262299
2327- let ty = super :: normalize_to (
2300+ let ty = normalize_with_depth_to (
23282301 selcx,
23292302 obligation. param_env ,
23302303 cause. clone ( ) ,
2304+ obligation. recursion_depth + 1 ,
23312305 tcx. bound_trait_impl_trait_tys ( impl_fn_def_id)
23322306 . map_bound ( |tys| {
23332307 tys. map_or_else ( |_| tcx. ty_error ( ) , |tys| tys[ & obligation. predicate . item_def_id ] )
0 commit comments