Rollup merge of #119022 - compiler-errors:no-constness, r=fee1-dead

Remove unnecessary constness from ProjectionCandidate

Constness in an item bound will be represented by an effect param, so no need to record constness here.

r? fee1-dead
This commit is contained in:
Matthias Krüger 2023-12-17 21:30:00 +01:00 committed by GitHub
commit 677bb6cd60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 19 deletions

View File

@ -125,10 +125,8 @@ pub enum SelectionCandidate<'tcx> {
/// This is a trait matching with a projected type as `Self`, and we found /// 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 /// an applicable bound in the trait definition. The `usize` is an index
/// into the list returned by `tcx.item_bounds`. The constness is the /// into the list returned by `tcx.item_bounds`.
/// constness of the bound in the trait. ProjectionCandidate(usize),
// FIXME(effects) do we need this constness
ProjectionCandidate(usize, ty::BoundConstness),
/// Implementation of a `Fn`-family trait by one of the anonymous types /// Implementation of a `Fn`-family trait by one of the anonymous types
/// generated for an `||` expression. /// generated for an `||` expression.

View File

@ -154,10 +154,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
.infcx .infcx
.probe(|_| self.match_projection_obligation_against_definition_bounds(obligation)); .probe(|_| self.match_projection_obligation_against_definition_bounds(obligation));
// FIXME(effects) proper constness needed? candidates.vec.extend(result.into_iter().map(|idx| ProjectionCandidate(idx)));
candidates.vec.extend(
result.into_iter().map(|idx| ProjectionCandidate(idx, ty::BoundConstness::NotConst)),
);
} }
/// Given an obligation like `<SomeTrait for T>`, searches the obligations that the caller /// Given an obligation like `<SomeTrait for T>`, searches the obligations that the caller
@ -585,7 +582,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
} }
ty::Alias(ty::Opaque, _) => { 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 // We do not generate an auto impl candidate for `impl Trait`s which already
// reference our auto trait. // reference our auto trait.
// //

View File

@ -71,7 +71,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ImplSource::Builtin(BuiltinImplSource::Misc, data) ImplSource::Builtin(BuiltinImplSource::Misc, data)
} }
ProjectionCandidate(idx, _) => { ProjectionCandidate(idx) => {
let obligations = self.confirm_projection_candidate(obligation, idx)?; let obligations = self.confirm_projection_candidate(obligation, idx)?;
ImplSource::Param(obligations) ImplSource::Param(obligations)
} }
@ -1313,7 +1313,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// If we have a projection type, make sure to normalize it so we replace it // If we have a projection type, make sure to normalize it so we replace it
// with a fresh infer variable // with a fresh infer variable
ty::Alias(ty::Projection | ty::Inherent, ..) => { ty::Alias(ty::Projection | ty::Inherent, ..) => {
// FIXME(effects) this needs constness
let predicate = normalize_with_depth_to( let predicate = normalize_with_depth_to(
self, self,
obligation.param_env, obligation.param_env,
@ -1344,7 +1343,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// since it's either not `const Drop` (and we raise an error during selection), // 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) // 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 { let predicate = self_ty.rebind(ty::TraitPredicate {
trait_ref: ty::TraitRef::from_lang_item( trait_ref: ty::TraitRef::from_lang_item(
self.tcx(), self.tcx(),

View File

@ -1883,7 +1883,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
| BuiltinCandidate { .. } | BuiltinCandidate { .. }
| TraitAliasCandidate | TraitAliasCandidate
| ObjectCandidate(_) | ObjectCandidate(_)
| ProjectionCandidate(..), | ProjectionCandidate(_),
) => { ) => {
// We have a where clause so don't go around looking // We have a where clause so don't go around looking
// for impls. Arbitrarily give param candidates priority // for impls. Arbitrarily give param candidates priority
@ -1893,7 +1893,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
// here (see issue #50825). // here (see issue #50825).
DropVictim::drop_if(!is_global(other_cand)) 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 // Prefer these to a global where-clause bound
// (see issue #50825). // (see issue #50825).
if is_global(victim_cand) { DropVictim::Yes } else { DropVictim::No } if is_global(victim_cand) { DropVictim::Yes } else { DropVictim::No }
@ -1921,20 +1921,20 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
) )
} }
(ProjectionCandidate(i, _), ProjectionCandidate(j, _)) (ProjectionCandidate(i), ProjectionCandidate(j))
| (ObjectCandidate(i), ObjectCandidate(j)) => { | (ObjectCandidate(i), ObjectCandidate(j)) => {
// Arbitrarily pick the lower numbered candidate for backwards // Arbitrarily pick the lower numbered candidate for backwards
// compatibility reasons. Don't let this affect inference. // compatibility reasons. Don't let this affect inference.
DropVictim::drop_if(i < j && !has_non_region_infer) DropVictim::drop_if(i < j && !has_non_region_infer)
} }
(ObjectCandidate(_), ProjectionCandidate(..)) (ObjectCandidate(_), ProjectionCandidate(_))
| (ProjectionCandidate(..), ObjectCandidate(_)) => { | (ProjectionCandidate(_), ObjectCandidate(_)) => {
bug!("Have both object and projection candidate") bug!("Have both object and projection candidate")
} }
// Arbitrarily give projection and object candidates priority. // Arbitrarily give projection and object candidates priority.
( (
ObjectCandidate(_) | ProjectionCandidate(..), ObjectCandidate(_) | ProjectionCandidate(_),
ImplCandidate(..) ImplCandidate(..)
| AutoImplCandidate | AutoImplCandidate
| ClosureCandidate { .. } | ClosureCandidate { .. }
@ -1964,7 +1964,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
| TraitUpcastingUnsizeCandidate(_) | TraitUpcastingUnsizeCandidate(_)
| BuiltinCandidate { .. } | BuiltinCandidate { .. }
| TraitAliasCandidate, | TraitAliasCandidate,
ObjectCandidate(_) | ProjectionCandidate(..), ObjectCandidate(_) | ProjectionCandidate(_),
) => DropVictim::No, ) => DropVictim::No,
(&ImplCandidate(other_def), &ImplCandidate(victim_def)) => { (&ImplCandidate(other_def), &ImplCandidate(victim_def)) => {