Auto merge of #113312 - Ddystopia:auto-trait-fun, r=lcnr
discard default auto trait impls if explicit ones exist (rebase of #85048) Rebase of #85048
This commit is contained in:
@@ -1783,6 +1783,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
/// candidates and prefer where-clause candidates.
|
||||
///
|
||||
/// See the comment for "SelectionCandidate" for more details.
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
fn candidate_should_be_dropped_in_favor_of(
|
||||
&mut self,
|
||||
victim: &EvaluatedCandidate<'tcx>,
|
||||
@@ -1806,13 +1807,6 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
// This is a fix for #53123 and prevents winnowing from accidentally extending the
|
||||
// lifetime of a variable.
|
||||
match (&other.candidate, &victim.candidate) {
|
||||
(_, AutoImplCandidate) | (AutoImplCandidate, _) => {
|
||||
bug!(
|
||||
"default implementations shouldn't be recorded \
|
||||
when there are other valid candidates"
|
||||
);
|
||||
}
|
||||
|
||||
// FIXME(@jswrenn): this should probably be more sophisticated
|
||||
(TransmutabilityCandidate, _) | (_, TransmutabilityCandidate) => DropVictim::No,
|
||||
|
||||
@@ -1854,6 +1848,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
(
|
||||
ParamCandidate(ref other_cand),
|
||||
ImplCandidate(..)
|
||||
| AutoImplCandidate
|
||||
| ClosureCandidate { .. }
|
||||
| GeneratorCandidate
|
||||
| FutureCandidate
|
||||
@@ -1881,6 +1876,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
}
|
||||
(
|
||||
ImplCandidate(_)
|
||||
| AutoImplCandidate
|
||||
| ClosureCandidate { .. }
|
||||
| GeneratorCandidate
|
||||
| FutureCandidate
|
||||
@@ -1914,6 +1910,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
(
|
||||
ObjectCandidate(_) | ProjectionCandidate(..),
|
||||
ImplCandidate(..)
|
||||
| AutoImplCandidate
|
||||
| ClosureCandidate { .. }
|
||||
| GeneratorCandidate
|
||||
| FutureCandidate
|
||||
@@ -1927,6 +1924,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
|
||||
(
|
||||
ImplCandidate(..)
|
||||
| AutoImplCandidate
|
||||
| ClosureCandidate { .. }
|
||||
| GeneratorCandidate
|
||||
| FutureCandidate
|
||||
@@ -2017,6 +2015,19 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
(AutoImplCandidate, ImplCandidate(_)) | (ImplCandidate(_), AutoImplCandidate) => {
|
||||
DropVictim::No
|
||||
}
|
||||
|
||||
(AutoImplCandidate, _) | (_, AutoImplCandidate) => {
|
||||
bug!(
|
||||
"default implementations shouldn't be recorded \
|
||||
when there are other global candidates: {:?} {:?}",
|
||||
other,
|
||||
victim
|
||||
);
|
||||
}
|
||||
|
||||
// Everything else is ambiguous
|
||||
(
|
||||
ImplCandidate(_)
|
||||
|
||||
Reference in New Issue
Block a user