diff --git a/src/librustc_traits/lowering/mod.rs b/src/librustc_traits/lowering/mod.rs index 44883d438a1e5..0cbfa7c626f13 100644 --- a/src/librustc_traits/lowering/mod.rs +++ b/src/librustc_traits/lowering/mod.rs @@ -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) :- Implemented(Self: Trait) && 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())