@@ -50,14 +50,18 @@ pub type ProjectionTyObligation<'tcx> = Obligation<'tcx, ty::ProjectionTy<'tcx>>
50
50
pub ( super ) struct InProgress ;
51
51
52
52
pub 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.
53
57
fn normalize < T : TypeFoldable < ' tcx > > ( & self , t : T ) -> InferOk < ' tcx , T > ;
54
58
}
55
59
56
60
impl < ' tcx > NormalizeExt < ' tcx > for At < ' _ , ' tcx > {
57
61
fn normalize < T : TypeFoldable < ' tcx > > ( & self , value : T ) -> InferOk < ' tcx , T > {
58
62
let mut selcx = SelectionContext :: new ( self . infcx ) ;
59
63
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) ;
61
65
InferOk { value, obligations }
62
66
}
63
67
}
@@ -303,37 +307,6 @@ fn project_and_unify_type<'cx, 'tcx>(
303
307
}
304
308
}
305
309
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
-
337
310
/// As `normalize`, but with a custom depth.
338
311
pub ( crate ) fn normalize_with_depth < ' a , ' b , ' tcx , T > (
339
312
selcx : & ' a mut SelectionContext < ' b , ' tcx > ,
@@ -2324,10 +2297,11 @@ fn confirm_impl_trait_in_trait_candidate<'tcx>(
2324
2297
} ,
2325
2298
) ) ;
2326
2299
2327
- let ty = super :: normalize_to (
2300
+ let ty = normalize_with_depth_to (
2328
2301
selcx,
2329
2302
obligation. param_env ,
2330
2303
cause. clone ( ) ,
2304
+ obligation. recursion_depth + 1 ,
2331
2305
tcx. bound_trait_impl_trait_tys ( impl_fn_def_id)
2332
2306
. map_bound ( |tys| {
2333
2307
tys. map_or_else ( |_| tcx. ty_error ( ) , |tys| tys[ & obligation. predicate . item_def_id ] )
0 commit comments