@@ -1713,24 +1713,13 @@ fn receiver_is_valid<'tcx>(
17131713 let cause =
17141714 ObligationCause :: new ( span, wfcx. body_def_id , traits:: ObligationCauseCode :: MethodReceiver ) ;
17151715
1716- // Special case `receiver == self_ty`, which doesn't necessarily require the `Receiver` lang item.
1717- if let Ok ( ( ) ) = wfcx. infcx . commit_if_ok ( |_| {
1718- let ocx = ObligationCtxt :: new ( wfcx. infcx ) ;
1719- ocx. eq ( & cause, wfcx. param_env , self_ty, receiver_ty) ?;
1720- if ocx. select_all_or_error ( ) . is_empty ( ) { Ok ( ( ) ) } else { Err ( NoSolution ) }
1721- } ) {
1722- return true ;
1723- }
1724-
17251716 let mut autoderef = Autoderef :: new ( infcx, wfcx. param_env , wfcx. body_def_id , span, receiver_ty) ;
17261717
17271718 // The `arbitrary_self_types` feature allows raw pointer receivers like `self: *const Self`.
17281719 if arbitrary_self_types_enabled {
17291720 autoderef = autoderef. include_raw_pointers ( ) ;
17301721 }
17311722
1732- let receiver_trait_def_id = tcx. require_lang_item ( LangItem :: Receiver , Some ( span) ) ;
1733-
17341723 // Keep dereferencing `receiver_ty` until we get to `self_ty`.
17351724 while let Some ( ( potential_self_ty, _) ) = autoderef. next ( ) {
17361725 debug ! (
@@ -1752,6 +1741,8 @@ fn receiver_is_valid<'tcx>(
17521741 // Without `feature(arbitrary_self_types)`, we require that each step in the
17531742 // deref chain implement `receiver`.
17541743 if !arbitrary_self_types_enabled {
1744+ let receiver_trait_def_id = tcx. require_lang_item ( LangItem :: Receiver , Some ( span) ) ;
1745+
17551746 if !receiver_is_implemented (
17561747 wfcx,
17571748 receiver_trait_def_id,
0 commit comments