Skip to content

Commit

Permalink
Fix a bug in chalk lowering
Browse files Browse the repository at this point in the history
Some where clauses were not subtituted for generic bound type vars.
  • Loading branch information
scalexm committed Mar 20, 2019
1 parent 1834665 commit 4effdd2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/librustc_traits/lowering/mod.rs
Expand Up @@ -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())
Expand Down Expand Up @@ -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)`
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 4effdd2

Please sign in to comment.