Remove unnecessary constness from ProjectionCandidate
This commit is contained in:
parent
e223c41028
commit
20927d3956
@ -125,10 +125,8 @@ pub enum SelectionCandidate<'tcx> {
|
||||
|
||||
/// 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
|
||||
/// into the list returned by `tcx.item_bounds`. The constness is the
|
||||
/// constness of the bound in the trait.
|
||||
// FIXME(effects) do we need this constness
|
||||
ProjectionCandidate(usize, ty::BoundConstness),
|
||||
/// into the list returned by `tcx.item_bounds`.
|
||||
ProjectionCandidate(usize),
|
||||
|
||||
/// Implementation of a `Fn`-family trait by one of the anonymous types
|
||||
/// generated for an `||` expression.
|
||||
|
@ -154,10 +154,7 @@ fn assemble_candidates_from_projected_tys(
|
||||
.infcx
|
||||
.probe(|_| self.match_projection_obligation_against_definition_bounds(obligation));
|
||||
|
||||
// FIXME(effects) proper constness needed?
|
||||
candidates.vec.extend(
|
||||
result.into_iter().map(|idx| ProjectionCandidate(idx, ty::BoundConstness::NotConst)),
|
||||
);
|
||||
candidates.vec.extend(result.into_iter().map(|idx| ProjectionCandidate(idx)));
|
||||
}
|
||||
|
||||
/// Given an obligation like `<SomeTrait for T>`, searches the obligations that the caller
|
||||
@ -585,7 +582,7 @@ fn assemble_candidates_from_auto_impls(
|
||||
}
|
||||
|
||||
ty::Alias(ty::Opaque, _) => {
|
||||
if candidates.vec.iter().any(|c| matches!(c, ProjectionCandidate(..))) {
|
||||
if candidates.vec.iter().any(|c| matches!(c, ProjectionCandidate(_))) {
|
||||
// We do not generate an auto impl candidate for `impl Trait`s which already
|
||||
// reference our auto trait.
|
||||
//
|
||||
|
@ -71,7 +71,7 @@ pub(super) fn confirm_candidate(
|
||||
ImplSource::Builtin(BuiltinImplSource::Misc, data)
|
||||
}
|
||||
|
||||
ProjectionCandidate(idx, _) => {
|
||||
ProjectionCandidate(idx) => {
|
||||
let obligations = self.confirm_projection_candidate(obligation, idx)?;
|
||||
ImplSource::Param(obligations)
|
||||
}
|
||||
@ -1313,7 +1313,6 @@ fn confirm_const_destruct_candidate(
|
||||
// If we have a projection type, make sure to normalize it so we replace it
|
||||
// with a fresh infer variable
|
||||
ty::Alias(ty::Projection | ty::Inherent, ..) => {
|
||||
// FIXME(effects) this needs constness
|
||||
let predicate = normalize_with_depth_to(
|
||||
self,
|
||||
obligation.param_env,
|
||||
@ -1344,7 +1343,6 @@ fn confirm_const_destruct_candidate(
|
||||
// since it's either not `const Drop` (and we raise an error during selection),
|
||||
// or it's an ADT (and we need to check for a custom impl during selection)
|
||||
_ => {
|
||||
// FIXME(effects) this needs constness
|
||||
let predicate = self_ty.rebind(ty::TraitPredicate {
|
||||
trait_ref: ty::TraitRef::from_lang_item(
|
||||
self.tcx(),
|
||||
|
@ -1883,7 +1883,7 @@ fn candidate_should_be_dropped_in_favor_of(
|
||||
| BuiltinCandidate { .. }
|
||||
| TraitAliasCandidate
|
||||
| ObjectCandidate(_)
|
||||
| ProjectionCandidate(..),
|
||||
| ProjectionCandidate(_),
|
||||
) => {
|
||||
// We have a where clause so don't go around looking
|
||||
// for impls. Arbitrarily give param candidates priority
|
||||
@ -1893,7 +1893,7 @@ fn candidate_should_be_dropped_in_favor_of(
|
||||
// here (see issue #50825).
|
||||
DropVictim::drop_if(!is_global(other_cand))
|
||||
}
|
||||
(ObjectCandidate(_) | ProjectionCandidate(..), ParamCandidate(ref victim_cand)) => {
|
||||
(ObjectCandidate(_) | ProjectionCandidate(_), ParamCandidate(ref victim_cand)) => {
|
||||
// Prefer these to a global where-clause bound
|
||||
// (see issue #50825).
|
||||
if is_global(victim_cand) { DropVictim::Yes } else { DropVictim::No }
|
||||
@ -1921,20 +1921,20 @@ fn candidate_should_be_dropped_in_favor_of(
|
||||
)
|
||||
}
|
||||
|
||||
(ProjectionCandidate(i, _), ProjectionCandidate(j, _))
|
||||
(ProjectionCandidate(i), ProjectionCandidate(j))
|
||||
| (ObjectCandidate(i), ObjectCandidate(j)) => {
|
||||
// Arbitrarily pick the lower numbered candidate for backwards
|
||||
// compatibility reasons. Don't let this affect inference.
|
||||
DropVictim::drop_if(i < j && !has_non_region_infer)
|
||||
}
|
||||
(ObjectCandidate(_), ProjectionCandidate(..))
|
||||
| (ProjectionCandidate(..), ObjectCandidate(_)) => {
|
||||
(ObjectCandidate(_), ProjectionCandidate(_))
|
||||
| (ProjectionCandidate(_), ObjectCandidate(_)) => {
|
||||
bug!("Have both object and projection candidate")
|
||||
}
|
||||
|
||||
// Arbitrarily give projection and object candidates priority.
|
||||
(
|
||||
ObjectCandidate(_) | ProjectionCandidate(..),
|
||||
ObjectCandidate(_) | ProjectionCandidate(_),
|
||||
ImplCandidate(..)
|
||||
| AutoImplCandidate
|
||||
| ClosureCandidate { .. }
|
||||
@ -1964,7 +1964,7 @@ fn candidate_should_be_dropped_in_favor_of(
|
||||
| TraitUpcastingUnsizeCandidate(_)
|
||||
| BuiltinCandidate { .. }
|
||||
| TraitAliasCandidate,
|
||||
ObjectCandidate(_) | ProjectionCandidate(..),
|
||||
ObjectCandidate(_) | ProjectionCandidate(_),
|
||||
) => DropVictim::No,
|
||||
|
||||
(&ImplCandidate(other_def), &ImplCandidate(victim_def)) => {
|
||||
|
Loading…
Reference in New Issue
Block a user