Skip to content

Commit 4effdd2

Browse files
committed
Fix a bug in chalk lowering
Some where clauses were not subtituted for generic bound type vars.
1 parent 1834665 commit 4effdd2

File tree

1 file changed

+8
-1
lines changed
  • src/librustc_traits/lowering

1 file changed

+8
-1
lines changed

src/librustc_traits/lowering/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ fn program_clauses_for_trait<'a, 'tcx>(
209209
let implemented_from_env = Clause::ForAll(ty::Binder::bind(implemented_from_env));
210210

211211
let predicates = &tcx.predicates_defined_on(def_id).predicates;
212+
213+
// Warning: these where clauses are not substituted for bound vars yet,
214+
// so that we don't need to adjust binders in the `FromEnv` rules below
215+
// (see the FIXME).
212216
let where_clauses = &predicates
213217
.iter()
214218
.map(|(wc, _)| wc.lower())
@@ -258,6 +262,7 @@ fn program_clauses_for_trait<'a, 'tcx>(
258262
// `WellFormed(WC)`
259263
let wf_conditions = where_clauses
260264
.into_iter()
265+
.map(|wc| wc.subst(tcx, bound_vars))
261266
.map(|wc| wc.map_bound(|goal| goal.into_well_formed_goal()));
262267

263268
// `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>(
341346
// `Ty<...>`
342347
let ty = tcx.type_of(def_id).subst(tcx, bound_vars);
343348

344-
// `WC`
349+
// Warning: these where clauses are not substituted for bound vars yet,
350+
// so that we don't need to adjust binders in the `FromEnv` rules below
351+
// (see the FIXME).
345352
let where_clauses = tcx.predicates_of(def_id).predicates
346353
.iter()
347354
.map(|(wc, _)| wc.lower())

0 commit comments

Comments
 (0)