Migrate predicates_of and caller_bounds to Clause

This commit is contained in:
Michael Goulet
2023-06-22 18:17:13 +00:00
parent 36fb58e433
commit fbdef58414
77 changed files with 478 additions and 705 deletions

View File

@@ -469,13 +469,11 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
candidates: &mut Vec<Candidate<'tcx>>,
) {
for (i, assumption) in goal.param_env.caller_bounds().iter().enumerate() {
if let Some(clause) = assumption.as_clause() {
match G::consider_implied_clause(self, goal, clause, []) {
Ok(result) => {
candidates.push(Candidate { source: CandidateSource::ParamEnv(i), result })
}
Err(NoSolution) => (),
match G::consider_implied_clause(self, goal, assumption, []) {
Ok(result) => {
candidates.push(Candidate { source: CandidateSource::ParamEnv(i), result })
}
Err(NoSolution) => (),
}
}
}
@@ -685,19 +683,15 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
// since that'll cause ambiguity.
//
// We can remove this when we have implemented lifetime intersections in responses.
if assumption.to_opt_poly_projection_pred().is_some()
&& !own_bounds.contains(&assumption)
{
if assumption.as_projection_clause().is_some() && !own_bounds.contains(&assumption) {
continue;
}
if let Some(clause) = assumption.as_clause() {
match G::consider_object_bound_candidate(self, goal, clause) {
Ok(result) => {
candidates.push(Candidate { source: CandidateSource::BuiltinImpl, result })
}
Err(NoSolution) => (),
match G::consider_object_bound_candidate(self, goal, assumption) {
Ok(result) => {
candidates.push(Candidate { source: CandidateSource::BuiltinImpl, result })
}
Err(NoSolution) => (),
}
}
}

View File

@@ -343,7 +343,7 @@ pub(in crate::solve) fn predicates_for_object_candidate<'tcx>(
param_env: ty::ParamEnv<'tcx>,
trait_ref: ty::TraitRef<'tcx>,
object_bound: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
) -> Vec<ty::Predicate<'tcx>> {
) -> Vec<ty::Clause<'tcx>> {
let tcx = ecx.tcx();
let mut requirements = vec![];
requirements.extend(
@@ -353,11 +353,7 @@ pub(in crate::solve) fn predicates_for_object_candidate<'tcx>(
// FIXME(associated_const_equality): Also add associated consts to
// the requirements here.
if item.kind == ty::AssocKind::Type {
requirements.extend(
tcx.item_bounds(item.def_id)
.subst_iter(tcx, trait_ref.substs)
.map(|clause| clause.as_predicate()),
);
requirements.extend(tcx.item_bounds(item.def_id).subst_iter(tcx, trait_ref.substs));
}
}