aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/walk.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-04-05 18:15:13 +0100
committerFlorian Diebold <[email protected]>2021-04-05 18:21:03 +0100
commita316d583600e11ee1fcc8027a838efafe435f03c (patch)
treed4448b520724757956ba653e5c0a318b3abdb52c /crates/hir_ty/src/walk.rs
parentfbab69cbffed37291b463c0e57fade49581e1de2 (diff)
Rename shift_bound_vars{_out} to align with Chalk
Diffstat (limited to 'crates/hir_ty/src/walk.rs')
-rw-r--r--crates/hir_ty/src/walk.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/crates/hir_ty/src/walk.rs b/crates/hir_ty/src/walk.rs
index b1e22da0a..b85e6ab4d 100644
--- a/crates/hir_ty/src/walk.rs
+++ b/crates/hir_ty/src/walk.rs
@@ -82,7 +82,7 @@ pub trait TypeWalk {
82 *ty = substs.interned()[bound.index] 82 *ty = substs.interned()[bound.index]
83 .assert_ty_ref(&Interner) 83 .assert_ty_ref(&Interner)
84 .clone() 84 .clone()
85 .shift_bound_vars(binders); 85 .shifted_in_from(binders);
86 } 86 }
87 } 87 }
88 }, 88 },
@@ -92,7 +92,7 @@ pub trait TypeWalk {
92 } 92 }
93 93
94 /// Shifts up debruijn indices of `TyKind::Bound` vars by `n`. 94 /// Shifts up debruijn indices of `TyKind::Bound` vars by `n`.
95 fn shift_bound_vars(self, n: DebruijnIndex) -> Self 95 fn shifted_in_from(self, n: DebruijnIndex) -> Self
96 where 96 where
97 Self: Sized, 97 Self: Sized,
98 { 98 {
@@ -108,20 +108,22 @@ pub trait TypeWalk {
108 } 108 }
109 109
110 /// Shifts debruijn indices of `TyKind::Bound` vars out (down) by `n`. 110 /// Shifts debruijn indices of `TyKind::Bound` vars out (down) by `n`.
111 fn shift_bound_vars_out(self, n: DebruijnIndex) -> Self 111 fn shifted_out_to(self, n: DebruijnIndex) -> Option<Self>
112 where 112 where
113 Self: Sized + std::fmt::Debug, 113 Self: Sized + std::fmt::Debug,
114 { 114 {
115 self.fold_binders( 115 Some(self.fold_binders(
116 &mut |ty, binders| match ty.kind(&Interner) { 116 &mut |ty, binders| {
117 TyKind::BoundVar(bound) if bound.debruijn >= binders => { 117 match ty.kind(&Interner) {
118 TyKind::BoundVar(bound.shifted_out_to(n).unwrap_or(bound.clone())) 118 TyKind::BoundVar(bound) if bound.debruijn >= binders => {
119 .intern(&Interner) 119 TyKind::BoundVar(bound.shifted_out_to(n).unwrap_or(bound.clone()))
120 .intern(&Interner)
121 }
122 _ => ty,
120 } 123 }
121 _ => ty,
122 }, 124 },
123 DebruijnIndex::INNERMOST, 125 DebruijnIndex::INNERMOST,
124 ) 126 ))
125 } 127 }
126} 128}
127 129