Remove default trait RPITIT candidates
This commit is contained in:
parent
3eb5c4581a
commit
be55ad53a1
@ -90,15 +90,7 @@ enum ProjectionCandidate<'tcx> {
|
|||||||
/// From an "impl" (or a "pseudo-impl" returned by select)
|
/// From an "impl" (or a "pseudo-impl" returned by select)
|
||||||
Select(Selection<'tcx>),
|
Select(Selection<'tcx>),
|
||||||
|
|
||||||
ImplTraitInTrait(ImplTraitInTraitCandidate<'tcx>),
|
ImplTraitInTrait(ImplSourceUserDefinedData<'tcx, PredicateObligation<'tcx>>),
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Debug)]
|
|
||||||
enum ImplTraitInTraitCandidate<'tcx> {
|
|
||||||
// The `impl Trait` from a trait function's default body
|
|
||||||
Trait,
|
|
||||||
// A concrete type provided from a trait's `impl Trait` from an impl
|
|
||||||
Impl(ImplSourceUserDefinedData<'tcx, PredicateObligation<'tcx>>),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ProjectionCandidateSet<'tcx> {
|
enum ProjectionCandidateSet<'tcx> {
|
||||||
@ -1292,17 +1284,6 @@ fn assemble_candidate_for_impl_trait_in_trait<'cx, 'tcx>(
|
|||||||
let tcx = selcx.tcx();
|
let tcx = selcx.tcx();
|
||||||
if tcx.def_kind(obligation.predicate.def_id) == DefKind::ImplTraitPlaceholder {
|
if tcx.def_kind(obligation.predicate.def_id) == DefKind::ImplTraitPlaceholder {
|
||||||
let trait_fn_def_id = tcx.impl_trait_in_trait_parent(obligation.predicate.def_id);
|
let trait_fn_def_id = tcx.impl_trait_in_trait_parent(obligation.predicate.def_id);
|
||||||
// If we are trying to project an RPITIT with trait's default `Self` parameter,
|
|
||||||
// then we must be within a default trait body.
|
|
||||||
if obligation.predicate.self_ty()
|
|
||||||
== ty::InternalSubsts::identity_for_item(tcx, obligation.predicate.def_id).type_at(0)
|
|
||||||
&& tcx.associated_item(trait_fn_def_id).defaultness(tcx).has_value()
|
|
||||||
{
|
|
||||||
candidate_set.push_candidate(ProjectionCandidate::ImplTraitInTrait(
|
|
||||||
ImplTraitInTraitCandidate::Trait,
|
|
||||||
));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let trait_def_id = tcx.parent(trait_fn_def_id);
|
let trait_def_id = tcx.parent(trait_fn_def_id);
|
||||||
let trait_substs =
|
let trait_substs =
|
||||||
@ -1313,9 +1294,7 @@ fn assemble_candidate_for_impl_trait_in_trait<'cx, 'tcx>(
|
|||||||
let _ = selcx.infcx.commit_if_ok(|_| {
|
let _ = selcx.infcx.commit_if_ok(|_| {
|
||||||
match selcx.select(&obligation.with(tcx, trait_predicate)) {
|
match selcx.select(&obligation.with(tcx, trait_predicate)) {
|
||||||
Ok(Some(super::ImplSource::UserDefined(data))) => {
|
Ok(Some(super::ImplSource::UserDefined(data))) => {
|
||||||
candidate_set.push_candidate(ProjectionCandidate::ImplTraitInTrait(
|
candidate_set.push_candidate(ProjectionCandidate::ImplTraitInTrait(data));
|
||||||
ImplTraitInTraitCandidate::Impl(data),
|
|
||||||
));
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
@ -1777,18 +1756,9 @@ fn confirm_candidate<'cx, 'tcx>(
|
|||||||
ProjectionCandidate::Select(impl_source) => {
|
ProjectionCandidate::Select(impl_source) => {
|
||||||
confirm_select_candidate(selcx, obligation, impl_source)
|
confirm_select_candidate(selcx, obligation, impl_source)
|
||||||
}
|
}
|
||||||
ProjectionCandidate::ImplTraitInTrait(ImplTraitInTraitCandidate::Impl(data)) => {
|
ProjectionCandidate::ImplTraitInTrait(data) => {
|
||||||
confirm_impl_trait_in_trait_candidate(selcx, obligation, data)
|
confirm_impl_trait_in_trait_candidate(selcx, obligation, data)
|
||||||
}
|
}
|
||||||
// If we're projecting an RPITIT for a default trait body, that's just
|
|
||||||
// the same def-id, but as an opaque type (with regular RPIT semantics).
|
|
||||||
ProjectionCandidate::ImplTraitInTrait(ImplTraitInTraitCandidate::Trait) => Progress {
|
|
||||||
term: selcx
|
|
||||||
.tcx()
|
|
||||||
.mk_opaque(obligation.predicate.def_id, obligation.predicate.substs)
|
|
||||||
.into(),
|
|
||||||
obligations: vec![],
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// When checking for cycle during evaluation, we compare predicates with
|
// When checking for cycle during evaluation, we compare predicates with
|
||||||
|
Loading…
x
Reference in New Issue
Block a user