diff options
Diffstat (limited to 'compiler/rustc_trait_selection/src/solve/weak_types.rs')
-rw-r--r-- | compiler/rustc_trait_selection/src/solve/weak_types.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/weak_types.rs b/compiler/rustc_trait_selection/src/solve/weak_types.rs index b095b54c5..54de32cf6 100644 --- a/compiler/rustc_trait_selection/src/solve/weak_types.rs +++ b/compiler/rustc_trait_selection/src/solve/weak_types.rs @@ -1,3 +1,8 @@ +//! Computes a normalizes-to (projection) goal for inherent associated types, +//! `#![feature(lazy_type_alias)]` and `#![feature(type_alias_impl_trait)]`. +//! +//! Since a weak alias is not ambiguous, this just computes the `type_of` of +//! the alias and registers the where-clauses of the type alias. use rustc_middle::traits::solve::{Certainty, Goal, QueryResult}; use rustc_middle::ty; @@ -12,8 +17,18 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { let weak_ty = goal.predicate.projection_ty; let expected = goal.predicate.term.ty().expect("no such thing as a const alias"); - let actual = tcx.type_of(weak_ty.def_id).subst(tcx, weak_ty.substs); + let actual = tcx.type_of(weak_ty.def_id).instantiate(tcx, weak_ty.args); self.eq(goal.param_env, expected, actual)?; + + // Check where clauses + self.add_goals( + tcx.predicates_of(weak_ty.def_id) + .instantiate(tcx, weak_ty.args) + .predicates + .into_iter() + .map(|pred| goal.with(tcx, pred)), + ); + self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) } } |