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