@@ -125,29 +125,34 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
125125 self . infcx . commit_unconditionally ( |_| {
126126 let tcx = self . tcx ( ) ;
127127
128- let bound_self_ty = self . infcx . shallow_resolve ( obligation. self_ty ( ) ) ;
129- let ( def_id, substs) = match * bound_self_ty. skip_binder ( ) . kind ( ) {
128+ let trait_predicate = self . infcx . shallow_resolve ( obligation. predicate ) ;
129+ let placeholder_trait_predicate =
130+ self . infcx ( ) . replace_bound_vars_with_placeholders ( & trait_predicate) ;
131+ let placeholder_self_ty = placeholder_trait_predicate. self_ty ( ) ;
132+ let ( def_id, substs) = match * placeholder_self_ty. kind ( ) {
130133 ty:: Projection ( proj) => ( proj. item_def_id , proj. substs ) ,
131134 ty:: Opaque ( def_id, substs) => ( def_id, substs) ,
132- _ => bug ! ( "projection candidate for unexpected type: {:?}" , bound_self_ty ) ,
135+ _ => bug ! ( "projection candidate for unexpected type: {:?}" , placeholder_self_ty ) ,
133136 } ;
134137
135138 let candidate_predicate = tcx. item_bounds ( def_id) [ idx] . subst ( tcx, substs) ;
136139 let candidate = candidate_predicate
137140 . to_opt_poly_trait_ref ( )
138141 . expect ( "projection candidate is not a trait predicate" ) ;
139- let Normalized { value : candidate, mut obligations } = normalize_with_depth (
142+ let mut obligations = Vec :: new ( ) ;
143+ let candidate = normalize_with_depth_to (
140144 self ,
141145 obligation. param_env ,
142146 obligation. cause . clone ( ) ,
143147 obligation. recursion_depth + 1 ,
144148 & candidate,
149+ & mut obligations,
145150 ) ;
146151
147152 obligations. extend (
148153 self . infcx
149154 . at ( & obligation. cause , obligation. param_env )
150- . sup ( obligation . predicate . to_poly_trait_ref ( ) , candidate)
155+ . sup ( placeholder_trait_predicate . trait_ref . to_poly_trait_ref ( ) , candidate)
151156 . map ( |InferOk { obligations, .. } | obligations)
152157 . unwrap_or_else ( |_| {
153158 bug ! (
@@ -158,7 +163,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
158163 } ) ,
159164 ) ;
160165
161- if let ty:: Projection ( ..) = bound_self_ty . skip_binder ( ) . kind ( ) {
166+ if let ty:: Projection ( ..) = placeholder_self_ty . kind ( ) {
162167 for predicate in tcx. predicates_of ( def_id) . instantiate_own ( tcx, substs) . predicates {
163168 let normalized = normalize_with_depth_to (
164169 self ,
0 commit comments