@@ -998,13 +998,8 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
998998 if trait_predicate. skip_binder ( ) . self_ty ( ) . is_never ( )
999999 && self . fallback_has_occurred
10001000 {
1001- let predicate = trait_predicate. map_bound ( |mut trait_pred| {
1002- trait_pred. trait_ref = self . tcx . mk_trait_ref (
1003- trait_pred. trait_ref . def_id ,
1004- self . tcx . mk_unit ( ) ,
1005- & trait_pred. trait_ref . substs [ 1 ..] ,
1006- ) ;
1007- trait_pred
1001+ let predicate = trait_predicate. map_bound ( |trait_pred| {
1002+ trait_pred. with_self_type ( self . tcx , self . tcx . mk_unit ( ) )
10081003 } ) ;
10091004 let unit_obligation = obligation. with ( tcx, predicate) ;
10101005 if self . predicate_may_hold ( & unit_obligation) {
@@ -2026,14 +2021,8 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
20262021 param_env : ty:: ParamEnv < ' tcx > ,
20272022 trait_ref_and_ty : ty:: Binder < ' tcx , ( ty:: TraitPredicate < ' tcx > , Ty < ' tcx > ) > ,
20282023 ) -> PredicateObligation < ' tcx > {
2029- let trait_pred = trait_ref_and_ty. map_bound_ref ( |( tr, new_self_ty) | ty:: TraitPredicate {
2030- trait_ref : self . tcx . mk_trait_ref (
2031- tr. trait_ref . def_id ,
2032- * new_self_ty,
2033- & tr. trait_ref . substs [ 1 ..] ,
2034- ) ,
2035- ..* tr
2036- } ) ;
2024+ let trait_pred = trait_ref_and_ty
2025+ . map_bound ( |( tr, new_self_ty) | tr. with_self_type ( self . tcx , new_self_ty) ) ;
20372026
20382027 Obligation :: new ( self . tcx , ObligationCause :: dummy ( ) , param_env, trait_pred)
20392028 }
0 commit comments