@@ -125,29 +125,34 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
125
125
self . infcx . commit_unconditionally ( |_| {
126
126
let tcx = self . tcx ( ) ;
127
127
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 ( ) {
130
133
ty:: Projection ( proj) => ( proj. item_def_id , proj. substs ) ,
131
134
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 ) ,
133
136
} ;
134
137
135
138
let candidate_predicate = tcx. item_bounds ( def_id) [ idx] . subst ( tcx, substs) ;
136
139
let candidate = candidate_predicate
137
140
. to_opt_poly_trait_ref ( )
138
141
. 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 (
140
144
self ,
141
145
obligation. param_env ,
142
146
obligation. cause . clone ( ) ,
143
147
obligation. recursion_depth + 1 ,
144
148
& candidate,
149
+ & mut obligations,
145
150
) ;
146
151
147
152
obligations. extend (
148
153
self . infcx
149
154
. 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)
151
156
. map ( |InferOk { obligations, .. } | obligations)
152
157
. unwrap_or_else ( |_| {
153
158
bug ! (
@@ -158,7 +163,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
158
163
} ) ,
159
164
) ;
160
165
161
- if let ty:: Projection ( ..) = bound_self_ty . skip_binder ( ) . kind ( ) {
166
+ if let ty:: Projection ( ..) = placeholder_self_ty . kind ( ) {
162
167
for predicate in tcx. predicates_of ( def_id) . instantiate_own ( tcx, substs) . predicates {
163
168
let normalized = normalize_with_depth_to (
164
169
self ,
0 commit comments