Skip to content

Commit 20927d3

Browse files
Remove unnecessary constness from ProjectionCandidate
1 parent e223c41 commit 20927d3

File tree

4 files changed

+12
-19
lines changed

4 files changed

+12
-19
lines changed

compiler/rustc_middle/src/traits/select.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,8 @@ pub enum SelectionCandidate<'tcx> {
125125

126126
/// This is a trait matching with a projected type as `Self`, and we found
127127
/// an applicable bound in the trait definition. The `usize` is an index
128-
/// into the list returned by `tcx.item_bounds`. The constness is the
129-
/// constness of the bound in the trait.
130-
// FIXME(effects) do we need this constness
131-
ProjectionCandidate(usize, ty::BoundConstness),
128+
/// into the list returned by `tcx.item_bounds`.
129+
ProjectionCandidate(usize),
132130

133131
/// Implementation of a `Fn`-family trait by one of the anonymous types
134132
/// generated for an `||` expression.

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
154154
.infcx
155155
.probe(|_| self.match_projection_obligation_against_definition_bounds(obligation));
156156

157-
// FIXME(effects) proper constness needed?
158-
candidates.vec.extend(
159-
result.into_iter().map(|idx| ProjectionCandidate(idx, ty::BoundConstness::NotConst)),
160-
);
157+
candidates.vec.extend(result.into_iter().map(|idx| ProjectionCandidate(idx)));
161158
}
162159

163160
/// Given an obligation like `<SomeTrait for T>`, searches the obligations that the caller
@@ -585,7 +582,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
585582
}
586583

587584
ty::Alias(ty::Opaque, _) => {
588-
if candidates.vec.iter().any(|c| matches!(c, ProjectionCandidate(..))) {
585+
if candidates.vec.iter().any(|c| matches!(c, ProjectionCandidate(_))) {
589586
// We do not generate an auto impl candidate for `impl Trait`s which already
590587
// reference our auto trait.
591588
//

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
7171
ImplSource::Builtin(BuiltinImplSource::Misc, data)
7272
}
7373

74-
ProjectionCandidate(idx, _) => {
74+
ProjectionCandidate(idx) => {
7575
let obligations = self.confirm_projection_candidate(obligation, idx)?;
7676
ImplSource::Param(obligations)
7777
}
@@ -1313,7 +1313,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
13131313
// If we have a projection type, make sure to normalize it so we replace it
13141314
// with a fresh infer variable
13151315
ty::Alias(ty::Projection | ty::Inherent, ..) => {
1316-
// FIXME(effects) this needs constness
13171316
let predicate = normalize_with_depth_to(
13181317
self,
13191318
obligation.param_env,
@@ -1344,7 +1343,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
13441343
// since it's either not `const Drop` (and we raise an error during selection),
13451344
// or it's an ADT (and we need to check for a custom impl during selection)
13461345
_ => {
1347-
// FIXME(effects) this needs constness
13481346
let predicate = self_ty.rebind(ty::TraitPredicate {
13491347
trait_ref: ty::TraitRef::from_lang_item(
13501348
self.tcx(),

compiler/rustc_trait_selection/src/traits/select/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1883,7 +1883,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
18831883
| BuiltinCandidate { .. }
18841884
| TraitAliasCandidate
18851885
| ObjectCandidate(_)
1886-
| ProjectionCandidate(..),
1886+
| ProjectionCandidate(_),
18871887
) => {
18881888
// We have a where clause so don't go around looking
18891889
// for impls. Arbitrarily give param candidates priority
@@ -1893,7 +1893,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
18931893
// here (see issue #50825).
18941894
DropVictim::drop_if(!is_global(other_cand))
18951895
}
1896-
(ObjectCandidate(_) | ProjectionCandidate(..), ParamCandidate(ref victim_cand)) => {
1896+
(ObjectCandidate(_) | ProjectionCandidate(_), ParamCandidate(ref victim_cand)) => {
18971897
// Prefer these to a global where-clause bound
18981898
// (see issue #50825).
18991899
if is_global(victim_cand) { DropVictim::Yes } else { DropVictim::No }
@@ -1921,20 +1921,20 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
19211921
)
19221922
}
19231923

1924-
(ProjectionCandidate(i, _), ProjectionCandidate(j, _))
1924+
(ProjectionCandidate(i), ProjectionCandidate(j))
19251925
| (ObjectCandidate(i), ObjectCandidate(j)) => {
19261926
// Arbitrarily pick the lower numbered candidate for backwards
19271927
// compatibility reasons. Don't let this affect inference.
19281928
DropVictim::drop_if(i < j && !has_non_region_infer)
19291929
}
1930-
(ObjectCandidate(_), ProjectionCandidate(..))
1931-
| (ProjectionCandidate(..), ObjectCandidate(_)) => {
1930+
(ObjectCandidate(_), ProjectionCandidate(_))
1931+
| (ProjectionCandidate(_), ObjectCandidate(_)) => {
19321932
bug!("Have both object and projection candidate")
19331933
}
19341934

19351935
// Arbitrarily give projection and object candidates priority.
19361936
(
1937-
ObjectCandidate(_) | ProjectionCandidate(..),
1937+
ObjectCandidate(_) | ProjectionCandidate(_),
19381938
ImplCandidate(..)
19391939
| AutoImplCandidate
19401940
| ClosureCandidate { .. }
@@ -1964,7 +1964,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
19641964
| TraitUpcastingUnsizeCandidate(_)
19651965
| BuiltinCandidate { .. }
19661966
| TraitAliasCandidate,
1967-
ObjectCandidate(_) | ProjectionCandidate(..),
1967+
ObjectCandidate(_) | ProjectionCandidate(_),
19681968
) => DropVictim::No,
19691969

19701970
(&ImplCandidate(other_def), &ImplCandidate(victim_def)) => {

0 commit comments

Comments
 (0)