Skip to content

Commit

Permalink
Make names more accurate
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Apr 29, 2024
1 parent 7a58674 commit 5776aec
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
18 changes: 11 additions & 7 deletions compiler/rustc_trait_selection/src/solve/assembly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub(super) trait GoalKind<'tcx>:
/// Consider a clause, which consists of a "assumption" and some "requirements",
/// to satisfy a goal. If the requirements hold, then attempt to satisfy our
/// goal by equating it with the assumption.
fn consider_implied_clause(
fn probe_and_consider_implied_clause(
ecx: &mut EvalCtxt<'_, 'tcx>,
goal: Goal<'tcx, Self>,
assumption: ty::Clause<'tcx>,
Expand All @@ -73,15 +73,15 @@ pub(super) trait GoalKind<'tcx>:
/// Consider a clause specifically for a `dyn Trait` self type. This requires
/// additionally checking all of the supertraits and object bounds to hold,
/// since they're not implied by the well-formedness of the object type.
fn consider_object_bound_candidate(
fn probe_and_consider_object_bound_candidate(
ecx: &mut EvalCtxt<'_, 'tcx>,
goal: Goal<'tcx, Self>,
assumption: ty::Clause<'tcx>,
) -> QueryResult<'tcx> {
Self::probe_and_match_goal_against_assumption(ecx, goal, assumption, |ecx| {
let tcx = ecx.tcx();
let ty::Dynamic(bounds, _, _) = *goal.predicate.self_ty().kind() else {
bug!("expected object type in `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(
Expand Down Expand Up @@ -557,7 +557,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
candidates: &mut Vec<Candidate<'tcx>>,
) {
for (i, assumption) in goal.param_env.caller_bounds().iter().enumerate() {
match G::consider_implied_clause(self, goal, assumption, []) {
match G::probe_and_consider_implied_clause(self, goal, assumption, []) {
Ok(result) => {
candidates.push(Candidate { source: CandidateSource::ParamEnv(i), result })
}
Expand Down Expand Up @@ -648,7 +648,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
for assumption in
self.tcx().item_bounds(alias_ty.def_id).instantiate(self.tcx(), alias_ty.args)
{
match G::consider_implied_clause(self, goal, assumption, []) {
match G::probe_and_consider_implied_clause(self, goal, assumption, []) {
Ok(result) => {
candidates.push(Candidate { source: CandidateSource::AliasBound, result });
}
Expand Down Expand Up @@ -728,7 +728,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
}
ty::ExistentialPredicate::Projection(_)
| ty::ExistentialPredicate::AutoTrait(_) => {
match G::consider_object_bound_candidate(
match G::probe_and_consider_object_bound_candidate(
self,
goal,
bound.with_self_ty(tcx, self_ty),
Expand All @@ -749,7 +749,11 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
if let Some(principal) = bounds.principal() {
let principal_trait_ref = principal.with_self_ty(tcx, self_ty);
self.walk_vtable(principal_trait_ref, |ecx, assumption, vtable_base, _| {
match G::consider_object_bound_candidate(ecx, goal, assumption.to_predicate(tcx)) {
match G::probe_and_consider_object_bound_candidate(
ecx,
goal,
assumption.to_predicate(tcx),
) {
Ok(result) => candidates.push(Candidate {
source: CandidateSource::BuiltinImpl(BuiltinImplSource::Object {
vtable_base,
Expand Down
15 changes: 10 additions & 5 deletions compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,12 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {

// A built-in `Fn` impl only holds if the output is sized.
// (FIXME: technically we only need to check this if the type is a fn ptr...)
Self::consider_implied_clause(ecx, goal, pred, [goal.with(tcx, output_is_sized_pred)])
Self::probe_and_consider_implied_clause(
ecx,
goal,
pred,
[goal.with(tcx, output_is_sized_pred)],
)
}

fn consider_builtin_async_fn_trait_candidates(
Expand Down Expand Up @@ -461,7 +466,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {

// A built-in `AsyncFn` impl only holds if the output is sized.
// (FIXME: technically we only need to check this if the type is a fn ptr...)
Self::consider_implied_clause(
Self::probe_and_consider_implied_clause(
ecx,
goal,
pred,
Expand Down Expand Up @@ -623,7 +628,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {

let term = args.as_coroutine().return_ty().into();

Self::consider_implied_clause(
Self::probe_and_consider_implied_clause(
ecx,
goal,
ty::ProjectionPredicate {
Expand Down Expand Up @@ -654,7 +659,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {

let term = args.as_coroutine().yield_ty().into();

Self::consider_implied_clause(
Self::probe_and_consider_implied_clause(
ecx,
goal,
ty::ProjectionPredicate {
Expand Down Expand Up @@ -737,7 +742,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
bug!("unexpected associated item `<{self_ty} as Coroutine>::{name}`")
};

Self::consider_implied_clause(
Self::probe_and_consider_implied_clause(
ecx,
goal,
ty::ProjectionPredicate {
Expand Down
11 changes: 8 additions & 3 deletions compiler/rustc_trait_selection/src/solve/trait_goals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,12 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
.to_predicate(tcx);
// A built-in `Fn` impl only holds if the output is sized.
// (FIXME: technically we only need to check this if the type is a fn ptr...)
Self::consider_implied_clause(ecx, goal, pred, [goal.with(tcx, output_is_sized_pred)])
Self::probe_and_consider_implied_clause(
ecx,
goal,
pred,
[goal.with(tcx, output_is_sized_pred)],
)
}

fn consider_builtin_async_fn_trait_candidates(
Expand Down Expand Up @@ -345,7 +350,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
.to_predicate(tcx);
// A built-in `AsyncFn` impl only holds if the output is sized.
// (FIXME: technically we only need to check this if the type is a fn ptr...)
Self::consider_implied_clause(
Self::probe_and_consider_implied_clause(
ecx,
goal,
pred,
Expand Down Expand Up @@ -521,7 +526,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
}

let coroutine = args.as_coroutine();
Self::consider_implied_clause(
Self::probe_and_consider_implied_clause(
ecx,
goal,
ty::TraitRef::new(tcx, goal.predicate.def_id(), [self_ty, coroutine.resume_ty()])
Expand Down

0 comments on commit 5776aec

Please sign in to comment.