diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 2f2d3080ec90..182f847f1756 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs @@ -814,13 +814,13 @@ pub trait TypeWalk { where Self: Sized, { - self.fold(&mut |ty| match ty { - Ty::Bound(idx) => { + self.fold_binders(&mut |ty, binders| match ty { + Ty::Bound(idx) if idx as usize >= binders => { assert!(idx as i32 >= -n); Ty::Bound((idx as i32 + n) as u32) } ty => ty, - }) + }, 0) } }