Skip to content

Commit

Permalink
Simplify discriminant_kind goal using new helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
detrumi committed Feb 1, 2023
1 parent 5fd4f5b commit de50a86
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions compiler/rustc_trait_selection/src/solve/project_goals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,20 +586,13 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
ecx: &mut EvalCtxt<'_, 'tcx>,
goal: Goal<'tcx, Self>,
) -> QueryResult<'tcx> {
let self_ty = goal.predicate.self_ty();

let tcx = ecx.tcx();
let term = self_ty.discriminant_ty(tcx).into();

Self::consider_assumption(
ecx,
goal,
ty::Binder::dummy(ty::ProjectionPredicate {
projection_ty: tcx.mk_alias_ty(goal.predicate.def_id(), [self_ty]),
term,
})
.to_predicate(tcx),
)
let discriminant = goal.predicate.self_ty().discriminant_ty(ecx.tcx());
let nested_goals = ecx.infcx.eq(
goal.param_env,
goal.predicate.term.ty().expect("expected ty goal"),
discriminant,
)?;
ecx.evaluate_all_and_make_canonical_response(nested_goals)
}
}

Expand Down

0 comments on commit de50a86

Please sign in to comment.