@@ -1713,24 +1713,13 @@ fn receiver_is_valid<'tcx>(
1713
1713
let cause =
1714
1714
ObligationCause :: new ( span, wfcx. body_def_id , traits:: ObligationCauseCode :: MethodReceiver ) ;
1715
1715
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
-
1725
1716
let mut autoderef = Autoderef :: new ( infcx, wfcx. param_env , wfcx. body_def_id , span, receiver_ty) ;
1726
1717
1727
1718
// The `arbitrary_self_types` feature allows raw pointer receivers like `self: *const Self`.
1728
1719
if arbitrary_self_types_enabled {
1729
1720
autoderef = autoderef. include_raw_pointers ( ) ;
1730
1721
}
1731
1722
1732
- let receiver_trait_def_id = tcx. require_lang_item ( LangItem :: Receiver , Some ( span) ) ;
1733
-
1734
1723
// Keep dereferencing `receiver_ty` until we get to `self_ty`.
1735
1724
while let Some ( ( potential_self_ty, _) ) = autoderef. next ( ) {
1736
1725
debug ! (
@@ -1752,6 +1741,8 @@ fn receiver_is_valid<'tcx>(
1752
1741
// Without `feature(arbitrary_self_types)`, we require that each step in the
1753
1742
// deref chain implement `receiver`.
1754
1743
if !arbitrary_self_types_enabled {
1744
+ let receiver_trait_def_id = tcx. require_lang_item ( LangItem :: Receiver , Some ( span) ) ;
1745
+
1755
1746
if !receiver_is_implemented (
1756
1747
wfcx,
1757
1748
receiver_trait_def_id,
0 commit comments