@@ -1814,6 +1814,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
1814
1814
/// candidates and prefer where-clause candidates.
1815
1815
///
1816
1816
/// See the comment for "SelectionCandidate" for more details.
1817
+ #[ instrument( level = "debug" , skip( self ) ) ]
1817
1818
fn candidate_should_be_dropped_in_favor_of (
1818
1819
& mut self ,
1819
1820
victim : & EvaluatedCandidate < ' tcx > ,
@@ -1837,13 +1838,6 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
1837
1838
// This is a fix for #53123 and prevents winnowing from accidentally extending the
1838
1839
// lifetime of a variable.
1839
1840
match ( & other. candidate , & victim. candidate ) {
1840
- ( _, AutoImplCandidate ) | ( AutoImplCandidate , _) => {
1841
- bug ! (
1842
- "default implementations shouldn't be recorded \
1843
- when there are other valid candidates"
1844
- ) ;
1845
- }
1846
-
1847
1841
// FIXME(@jswrenn): this should probably be more sophisticated
1848
1842
( TransmutabilityCandidate , _) | ( _, TransmutabilityCandidate ) => DropVictim :: No ,
1849
1843
@@ -1885,6 +1879,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
1885
1879
(
1886
1880
ParamCandidate ( ref other_cand) ,
1887
1881
ImplCandidate ( ..)
1882
+ | AutoImplCandidate
1888
1883
| ClosureCandidate { .. }
1889
1884
| GeneratorCandidate
1890
1885
| FutureCandidate
@@ -1912,6 +1907,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
1912
1907
}
1913
1908
(
1914
1909
ImplCandidate ( _)
1910
+ | AutoImplCandidate
1915
1911
| ClosureCandidate { .. }
1916
1912
| GeneratorCandidate
1917
1913
| FutureCandidate
@@ -1945,6 +1941,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
1945
1941
(
1946
1942
ObjectCandidate ( _) | ProjectionCandidate ( ..) ,
1947
1943
ImplCandidate ( ..)
1944
+ | AutoImplCandidate
1948
1945
| ClosureCandidate { .. }
1949
1946
| GeneratorCandidate
1950
1947
| FutureCandidate
@@ -1958,6 +1955,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
1958
1955
1959
1956
(
1960
1957
ImplCandidate ( ..)
1958
+ | AutoImplCandidate
1961
1959
| ClosureCandidate { .. }
1962
1960
| GeneratorCandidate
1963
1961
| FutureCandidate
@@ -2048,6 +2046,19 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
2048
2046
}
2049
2047
}
2050
2048
2049
+ ( AutoImplCandidate , ImplCandidate ( _) ) | ( ImplCandidate ( _) , AutoImplCandidate ) => {
2050
+ DropVictim :: No
2051
+ }
2052
+
2053
+ ( AutoImplCandidate , _) | ( _, AutoImplCandidate ) => {
2054
+ bug ! (
2055
+ "default implementations shouldn't be recorded \
2056
+ when there are other global candidates: {:?} {:?}",
2057
+ other,
2058
+ victim
2059
+ ) ;
2060
+ }
2061
+
2051
2062
// Everything else is ambiguous
2052
2063
(
2053
2064
ImplCandidate ( _)
0 commit comments