Skip to content

Commit 919007b

Browse files
TODO
1 parent 8a03a02 commit 919007b

File tree

7 files changed

+30
-17
lines changed

7 files changed

+30
-17
lines changed

Diff for: compiler/rustc_trait_selection/src/solve/assembly/mod.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ pub(super) trait GoalKind<'tcx>:
6060
ecx: &mut EvalCtxt<'_, 'tcx>,
6161
goal: Goal<'tcx, Self>,
6262
assumption: ty::Clause<'tcx>,
63-
requirements: impl IntoIterator<Item = Goal<'tcx, ty::Predicate<'tcx>>>,
63+
requirements: impl IntoIterator<Item = (GoalSource, Goal<'tcx, ty::Predicate<'tcx>>)>,
6464
) -> QueryResult<'tcx> {
6565
Self::probe_and_match_goal_against_assumption(ecx, goal, assumption, |ecx| {
66-
// FIXME(-Znext-solver=coinductive): check whether this should be
67-
// `GoalSource::ImplWhereBound` for any caller.
68-
ecx.add_goals(GoalSource::Misc, requirements);
66+
for (source, goal) in requirements {
67+
ecx.add_goal(source, goal);
68+
}
6969
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
7070
})
7171
}
@@ -83,9 +83,8 @@ pub(super) trait GoalKind<'tcx>:
8383
let ty::Dynamic(bounds, _, _) = *goal.predicate.self_ty().kind() else {
8484
bug!("expected object type in `consider_object_bound_candidate`");
8585
};
86-
// FIXME(-Znext-solver=coinductive): Should this be `GoalSource::ImplWhereBound`?
8786
ecx.add_goals(
88-
GoalSource::Misc,
87+
GoalSource::ImplWhereBound,
8988
structural_traits::predicates_for_object_candidate(
9089
ecx,
9190
goal.param_env,

Diff for: compiler/rustc_trait_selection/src/solve/fulfill.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -315,17 +315,16 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
315315
fn visit_goal(&mut self, goal: &super::inspect::InspectGoal<'_, 'tcx>) -> Self::Result {
316316
if matches!(goal.source(), GoalSource::ImplWhereBound) {
317317
self.impl_where_bound_count += 1;
318+
} else if self.parent_kind.is_some() {
319+
return ControlFlow::Continue(());
318320
}
319321

320322
if goal.result().is_ok() {
321323
return ControlFlow::Continue(());
322324
}
323325

324326
let candidates = goal.candidates();
325-
// FIXME: We should try to throw out the candidates that are definitely
326-
// not worthwhile, such as param-env and impl candidates whose headers
327-
// won't even unify. We already do this with deep-reject for impls, but
328-
// we shouldn't rely on this for diagnostic correctness.
327+
// FIXME: Throw out candidates that have no failing WC and >1 failing misc goal.
329328
let [candidate] = candidates.as_slice() else {
330329
return ControlFlow::Break(self.parent_obligation.clone());
331330
};

Diff for: compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,12 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
385385

386386
// A built-in `Fn` impl only holds if the output is sized.
387387
// (FIXME: technically we only need to check this if the type is a fn ptr...)
388-
Self::consider_implied_clause(ecx, goal, pred, [goal.with(tcx, output_is_sized_pred)])
388+
Self::consider_implied_clause(
389+
ecx,
390+
goal,
391+
pred,
392+
[(GoalSource::ImplWhereBound, goal.with(tcx, output_is_sized_pred))],
393+
)
389394
}
390395

391396
fn consider_builtin_async_fn_trait_candidates(
@@ -467,7 +472,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
467472
pred,
468473
[goal.with(tcx, output_is_sized_pred)]
469474
.into_iter()
470-
.chain(nested_preds.into_iter().map(|pred| goal.with(tcx, pred))),
475+
.chain(nested_preds.into_iter().map(|pred| goal.with(tcx, pred)))
476+
.map(|goal| (GoalSource::ImplWhereBound, goal)),
471477
)
472478
}
473479

Diff for: compiler/rustc_trait_selection/src/solve/trait_goals.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,12 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
307307
.to_predicate(tcx);
308308
// A built-in `Fn` impl only holds if the output is sized.
309309
// (FIXME: technically we only need to check this if the type is a fn ptr...)
310-
Self::consider_implied_clause(ecx, goal, pred, [goal.with(tcx, output_is_sized_pred)])
310+
Self::consider_implied_clause(
311+
ecx,
312+
goal,
313+
pred,
314+
[(GoalSource::ImplWhereBound, goal.with(tcx, output_is_sized_pred))],
315+
)
311316
}
312317

313318
fn consider_builtin_async_fn_trait_candidates(
@@ -351,7 +356,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
351356
pred,
352357
[goal.with(tcx, output_is_sized_pred)]
353358
.into_iter()
354-
.chain(nested_preds.into_iter().map(|pred| goal.with(tcx, pred))),
359+
.chain(nested_preds.into_iter().map(|pred| goal.with(tcx, pred)))
360+
.map(|goal| (GoalSource::ImplWhereBound, goal)),
355361
)
356362
}
357363

Diff for: tests/ui/traits/next-solver/builtin-fn-must-return-sized.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t
44
LL | foo::<fn() -> str, _>(None, ());
55
| ^^^^^^^^^^^ doesn't have a size known at compile-time
66
|
7-
= help: the trait `Sized` is not implemented for `str`
7+
= help: within `fn() -> str`, the trait `Sized` is not implemented for `str`, which is required by `fn() -> str: Fn<_>`
8+
= note: required because it appears within the type `fn() -> str`
89
note: required by a bound in `foo`
910
--> $DIR/builtin-fn-must-return-sized.rs:10:11
1011
|

Diff for: tests/ui/traits/next-solver/more-object-bound.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ error[E0271]: type mismatch resolving `<dyn Trait<A = A, B = B> as SuperTrait>::
44
LL | foo::<A, B, dyn Trait<A = A, B = B>>(x)
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ
66
|
7+
= note: required because it appears within the type `dyn Trait<A = A, B = B>`
78
note: required by a bound in `foo`
89
--> $DIR/more-object-bound.rs:18:8
910
|

Diff for: tests/ui/traits/next-solver/object-unsafety.stderr

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
error[E0277]: the trait bound `T: Copy` is not satisfied
1+
error[E0277]: the trait bound `T: Copy` is not satisfied in `dyn Setup<From = T>`
22
--> $DIR/object-unsafety.rs:12:12
33
|
44
LL | copy::<dyn Setup<From=T>>(t)
5-
| ^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T`
5+
| ^^^^^^^^^^^^^^^^^ within `dyn Setup<From = T>`, the trait `Copy` is not implemented for `T`, which is required by `dyn Setup<From = T>: Setup`
66
|
7+
= note: required because it appears within the type `dyn Setup<From = T>`
78
note: required by a bound in `copy`
89
--> $DIR/object-unsafety.rs:7:12
910
|

0 commit comments

Comments
 (0)