Skip to content

Commit 2208f5e

Browse files
Inline DebruijnIndex methods
1 parent 99baddb commit 2208f5e

File tree

1 file changed

+5
-0
lines changed
  • compiler/rustc_type_ir/src

1 file changed

+5
-0
lines changed

compiler/rustc_type_ir/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,24 +150,28 @@ impl DebruijnIndex {
150150
///
151151
/// you would need to shift the index for `'a` into a new binder.
152152
#[must_use]
153+
#[inline]
153154
pub fn shifted_in(self, amount: u32) -> DebruijnIndex {
154155
DebruijnIndex::from_u32(self.as_u32() + amount)
155156
}
156157

157158
/// Update this index in place by shifting it "in" through
158159
/// `amount` number of binders.
160+
#[inline]
159161
pub fn shift_in(&mut self, amount: u32) {
160162
*self = self.shifted_in(amount);
161163
}
162164

163165
/// Returns the resulting index when this value is moved out from
164166
/// `amount` number of new binders.
165167
#[must_use]
168+
#[inline]
166169
pub fn shifted_out(self, amount: u32) -> DebruijnIndex {
167170
DebruijnIndex::from_u32(self.as_u32() - amount)
168171
}
169172

170173
/// Update in place by shifting out from `amount` binders.
174+
#[inline]
171175
pub fn shift_out(&mut self, amount: u32) {
172176
*self = self.shifted_out(amount);
173177
}
@@ -192,6 +196,7 @@ impl DebruijnIndex {
192196
/// If we invoke `shift_out_to_binder` and the region is in fact
193197
/// bound by one of the binders we are shifting out of, that is an
194198
/// error (and should fail an assertion failure).
199+
#[inline]
195200
pub fn shifted_out_to_binder(self, to_binder: DebruijnIndex) -> Self {
196201
self.shifted_out(to_binder.as_u32() - INNERMOST.as_u32())
197202
}

0 commit comments

Comments
 (0)