Fix a bug in chalk lowering

Some where clauses were not subtituted for generic bound type vars.
This commit is contained in:
scalexm 2019-02-08 15:29:22 +01:00
parent 1834665508
commit 4effdd2431

View file

@ -209,6 +209,10 @@ fn program_clauses_for_trait<'a, 'tcx>(
let implemented_from_env = Clause::ForAll(ty::Binder::bind(implemented_from_env));
let predicates = &tcx.predicates_defined_on(def_id).predicates;
// Warning: these where clauses are not substituted for bound vars yet,
// so that we don't need to adjust binders in the `FromEnv` rules below
// (see the FIXME).
let where_clauses = &predicates
.iter()
.map(|(wc, _)| wc.lower())
@ -258,6 +262,7 @@ fn program_clauses_for_trait<'a, 'tcx>(
// `WellFormed(WC)`
let wf_conditions = where_clauses
.into_iter()
.map(|wc| wc.subst(tcx, bound_vars))
.map(|wc| wc.map_bound(|goal| goal.into_well_formed_goal()));
// `WellFormed(Self: Trait<P1..Pn>) :- Implemented(Self: Trait<P1..Pn>) && WellFormed(WC)`
@ -341,7 +346,9 @@ pub fn program_clauses_for_type_def<'a, 'tcx>(
// `Ty<...>`
let ty = tcx.type_of(def_id).subst(tcx, bound_vars);
// `WC`
// Warning: these where clauses are not substituted for bound vars yet,
// so that we don't need to adjust binders in the `FromEnv` rules below
// (see the FIXME).
let where_clauses = tcx.predicates_of(def_id).predicates
.iter()
.map(|(wc, _)| wc.lower())