@@ -3147,7 +3147,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
31473147 err : & mut Diagnostic ,
31483148 parent_code : & ObligationCauseCode < ' tcx > ,
31493149 param_env : ty:: ParamEnv < ' tcx > ,
3150- predicate : ty:: Predicate < ' tcx > ,
3150+ failed_pred : ty:: Predicate < ' tcx > ,
31513151 call_hir_id : HirId ,
31523152 ) {
31533153 let tcx = self . tcx ;
@@ -3183,31 +3183,28 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
31833183
31843184 if let ObligationCauseCode :: ExprBindingObligation ( def_id, _, _, idx) = parent_code. deref ( )
31853185 && let Some ( node_substs) = typeck_results. node_substs_opt ( call_hir_id)
3186- && let predicates = self . tcx . predicates_of ( def_id) . instantiate ( self . tcx , node_substs)
3187- && let Some ( pred ) = predicates . predicates . get ( * idx)
3186+ && let where_clauses = self . tcx . predicates_of ( def_id) . instantiate ( self . tcx , node_substs)
3187+ && let Some ( where_pred ) = where_clauses . predicates . get ( * idx)
31883188 {
3189- if let Some ( trait_pred ) = pred . to_opt_poly_trait_pred ( )
3190- && let Some ( trait_predicate ) = predicate . to_opt_poly_trait_pred ( )
3189+ if let Some ( where_pred ) = where_pred . to_opt_poly_trait_pred ( )
3190+ && let Some ( failed_pred ) = failed_pred . to_opt_poly_trait_pred ( )
31913191 {
31923192 let mut c = CollectAllMismatches {
31933193 infcx : self . infcx ,
31943194 param_env,
31953195 errors : vec ! [ ] ,
31963196 } ;
3197- if let Ok ( _) = c. relate ( trait_pred , trait_predicate ) {
3197+ if let Ok ( _) = c. relate ( where_pred , failed_pred ) {
31983198 type_diffs = c. errors ;
31993199 }
3200- } else if let ty:: PredicateKind :: Clause (
3201- ty:: Clause :: Projection ( proj)
3202- ) = pred. kind ( ) . skip_binder ( )
3203- && let ty:: PredicateKind :: Clause (
3204- ty:: Clause :: Projection ( projection)
3205- ) = predicate. kind ( ) . skip_binder ( )
3200+ } else if let Some ( where_pred) = where_pred. to_opt_poly_projection_pred ( )
3201+ && let Some ( failed_pred) = failed_pred. to_opt_poly_projection_pred ( )
3202+ && let Some ( found) = failed_pred. skip_binder ( ) . term . ty ( )
32063203 {
32073204 type_diffs = vec ! [
32083205 Sorts ( ty:: error:: ExpectedFound {
3209- expected: self . tcx. mk_ty( ty:: Alias ( ty:: Projection , proj . projection_ty) ) ,
3210- found: projection . term . ty ( ) . unwrap ( ) ,
3206+ expected: self . tcx. mk_ty( ty:: Alias ( ty:: Projection , where_pred . skip_binder ( ) . projection_ty) ) ,
3207+ found,
32113208 } ) ,
32123209 ] ;
32133210 }
0 commit comments