@@ -1652,11 +1652,10 @@ fn check_fn_or_method<'tcx>(
1652
1652
}
1653
1653
1654
1654
/// The `arbitrary_self_types_pointers` feature implies `arbitrary_self_types`.
1655
- #[ derive( Clone , Copy ) ]
1655
+ #[ derive( Clone , Copy , PartialEq ) ]
1656
1656
enum 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
1660
1659
}
1661
1660
1662
1661
#[ instrument( level = "debug" , skip( wfcx) ) ]
@@ -1692,26 +1691,25 @@ fn check_method_receiver<'tcx>(
1692
1691
}
1693
1692
1694
1693
let arbitrary_self_types_level = if tcx. features ( ) . arbitrary_self_types_pointers {
1695
- ArbitrarySelfTypesLevel :: ArbitrarySelfTypesPointers
1694
+ Some ( ArbitrarySelfTypesLevel :: WithPointers )
1696
1695
} else if tcx. features ( ) . arbitrary_self_types {
1697
- ArbitrarySelfTypesLevel :: ArbitrarySelfTypes
1696
+ Some ( ArbitrarySelfTypesLevel :: Basic )
1698
1697
} else {
1699
- ArbitrarySelfTypesLevel :: None
1698
+ None
1700
1699
} ;
1701
1700
1702
1701
if !receiver_is_valid ( wfcx, span, receiver_ty, self_ty, arbitrary_self_types_level) {
1703
1702
return Err ( match arbitrary_self_types_level {
1704
1703
// Wherever possible, emit a message advising folks that the features
1705
1704
// `arbitrary_self_types` or `arbitrary_self_types_pointers` might
1706
1705
// 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
+ ) =>
1715
1713
{
1716
1714
// Report error; would have worked with `arbitrary_self_types`.
1717
1715
feature_err (
@@ -1726,13 +1724,13 @@ fn check_method_receiver<'tcx>(
1726
1724
. with_help ( fluent:: hir_analysis_invalid_receiver_ty_help)
1727
1725
. emit ( )
1728
1726
}
1729
- ArbitrarySelfTypesLevel :: ArbitrarySelfTypes | ArbitrarySelfTypesLevel :: None
1727
+ None | Some ( ArbitrarySelfTypesLevel :: Basic )
1730
1728
if receiver_is_valid (
1731
1729
wfcx,
1732
1730
span,
1733
1731
receiver_ty,
1734
1732
self_ty,
1735
- ArbitrarySelfTypesLevel :: ArbitrarySelfTypesPointers ,
1733
+ Some ( ArbitrarySelfTypesLevel :: WithPointers ) ,
1736
1734
) =>
1737
1735
{
1738
1736
// Report error; would have worked with `arbitrary_self_types_pointers`.
@@ -1772,7 +1770,7 @@ fn receiver_is_valid<'tcx>(
1772
1770
span : Span ,
1773
1771
receiver_ty : Ty < ' tcx > ,
1774
1772
self_ty : Ty < ' tcx > ,
1775
- arbitrary_self_types_enabled : ArbitrarySelfTypesLevel ,
1773
+ arbitrary_self_types_enabled : Option < ArbitrarySelfTypesLevel > ,
1776
1774
) -> bool {
1777
1775
let infcx = wfcx. infcx ;
1778
1776
let tcx = wfcx. tcx ( ) ;
@@ -1791,7 +1789,7 @@ fn receiver_is_valid<'tcx>(
1791
1789
let mut autoderef = Autoderef :: new ( infcx, wfcx. param_env , wfcx. body_def_id , span, receiver_ty) ;
1792
1790
1793
1791
// 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 ) {
1795
1793
autoderef = autoderef. include_raw_pointers ( ) ;
1796
1794
}
1797
1795
@@ -1817,7 +1815,7 @@ fn receiver_is_valid<'tcx>(
1817
1815
1818
1816
// Without `feature(arbitrary_self_types)`, we require that each step in the
1819
1817
// deref chain implement `receiver`.
1820
- if matches ! ( arbitrary_self_types_enabled, ArbitrarySelfTypesLevel :: None ) {
1818
+ if arbitrary_self_types_enabled. is_none ( ) {
1821
1819
if !receiver_is_implemented (
1822
1820
wfcx,
1823
1821
receiver_trait_def_id,
0 commit comments