diff options
| author | Michael Goulet <michael@errs.io> | 2023-12-13 14:11:09 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-12-14 18:41:23 +0000 |
| commit | 929d632b541cb52c23e1b768bb8c3f88bf9b5955 (patch) | |
| tree | b625d6417e72dbc7e699f379fc2794a5dcbebe1e /compiler/rustc_trait_selection/src/solve | |
| parent | 2ecba0fa00b75e7291978c50bece407f17296f45 (diff) | |
| download | rust-929d632b541cb52c23e1b768bb8c3f88bf9b5955.tar.gz rust-929d632b541cb52c23e1b768bb8c3f88bf9b5955.zip | |
Unconditionally register alias-relate in projection goal
Diffstat (limited to 'compiler/rustc_trait_selection/src/solve')
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/project_goals.rs | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/project_goals.rs b/compiler/rustc_trait_selection/src/solve/project_goals.rs index 0b80969c307..d0e92a54ceb 100644 --- a/compiler/rustc_trait_selection/src/solve/project_goals.rs +++ b/compiler/rustc_trait_selection/src/solve/project_goals.rs @@ -8,16 +8,28 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { &mut self, goal: Goal<'tcx, ProjectionPredicate<'tcx>>, ) -> QueryResult<'tcx> { - match goal.predicate.term.unpack() { - ty::TermKind::Ty(term) => { - let alias = goal.predicate.projection_ty.to_ty(self.tcx()); - self.eq(goal.param_env, alias, term)?; - self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) - } - // FIXME(associated_const_equality): actually do something here. - ty::TermKind::Const(_) => { - self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) - } - } + let tcx = self.tcx(); + let projection_term = match goal.predicate.term.unpack() { + ty::TermKind::Ty(_) => goal.predicate.projection_ty.to_ty(tcx).into(), + ty::TermKind::Const(_) => ty::Const::new_unevaluated( + tcx, + ty::UnevaluatedConst::new( + goal.predicate.projection_ty.def_id, + goal.predicate.projection_ty.args, + ), + tcx.type_of(goal.predicate.projection_ty.def_id) + .instantiate(tcx, goal.predicate.projection_ty.args), + ) + .into(), + }; + self.add_goal(goal.with( + tcx, + ty::PredicateKind::AliasRelate( + projection_term, + goal.predicate.term, + ty::AliasRelationDirection::Equate, + ), + )); + self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) } } |
