1
Fork 0

replace chain with two add_goal

This commit is contained in:
Boxy 2023-03-17 14:35:12 +00:00
parent aa8de17928
commit e624ef4d64

View file

@ -342,23 +342,18 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
let Some(sized_def_id) = tcx.lang_items().sized_trait() else { let Some(sized_def_id) = tcx.lang_items().sized_trait() else {
return Err(NoSolution); return Err(NoSolution);
}; };
ecx.add_goals(
data.iter()
// Check that the type implements all of the predicates of the def-id. // Check that the type implements all of the predicates of the def-id.
// (i.e. the principal, all of the associated types match, and any auto traits) // (i.e. the principal, all of the associated types match, and any auto traits)
.map(|pred| goal.with(tcx, pred.with_self_ty(tcx, a_ty))) ecx.add_goals(
.chain([ data.iter().map(|pred| goal.with(tcx, pred.with_self_ty(tcx, a_ty))),
);
// The type must be Sized to be unsized. // The type must be Sized to be unsized.
goal.with( ecx.add_goal(
tcx, goal.with(tcx, ty::Binder::dummy(tcx.mk_trait_ref(sized_def_id, [a_ty]))),
ty::Binder::dummy(tcx.mk_trait_ref(sized_def_id, [a_ty])), );
),
// The type must outlive the lifetime of the `dyn` we're unsizing into. // The type must outlive the lifetime of the `dyn` we're unsizing into.
goal.with( ecx.add_goal(
tcx, goal.with(tcx, ty::Binder::dummy(ty::OutlivesPredicate(a_ty, region))),
ty::Binder::dummy(ty::OutlivesPredicate(a_ty, region)),
),
]),
); );
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
} }