diff options
| author | scalexm <alexandre@scalexm.fr> | 2019-02-08 15:29:22 +0100 |
|---|---|---|
| committer | scalexm <alexandre@scalexm.fr> | 2019-03-20 20:09:26 +0100 |
| commit | 4effdd2431020ce86d4c22765afa05d19c3215cc (patch) | |
| tree | ba41336322afc3f68c9cfb2e4a3e633c47747354 | |
| parent | 183466550808dbce73709a2202d5f84fdfb8ddc1 (diff) | |
| download | rust-4effdd2431020ce86d4c22765afa05d19c3215cc.tar.gz rust-4effdd2431020ce86d4c22765afa05d19c3215cc.zip | |
Fix a bug in chalk lowering
Some where clauses were not subtituted for generic bound type vars.
| -rw-r--r-- | src/librustc_traits/lowering/mod.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/librustc_traits/lowering/mod.rs b/src/librustc_traits/lowering/mod.rs index 44883d438a1..0cbfa7c626f 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<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()) |
