Skip to content

Commit

Permalink
TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Apr 26, 2024
1 parent 8a03a02 commit 919007b
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 17 deletions.
11 changes: 5 additions & 6 deletions compiler/rustc_trait_selection/src/solve/assembly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ pub(super) trait GoalKind<'tcx>:
ecx: &mut EvalCtxt<'_, 'tcx>,
goal: Goal<'tcx, Self>,
assumption: ty::Clause<'tcx>,
requirements: impl IntoIterator<Item = Goal<'tcx, ty::Predicate<'tcx>>>,
requirements: impl IntoIterator<Item = (GoalSource, Goal<'tcx, ty::Predicate<'tcx>>)>,
) -> QueryResult<'tcx> {
Self::probe_and_match_goal_against_assumption(ecx, goal, assumption, |ecx| {
// FIXME(-Znext-solver=coinductive): check whether this should be
// `GoalSource::ImplWhereBound` for any caller.
ecx.add_goals(GoalSource::Misc, requirements);
for (source, goal) in requirements {
ecx.add_goal(source, goal);
}
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
})
}
Expand All @@ -83,9 +83,8 @@ pub(super) trait GoalKind<'tcx>:
let ty::Dynamic(bounds, _, _) = *goal.predicate.self_ty().kind() else {
bug!("expected object type in `consider_object_bound_candidate`");
};
// FIXME(-Znext-solver=coinductive): Should this be `GoalSource::ImplWhereBound`?
ecx.add_goals(
GoalSource::Misc,
GoalSource::ImplWhereBound,
structural_traits::predicates_for_object_candidate(
ecx,
goal.param_env,
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_trait_selection/src/solve/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,16 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
fn visit_goal(&mut self, goal: &super::inspect::InspectGoal<'_, 'tcx>) -> Self::Result {
if matches!(goal.source(), GoalSource::ImplWhereBound) {
self.impl_where_bound_count += 1;
} else if self.parent_kind.is_some() {
return ControlFlow::Continue(());
}

if goal.result().is_ok() {
return ControlFlow::Continue(());
}

let candidates = goal.candidates();
// FIXME: We should try to throw out the candidates that are definitely
// not worthwhile, such as param-env and impl candidates whose headers
// won't even unify. We already do this with deep-reject for impls, but
// we shouldn't rely on this for diagnostic correctness.
// FIXME: Throw out candidates that have no failing WC and >1 failing misc goal.
let [candidate] = candidates.as_slice() else {
return ControlFlow::Break(self.parent_obligation.clone());
};
Expand Down
10 changes: 8 additions & 2 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::consider_implied_clause(
ecx,
goal,
pred,
[(GoalSource::ImplWhereBound, goal.with(tcx, output_is_sized_pred))],
)
}

fn consider_builtin_async_fn_trait_candidates(
Expand Down Expand Up @@ -467,7 +472,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
pred,
[goal.with(tcx, output_is_sized_pred)]
.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)),
)
}

Expand Down
10 changes: 8 additions & 2 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::consider_implied_clause(
ecx,
goal,
pred,
[(GoalSource::ImplWhereBound, goal.with(tcx, output_is_sized_pred))],
)
}

fn consider_builtin_async_fn_trait_candidates(
Expand Down Expand Up @@ -351,7 +356,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
pred,
[goal.with(tcx, output_is_sized_pred)]
.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)),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t
LL | foo::<fn() -> str, _>(None, ());
| ^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `str`
= help: within `fn() -> str`, the trait `Sized` is not implemented for `str`, which is required by `fn() -> str: Fn<_>`
= note: required because it appears within the type `fn() -> str`
note: required by a bound in `foo`
--> $DIR/builtin-fn-must-return-sized.rs:10:11
|
Expand Down
1 change: 1 addition & 0 deletions tests/ui/traits/next-solver/more-object-bound.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ error[E0271]: type mismatch resolving `<dyn Trait<A = A, B = B> as SuperTrait>::
LL | foo::<A, B, dyn Trait<A = A, B = B>>(x)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ
|
= note: required because it appears within the type `dyn Trait<A = A, B = B>`
note: required by a bound in `foo`
--> $DIR/more-object-bound.rs:18:8
|
Expand Down
5 changes: 3 additions & 2 deletions tests/ui/traits/next-solver/object-unsafety.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
error[E0277]: the trait bound `T: Copy` is not satisfied
error[E0277]: the trait bound `T: Copy` is not satisfied in `dyn Setup<From = T>`
--> $DIR/object-unsafety.rs:12:12
|
LL | copy::<dyn Setup<From=T>>(t)
| ^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T`
| ^^^^^^^^^^^^^^^^^ within `dyn Setup<From = T>`, the trait `Copy` is not implemented for `T`, which is required by `dyn Setup<From = T>: Setup`
|
= note: required because it appears within the type `dyn Setup<From = T>`
note: required by a bound in `copy`
--> $DIR/object-unsafety.rs:7:12
|
Expand Down

0 comments on commit 919007b

Please sign in to comment.