@@ -1652,11 +1652,10 @@ fn check_fn_or_method<'tcx>(
16521652}
16531653
16541654/// The `arbitrary_self_types_pointers` feature implies `arbitrary_self_types`.
1655- #[ derive( Clone , Copy ) ]
1655+ #[ derive( Clone , Copy , PartialEq ) ]
16561656enum ArbitrarySelfTypesLevel {
1657- None , // neither arbitrary_self_types nor arbitrary_self_types_pointers
1658- ArbitrarySelfTypes , // just arbitrary_self_types
1659- ArbitrarySelfTypesPointers , // both arbitrary_self_types and arbitrary_self_types_pointers
1657+ Basic , // just arbitrary_self_types
1658+ WithPointers , // both arbitrary_self_types and arbitrary_self_types_pointers
16601659}
16611660
16621661#[ instrument( level = "debug" , skip( wfcx) ) ]
@@ -1692,26 +1691,25 @@ fn check_method_receiver<'tcx>(
16921691 }
16931692
16941693 let arbitrary_self_types_level = if tcx. features ( ) . arbitrary_self_types_pointers {
1695- ArbitrarySelfTypesLevel :: ArbitrarySelfTypesPointers
1694+ Some ( ArbitrarySelfTypesLevel :: WithPointers )
16961695 } else if tcx. features ( ) . arbitrary_self_types {
1697- ArbitrarySelfTypesLevel :: ArbitrarySelfTypes
1696+ Some ( ArbitrarySelfTypesLevel :: Basic )
16981697 } else {
1699- ArbitrarySelfTypesLevel :: None
1698+ None
17001699 } ;
17011700
17021701 if !receiver_is_valid ( wfcx, span, receiver_ty, self_ty, arbitrary_self_types_level) {
17031702 return Err ( match arbitrary_self_types_level {
17041703 // Wherever possible, emit a message advising folks that the features
17051704 // `arbitrary_self_types` or `arbitrary_self_types_pointers` might
17061705 // have helped.
1707- ArbitrarySelfTypesLevel :: None
1708- if receiver_is_valid (
1709- wfcx,
1710- span,
1711- receiver_ty,
1712- self_ty,
1713- ArbitrarySelfTypesLevel :: ArbitrarySelfTypes ,
1714- ) =>
1706+ None if receiver_is_valid (
1707+ wfcx,
1708+ span,
1709+ receiver_ty,
1710+ self_ty,
1711+ Some ( ArbitrarySelfTypesLevel :: Basic ) ,
1712+ ) =>
17151713 {
17161714 // Report error; would have worked with `arbitrary_self_types`.
17171715 feature_err (
@@ -1726,13 +1724,13 @@ fn check_method_receiver<'tcx>(
17261724 . with_help ( fluent:: hir_analysis_invalid_receiver_ty_help)
17271725 . emit ( )
17281726 }
1729- ArbitrarySelfTypesLevel :: ArbitrarySelfTypes | ArbitrarySelfTypesLevel :: None
1727+ None | Some ( ArbitrarySelfTypesLevel :: Basic )
17301728 if receiver_is_valid (
17311729 wfcx,
17321730 span,
17331731 receiver_ty,
17341732 self_ty,
1735- ArbitrarySelfTypesLevel :: ArbitrarySelfTypesPointers ,
1733+ Some ( ArbitrarySelfTypesLevel :: WithPointers ) ,
17361734 ) =>
17371735 {
17381736 // Report error; would have worked with `arbitrary_self_types_pointers`.
@@ -1772,7 +1770,7 @@ fn receiver_is_valid<'tcx>(
17721770 span : Span ,
17731771 receiver_ty : Ty < ' tcx > ,
17741772 self_ty : Ty < ' tcx > ,
1775- arbitrary_self_types_enabled : ArbitrarySelfTypesLevel ,
1773+ arbitrary_self_types_enabled : Option < ArbitrarySelfTypesLevel > ,
17761774) -> bool {
17771775 let infcx = wfcx. infcx ;
17781776 let tcx = wfcx. tcx ( ) ;
@@ -1791,7 +1789,7 @@ fn receiver_is_valid<'tcx>(
17911789 let mut autoderef = Autoderef :: new ( infcx, wfcx. param_env , wfcx. body_def_id , span, receiver_ty) ;
17921790
17931791 // The `arbitrary_self_types_pointers` feature allows raw pointer receivers like `self: *const Self`.
1794- if matches ! ( arbitrary_self_types_enabled, ArbitrarySelfTypesLevel :: ArbitrarySelfTypesPointers ) {
1792+ if arbitrary_self_types_enabled == Some ( ArbitrarySelfTypesLevel :: WithPointers ) {
17951793 autoderef = autoderef. include_raw_pointers ( ) ;
17961794 }
17971795
@@ -1817,7 +1815,7 @@ fn receiver_is_valid<'tcx>(
18171815
18181816 // Without `feature(arbitrary_self_types)`, we require that each step in the
18191817 // deref chain implement `receiver`.
1820- if matches ! ( arbitrary_self_types_enabled, ArbitrarySelfTypesLevel :: None ) {
1818+ if arbitrary_self_types_enabled. is_none ( ) {
18211819 if !receiver_is_implemented (
18221820 wfcx,
18231821 receiver_trait_def_id,
0 commit comments