From 2208f5e74252b19af0c33fb9f0c1edcbff8d1579 Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Tue, 15 Dec 2020 19:14:44 +0100 Subject: [PATCH] Inline `DebruijnIndex` methods --- compiler/rustc_type_ir/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/rustc_type_ir/src/lib.rs b/compiler/rustc_type_ir/src/lib.rs index 37abb4496ac3f..0eb40e1a06cd8 100644 --- a/compiler/rustc_type_ir/src/lib.rs +++ b/compiler/rustc_type_ir/src/lib.rs @@ -150,12 +150,14 @@ impl DebruijnIndex { /// /// you would need to shift the index for `'a` into a new binder. #[must_use] + #[inline] pub fn shifted_in(self, amount: u32) -> DebruijnIndex { DebruijnIndex::from_u32(self.as_u32() + amount) } /// Update this index in place by shifting it "in" through /// `amount` number of binders. + #[inline] pub fn shift_in(&mut self, amount: u32) { *self = self.shifted_in(amount); } @@ -163,11 +165,13 @@ impl DebruijnIndex { /// Returns the resulting index when this value is moved out from /// `amount` number of new binders. #[must_use] + #[inline] pub fn shifted_out(self, amount: u32) -> DebruijnIndex { DebruijnIndex::from_u32(self.as_u32() - amount) } /// Update in place by shifting out from `amount` binders. + #[inline] pub fn shift_out(&mut self, amount: u32) { *self = self.shifted_out(amount); } @@ -192,6 +196,7 @@ impl DebruijnIndex { /// If we invoke `shift_out_to_binder` and the region is in fact /// bound by one of the binders we are shifting out of, that is an /// error (and should fail an assertion failure). + #[inline] pub fn shifted_out_to_binder(self, to_binder: DebruijnIndex) -> Self { self.shifted_out(to_binder.as_u32() - INNERMOST.as_u32()) }