@@ -1712,24 +1712,13 @@ fn receiver_is_valid<'tcx>(
17121712 let cause =
17131713 ObligationCause :: new ( span, wfcx. body_def_id , traits:: ObligationCauseCode :: MethodReceiver ) ;
17141714
1715- // Special case `receiver == self_ty`, which doesn't necessarily require the `Receiver` lang item.
1716- if let Ok ( ( ) ) = wfcx. infcx . commit_if_ok ( |_| {
1717- let ocx = ObligationCtxt :: new ( wfcx. infcx ) ;
1718- ocx. eq ( & cause, wfcx. param_env , self_ty, receiver_ty) ?;
1719- if ocx. select_all_or_error ( ) . is_empty ( ) { Ok ( ( ) ) } else { Err ( NoSolution ) }
1720- } ) {
1721- return true ;
1722- }
1723-
17241715 let mut autoderef = Autoderef :: new ( infcx, wfcx. param_env , wfcx. body_def_id , span, receiver_ty) ;
17251716
17261717 // The `arbitrary_self_types` feature allows raw pointer receivers like `self: *const Self`.
17271718 if arbitrary_self_types_enabled {
17281719 autoderef = autoderef. include_raw_pointers ( ) ;
17291720 }
17301721
1731- let receiver_trait_def_id = tcx. require_lang_item ( LangItem :: Receiver , Some ( span) ) ;
1732-
17331722 // Keep dereferencing `receiver_ty` until we get to `self_ty`.
17341723 while let Some ( ( potential_self_ty, _) ) = autoderef. next ( ) {
17351724 debug ! (
@@ -1751,6 +1740,8 @@ fn receiver_is_valid<'tcx>(
17511740 // Without `feature(arbitrary_self_types)`, we require that each step in the
17521741 // deref chain implement `receiver`.
17531742 if !arbitrary_self_types_enabled {
1743+ let receiver_trait_def_id = tcx. require_lang_item ( LangItem :: Receiver , Some ( span) ) ;
1744+
17541745 if !receiver_is_implemented (
17551746 wfcx,
17561747 receiver_trait_def_id,
@@ -1760,14 +1751,6 @@ fn receiver_is_valid<'tcx>(
17601751 // We cannot proceed.
17611752 break ;
17621753 }
1763-
1764- // Register the bound, in case it has any region side-effects.
1765- wfcx. register_bound (
1766- cause. clone ( ) ,
1767- wfcx. param_env ,
1768- potential_self_ty,
1769- receiver_trait_def_id,
1770- ) ;
17711754 }
17721755 }
17731756
0 commit comments