aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/infer/unify.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty/infer/unify.rs')
-rw-r--r--crates/ra_hir/src/ty/infer/unify.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/crates/ra_hir/src/ty/infer/unify.rs b/crates/ra_hir/src/ty/infer/unify.rs
index ca33cc7f8..64d9394cf 100644
--- a/crates/ra_hir/src/ty/infer/unify.rs
+++ b/crates/ra_hir/src/ty/infer/unify.rs
@@ -134,17 +134,19 @@ where
134} 134}
135 135
136impl<T> Canonicalized<T> { 136impl<T> Canonicalized<T> {
137 pub fn decanonicalize_ty(&self, ty: Ty) -> Ty { 137 pub fn decanonicalize_ty(&self, mut ty: Ty) -> Ty {
138 ty.fold(&mut |ty| match ty { 138 ty.walk_mut_binders(
139 Ty::Bound(idx) => { 139 &mut |ty, binders| match ty {
140 if (idx as usize) < self.free_vars.len() { 140 &mut Ty::Bound(idx) => {
141 Ty::Infer(self.free_vars[idx as usize]) 141 if idx as usize >= binders && (idx as usize - binders) < self.free_vars.len() {
142 } else { 142 *ty = Ty::Infer(self.free_vars[idx as usize - binders]);
143 Ty::Bound(idx) 143 }
144 } 144 }
145 } 145 _ => {}
146 ty => ty, 146 },
147 }) 147 0,
148 );
149 ty
148 } 150 }
149 151
150 pub fn apply_solution( 152 pub fn apply_solution(