@@ -676,7 +676,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
676676 & self ,
677677 obligation : & PredicateObligation < ' tcx > ,
678678 err : & mut DiagnosticBuilder < ' _ > ,
679- trait_ref : & ty:: Binder < ' tcx , ty:: TraitRef < ' tcx > > ,
679+ poly_trait_ref : & ty:: Binder < ' tcx , ty:: TraitRef < ' tcx > > ,
680680 has_custom_message : bool ,
681681 ) -> bool {
682682 let span = obligation. cause . span ;
@@ -705,7 +705,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
705705 never_suggest_borrow. push ( self . tcx . get_diagnostic_item ( sym:: send_trait) . unwrap ( ) ) ;
706706
707707 let param_env = obligation. param_env ;
708- let trait_ref = trait_ref . skip_binder ( ) ;
708+ let trait_ref = poly_trait_ref . skip_binder ( ) ;
709709
710710 let found_ty = trait_ref. self_ty ( ) ;
711711 let found_ty_str = found_ty. to_string ( ) ;
@@ -715,25 +715,25 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
715715 let mut_substs = self . tcx . mk_substs_trait ( mut_borrowed_found_ty, & [ ] ) ;
716716
717717 // Try to apply the original trait binding obligation by borrowing.
718- let mut try_borrowing = |new_imm_trait_ref : ty:: TraitRef < ' tcx > ,
719- new_mut_trait_ref : ty:: TraitRef < ' tcx > ,
720- expected_trait_ref : ty:: TraitRef < ' tcx > ,
718+ let mut try_borrowing = |new_imm_trait_ref : ty:: Binder < ' tcx , ty :: TraitRef < ' tcx > > ,
719+ new_mut_trait_ref : ty:: Binder < ' tcx , ty :: TraitRef < ' tcx > > ,
720+ expected_trait_ref : ty:: Binder < ' tcx , ty :: TraitRef < ' tcx > > ,
721721 blacklist : & [ DefId ] |
722722 -> bool {
723- if blacklist. contains ( & expected_trait_ref. def_id ) {
723+ if blacklist. contains ( & expected_trait_ref. def_id ( ) ) {
724724 return false ;
725725 }
726726
727727 let imm_result = self . predicate_must_hold_modulo_regions ( & Obligation :: new (
728728 ObligationCause :: dummy ( ) ,
729729 param_env,
730- ty :: Binder :: dummy ( new_imm_trait_ref) . without_const ( ) . to_predicate ( self . tcx ) ,
730+ new_imm_trait_ref. without_const ( ) . to_predicate ( self . tcx ) ,
731731 ) ) ;
732732
733733 let mut_result = self . predicate_must_hold_modulo_regions ( & Obligation :: new (
734734 ObligationCause :: dummy ( ) ,
735735 param_env,
736- ty :: Binder :: dummy ( new_mut_trait_ref) . without_const ( ) . to_predicate ( self . tcx ) ,
736+ new_mut_trait_ref. without_const ( ) . to_predicate ( self . tcx ) ,
737737 ) ) ;
738738
739739 if imm_result || mut_result {
@@ -806,19 +806,19 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
806806 } ;
807807
808808 if let ObligationCauseCode :: ImplDerivedObligation ( obligation) = & * code {
809- let expected_trait_ref = obligation. parent_trait_ref . skip_binder ( ) ;
810- let new_imm_trait_ref =
811- ty:: TraitRef :: new ( obligation. parent_trait_ref . def_id ( ) , imm_substs) ;
812- let new_mut_trait_ref =
813- ty:: TraitRef :: new ( obligation. parent_trait_ref . def_id ( ) , mut_substs) ;
809+ let expected_trait_ref = obligation. parent_trait_ref ;
810+ let new_imm_trait_ref = poly_trait_ref
811+ . rebind ( ty:: TraitRef :: new ( obligation. parent_trait_ref . def_id ( ) , imm_substs) ) ;
812+ let new_mut_trait_ref = poly_trait_ref
813+ . rebind ( ty:: TraitRef :: new ( obligation. parent_trait_ref . def_id ( ) , mut_substs) ) ;
814814 return try_borrowing ( new_imm_trait_ref, new_mut_trait_ref, expected_trait_ref, & [ ] ) ;
815815 } else if let ObligationCauseCode :: BindingObligation ( _, _)
816816 | ObligationCauseCode :: ItemObligation ( _) = & * code
817817 {
818818 return try_borrowing (
819- ty:: TraitRef :: new ( trait_ref. def_id , imm_substs) ,
820- ty:: TraitRef :: new ( trait_ref. def_id , mut_substs) ,
821- trait_ref ,
819+ poly_trait_ref . rebind ( ty:: TraitRef :: new ( trait_ref. def_id , imm_substs) ) ,
820+ poly_trait_ref . rebind ( ty:: TraitRef :: new ( trait_ref. def_id , mut_substs) ) ,
821+ * poly_trait_ref ,
822822 & never_suggest_borrow[ ..] ,
823823 ) ;
824824 } else {
0 commit comments