From 2dc568e64402be1a1b0e7f1be6e3a62aba88a4e3 Mon Sep 17 00:00:00 2001 From: Mikhail Babenko Date: Sat, 6 Jun 2020 19:30:38 +0300 Subject: [PATCH] fix ucanonicalization bugs --- chalk-solve/src/infer/ucanonicalize.rs | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/chalk-solve/src/infer/ucanonicalize.rs b/chalk-solve/src/infer/ucanonicalize.rs index 10fce189e1e..aec861f021b 100644 --- a/chalk-solve/src/infer/ucanonicalize.rs +++ b/chalk-solve/src/infer/ucanonicalize.rs @@ -27,6 +27,10 @@ impl InferenceTable { DebruijnIndex::INNERMOST, ); + for universe in value0.binders.iter(interner) { + universes.add(*universe.skip_kind()) + } + // Now re-map the universes found in value. We have to do this // in a second pass because it is only then that we know the // full set of universes found in the original value. @@ -293,6 +297,20 @@ where .to_lifetime(self.interner())) } + fn fold_free_placeholder_const( + &mut self, + ty: &Ty, + universe0: PlaceholderIndex, + _outer_binder: DebruijnIndex, + ) -> Fallible> { + let universe = self.universes.map_universe_to_canonical(universe0.ui); + Ok(PlaceholderIndex { + ui: universe, + idx: universe0.idx, + } + .to_const(self.interner(), ty.clone())) + } + fn interner(&self) -> &'i I { self.interner } @@ -341,6 +359,20 @@ where .to_lifetime(self.interner())) } + fn fold_free_placeholder_const( + &mut self, + ty: &Ty, + universe0: PlaceholderIndex, + _outer_binder: DebruijnIndex, + ) -> Fallible> { + let universe = self.universes.map_universe_from_canonical(universe0.ui); + Ok(PlaceholderIndex { + ui: universe, + idx: universe0.idx, + } + .to_const(self.interner(), ty.clone())) + } + fn forbid_inference_vars(&self) -> bool { true }