Record more kinds of things as impl where bounds

This commit is contained in:
Michael Goulet 2024-05-01 15:58:51 -04:00
parent 6e3808e274
commit 382d0f73ad
3 changed files with 13 additions and 12 deletions

View File

@ -58,15 +58,15 @@ pub(super) trait GoalKind<'tcx>:
/// goal by equating it with the assumption. /// goal by equating it with the assumption.
fn probe_and_consider_implied_clause( fn probe_and_consider_implied_clause(
ecx: &mut EvalCtxt<'_, 'tcx>, ecx: &mut EvalCtxt<'_, 'tcx>,
source: CandidateSource, parent_source: CandidateSource,
goal: Goal<'tcx, Self>, goal: Goal<'tcx, Self>,
assumption: ty::Clause<'tcx>, assumption: ty::Clause<'tcx>,
requirements: impl IntoIterator<Item = Goal<'tcx, ty::Predicate<'tcx>>>, requirements: impl IntoIterator<Item = (GoalSource, Goal<'tcx, ty::Predicate<'tcx>>)>,
) -> Result<Candidate<'tcx>, NoSolution> { ) -> Result<Candidate<'tcx>, NoSolution> {
Self::probe_and_match_goal_against_assumption(ecx, source, goal, assumption, |ecx| { Self::probe_and_match_goal_against_assumption(ecx, parent_source, goal, assumption, |ecx| {
// FIXME(-Znext-solver=coinductive): check whether this should be for (nested_source, goal) in requirements {
// `GoalSource::ImplWhereBound` for any caller. ecx.add_goal(nested_source, goal);
ecx.add_goals(GoalSource::Misc, requirements); }
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
}) })
} }
@ -85,9 +85,8 @@ pub(super) trait GoalKind<'tcx>:
let ty::Dynamic(bounds, _, _) = *goal.predicate.self_ty().kind() else { let ty::Dynamic(bounds, _, _) = *goal.predicate.self_ty().kind() else {
bug!("expected object type in `probe_and_consider_object_bound_candidate`"); bug!("expected object type in `probe_and_consider_object_bound_candidate`");
}; };
// FIXME(-Znext-solver=coinductive): Should this be `GoalSource::ImplWhereBound`?
ecx.add_goals( ecx.add_goals(
GoalSource::Misc, GoalSource::ImplWhereBound,
structural_traits::predicates_for_object_candidate( structural_traits::predicates_for_object_candidate(
ecx, ecx,
goal.param_env, goal.param_env,

View File

@ -389,7 +389,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
CandidateSource::BuiltinImpl(BuiltinImplSource::Misc), CandidateSource::BuiltinImpl(BuiltinImplSource::Misc),
goal, goal,
pred, pred,
[goal.with(tcx, output_is_sized_pred)], [(GoalSource::ImplWhereBound, goal.with(tcx, output_is_sized_pred))],
) )
} }
@ -473,7 +473,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
pred, pred,
[goal.with(tcx, output_is_sized_pred)] [goal.with(tcx, output_is_sized_pred)]
.into_iter() .into_iter()
.chain(nested_preds.into_iter().map(|pred| goal.with(tcx, pred))), .chain(nested_preds.into_iter().map(|pred| goal.with(tcx, pred)))
.map(|goal| (GoalSource::ImplWhereBound, goal)),
) )
} }

View File

@ -321,7 +321,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
CandidateSource::BuiltinImpl(BuiltinImplSource::Misc), CandidateSource::BuiltinImpl(BuiltinImplSource::Misc),
goal, goal,
pred, pred,
[goal.with(tcx, output_is_sized_pred)], [(GoalSource::ImplWhereBound, goal.with(tcx, output_is_sized_pred))],
) )
} }
@ -367,7 +367,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
pred, pred,
[goal.with(tcx, output_is_sized_pred)] [goal.with(tcx, output_is_sized_pred)]
.into_iter() .into_iter()
.chain(nested_preds.into_iter().map(|pred| goal.with(tcx, pred))), .chain(nested_preds.into_iter().map(|pred| goal.with(tcx, pred)))
.map(|goal| (GoalSource::ImplWhereBound, goal)),
) )
} }