Rollup merge of #102785 - fee1-dead-contrib:rm_autoimpl_defid, r=compiler-errors

Remove `DefId` from some `SelectionCandidate` variants

They are both from `obligation.predicate.def_id()`, which do not need to be on the `SelectionCandidate`.

cc ````@lcnr```` ````@compiler-errors````
This commit is contained in:
Matthias Krüger 2022-10-08 14:38:19 +02:00 committed by GitHub
commit f1a03b6e4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 21 deletions

View File

@ -115,7 +115,7 @@ pub enum SelectionCandidate<'tcx> {
ParamCandidate(ty::PolyTraitPredicate<'tcx>),
ImplCandidate(DefId),
AutoImplCandidate(DefId),
AutoImplCandidate,
/// This is a trait matching with a projected type as `Self`, and we found
/// an applicable bound in the trait definition. The `usize` is an index
@ -143,7 +143,7 @@ pub enum SelectionCandidate<'tcx> {
/// Builtin implementation of `Pointee`.
PointeeCandidate,
TraitAliasCandidate(DefId),
TraitAliasCandidate,
/// Matching `dyn Trait` with a supertrait of `Trait`. The index is the
/// position in the iterator returned by

View File

@ -625,7 +625,7 @@ fn assemble_candidates_from_auto_impls(
}
}
_ => candidates.vec.push(AutoImplCandidate(def_id)),
_ => candidates.vec.push(AutoImplCandidate),
}
}
}
@ -914,7 +914,7 @@ fn assemble_candidates_for_trait_alias(
let def_id = obligation.predicate.def_id();
if self.tcx().is_trait_alias(def_id) {
candidates.vec.push(TraitAliasCandidate(def_id));
candidates.vec.push(TraitAliasCandidate);
}
}

View File

@ -64,8 +64,8 @@ pub(super) fn confirm_candidate(
ImplSource::UserDefined(self.confirm_impl_candidate(obligation, impl_def_id))
}
AutoImplCandidate(trait_def_id) => {
let data = self.confirm_auto_impl_candidate(obligation, trait_def_id);
AutoImplCandidate => {
let data = self.confirm_auto_impl_candidate(obligation);
ImplSource::AutoImpl(data)
}
@ -100,8 +100,8 @@ pub(super) fn confirm_candidate(
PointeeCandidate => ImplSource::Pointee(ImplSourcePointeeData),
TraitAliasCandidate(alias_def_id) => {
let data = self.confirm_trait_alias_candidate(obligation, alias_def_id);
TraitAliasCandidate => {
let data = self.confirm_trait_alias_candidate(obligation);
ImplSource::TraitAlias(data)
}
@ -317,13 +317,12 @@ fn confirm_transmutability_candidate(
fn confirm_auto_impl_candidate(
&mut self,
obligation: &TraitObligation<'tcx>,
trait_def_id: DefId,
) -> ImplSourceAutoImplData<PredicateObligation<'tcx>> {
debug!(?obligation, ?trait_def_id, "confirm_auto_impl_candidate");
debug!(?obligation, "confirm_auto_impl_candidate");
let self_ty = self.infcx.shallow_resolve(obligation.predicate.self_ty());
let types = self.constituent_types_for_ty(self_ty);
self.vtable_auto_impl(obligation, trait_def_id, types)
self.vtable_auto_impl(obligation, obligation.predicate.def_id(), types)
}
/// See `confirm_auto_impl_candidate`.
@ -658,10 +657,10 @@ fn confirm_fn_pointer_candidate(
fn confirm_trait_alias_candidate(
&mut self,
obligation: &TraitObligation<'tcx>,
alias_def_id: DefId,
) -> ImplSourceTraitAliasData<'tcx, PredicateObligation<'tcx>> {
debug!(?obligation, ?alias_def_id, "confirm_trait_alias_candidate");
debug!(?obligation, "confirm_trait_alias_candidate");
let alias_def_id = obligation.predicate.def_id();
let predicate = self.infcx().replace_bound_vars_with_placeholders(obligation.predicate);
let trait_ref = predicate.trait_ref;
let trait_def_id = trait_ref.def_id;

View File

@ -1150,7 +1150,7 @@ fn filter_impls(
// const projection
ProjectionCandidate(_, ty::BoundConstness::ConstIfConst) => {}
// auto trait impl
AutoImplCandidate(..) => {}
AutoImplCandidate => {}
// generator, this will raise error in other places
// or ignore error with const_async_blocks feature
GeneratorCandidate => {}
@ -1568,7 +1568,7 @@ fn candidate_should_be_dropped_in_favor_of(
// This is a fix for #53123 and prevents winnowing from accidentally extending the
// lifetime of a variable.
match (&other.candidate, &victim.candidate) {
(_, AutoImplCandidate(..)) | (AutoImplCandidate(..), _) => {
(_, AutoImplCandidate) | (AutoImplCandidate, _) => {
bug!(
"default implementations shouldn't be recorded \
when there are other valid candidates"
@ -1638,7 +1638,7 @@ fn candidate_should_be_dropped_in_favor_of(
| BuiltinUnsizeCandidate
| TraitUpcastingUnsizeCandidate(_)
| BuiltinCandidate { .. }
| TraitAliasCandidate(..)
| TraitAliasCandidate
| ObjectCandidate(_)
| ProjectionCandidate(..),
) => !is_global(cand),
@ -1656,7 +1656,7 @@ fn candidate_should_be_dropped_in_favor_of(
| BuiltinUnsizeCandidate
| TraitUpcastingUnsizeCandidate(_)
| BuiltinCandidate { has_nested: true }
| TraitAliasCandidate(..),
| TraitAliasCandidate,
ParamCandidate(ref cand),
) => {
// Prefer these to a global where-clause bound
@ -1686,7 +1686,7 @@ fn candidate_should_be_dropped_in_favor_of(
| BuiltinUnsizeCandidate
| TraitUpcastingUnsizeCandidate(_)
| BuiltinCandidate { .. }
| TraitAliasCandidate(..),
| TraitAliasCandidate,
) => true,
(
@ -1698,7 +1698,7 @@ fn candidate_should_be_dropped_in_favor_of(
| BuiltinUnsizeCandidate
| TraitUpcastingUnsizeCandidate(_)
| BuiltinCandidate { .. }
| TraitAliasCandidate(..),
| TraitAliasCandidate,
ObjectCandidate(_) | ProjectionCandidate(..),
) => false,
@ -1779,7 +1779,7 @@ fn candidate_should_be_dropped_in_favor_of(
| BuiltinUnsizeCandidate
| TraitUpcastingUnsizeCandidate(_)
| BuiltinCandidate { has_nested: true }
| TraitAliasCandidate(..),
| TraitAliasCandidate,
ImplCandidate(_)
| ClosureCandidate
| GeneratorCandidate
@ -1788,7 +1788,7 @@ fn candidate_should_be_dropped_in_favor_of(
| BuiltinUnsizeCandidate
| TraitUpcastingUnsizeCandidate(_)
| BuiltinCandidate { has_nested: true }
| TraitAliasCandidate(..),
| TraitAliasCandidate,
) => false,
}
}