@@ -675,7 +675,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
675
675
& self ,
676
676
obligation : & PredicateObligation < ' tcx > ,
677
677
err : & mut DiagnosticBuilder < ' _ > ,
678
- trait_ref : & ty:: Binder < ' tcx , ty:: TraitRef < ' tcx > > ,
678
+ poly_trait_ref : & ty:: Binder < ' tcx , ty:: TraitRef < ' tcx > > ,
679
679
has_custom_message : bool ,
680
680
) -> bool {
681
681
let span = obligation. cause . span ;
@@ -704,7 +704,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
704
704
never_suggest_borrow. push ( self . tcx . get_diagnostic_item ( sym:: send_trait) . unwrap ( ) ) ;
705
705
706
706
let param_env = obligation. param_env ;
707
- let trait_ref = trait_ref . skip_binder ( ) ;
707
+ let trait_ref = poly_trait_ref . skip_binder ( ) ;
708
708
709
709
let found_ty = trait_ref. self_ty ( ) ;
710
710
let found_ty_str = found_ty. to_string ( ) ;
@@ -714,25 +714,25 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
714
714
let mut_substs = self . tcx . mk_substs_trait ( mut_borrowed_found_ty, & [ ] ) ;
715
715
716
716
// Try to apply the original trait binding obligation by borrowing.
717
- let mut try_borrowing = |new_imm_trait_ref : ty:: TraitRef < ' tcx > ,
718
- new_mut_trait_ref : ty:: TraitRef < ' tcx > ,
719
- expected_trait_ref : ty:: TraitRef < ' tcx > ,
717
+ let mut try_borrowing = |new_imm_trait_ref : ty:: Binder < ' tcx , ty :: TraitRef < ' tcx > > ,
718
+ new_mut_trait_ref : ty:: Binder < ' tcx , ty :: TraitRef < ' tcx > > ,
719
+ expected_trait_ref : ty:: Binder < ' tcx , ty :: TraitRef < ' tcx > > ,
720
720
blacklist : & [ DefId ] |
721
721
-> bool {
722
- if blacklist. contains ( & expected_trait_ref. def_id ) {
722
+ if blacklist. contains ( & expected_trait_ref. def_id ( ) ) {
723
723
return false ;
724
724
}
725
725
726
726
let imm_result = self . predicate_must_hold_modulo_regions ( & Obligation :: new (
727
727
ObligationCause :: dummy ( ) ,
728
728
param_env,
729
- ty :: Binder :: dummy ( new_imm_trait_ref) . without_const ( ) . to_predicate ( self . tcx ) ,
729
+ new_imm_trait_ref. without_const ( ) . to_predicate ( self . tcx ) ,
730
730
) ) ;
731
731
732
732
let mut_result = self . predicate_must_hold_modulo_regions ( & Obligation :: new (
733
733
ObligationCause :: dummy ( ) ,
734
734
param_env,
735
- ty :: Binder :: dummy ( new_mut_trait_ref) . without_const ( ) . to_predicate ( self . tcx ) ,
735
+ new_mut_trait_ref. without_const ( ) . to_predicate ( self . tcx ) ,
736
736
) ) ;
737
737
738
738
if imm_result || mut_result {
@@ -805,19 +805,19 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
805
805
} ;
806
806
807
807
if let ObligationCauseCode :: ImplDerivedObligation ( obligation) = & * code {
808
- let expected_trait_ref = obligation. parent_trait_ref . skip_binder ( ) ;
809
- let new_imm_trait_ref =
810
- ty:: TraitRef :: new ( obligation. parent_trait_ref . def_id ( ) , imm_substs) ;
811
- let new_mut_trait_ref =
812
- ty:: TraitRef :: new ( obligation. parent_trait_ref . def_id ( ) , mut_substs) ;
808
+ let expected_trait_ref = obligation. parent_trait_ref ;
809
+ let new_imm_trait_ref = poly_trait_ref
810
+ . rebind ( ty:: TraitRef :: new ( obligation. parent_trait_ref . def_id ( ) , imm_substs) ) ;
811
+ let new_mut_trait_ref = poly_trait_ref
812
+ . rebind ( ty:: TraitRef :: new ( obligation. parent_trait_ref . def_id ( ) , mut_substs) ) ;
813
813
return try_borrowing ( new_imm_trait_ref, new_mut_trait_ref, expected_trait_ref, & [ ] ) ;
814
814
} else if let ObligationCauseCode :: BindingObligation ( _, _)
815
815
| ObligationCauseCode :: ItemObligation ( _) = & * code
816
816
{
817
817
return try_borrowing (
818
- ty:: TraitRef :: new ( trait_ref. def_id , imm_substs) ,
819
- ty:: TraitRef :: new ( trait_ref. def_id , mut_substs) ,
820
- trait_ref ,
818
+ poly_trait_ref . rebind ( ty:: TraitRef :: new ( trait_ref. def_id , imm_substs) ) ,
819
+ poly_trait_ref . rebind ( ty:: TraitRef :: new ( trait_ref. def_id , mut_substs) ) ,
820
+ * poly_trait_ref ,
821
821
& never_suggest_borrow[ ..] ,
822
822
) ;
823
823
} else {
0 commit comments