Skip to content

Commit de50a86

Browse files
committed
Simplify discriminant_kind goal using new helper function
1 parent 5fd4f5b commit de50a86

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

compiler/rustc_trait_selection/src/solve/project_goals.rs

+7-14
Original file line numberDiff line numberDiff line change
@@ -586,20 +586,13 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
586586
ecx: &mut EvalCtxt<'_, 'tcx>,
587587
goal: Goal<'tcx, Self>,
588588
) -> QueryResult<'tcx> {
589-
let self_ty = goal.predicate.self_ty();
590-
591-
let tcx = ecx.tcx();
592-
let term = self_ty.discriminant_ty(tcx).into();
593-
594-
Self::consider_assumption(
595-
ecx,
596-
goal,
597-
ty::Binder::dummy(ty::ProjectionPredicate {
598-
projection_ty: tcx.mk_alias_ty(goal.predicate.def_id(), [self_ty]),
599-
term,
600-
})
601-
.to_predicate(tcx),
602-
)
589+
let discriminant = goal.predicate.self_ty().discriminant_ty(ecx.tcx());
590+
let nested_goals = ecx.infcx.eq(
591+
goal.param_env,
592+
goal.predicate.term.ty().expect("expected ty goal"),
593+
discriminant,
594+
)?;
595+
ecx.evaluate_all_and_make_canonical_response(nested_goals)
603596
}
604597
}
605598

0 commit comments

Comments
 (0)