Auto merge of #85892 - tmiasko:i, r=oli-obk

Miscellaneous inlining improvements
This commit is contained in:
bors
2021-06-02 10:47:58 +00:00
17 changed files with 45 additions and 0 deletions

View File

@@ -93,6 +93,7 @@ pub struct Generics {
}
impl<'tcx> Generics {
#[inline]
pub fn count(&self) -> usize {
self.parent_count + self.params.len()
}

View File

@@ -37,9 +37,11 @@ pub struct List<T> {
unsafe impl<'a, T: 'a> rustc_data_structures::tagged_ptr::Pointer for &'a List<T> {
const BITS: usize = std::mem::align_of::<usize>().trailing_zeros() as usize;
#[inline]
fn into_usize(self) -> usize {
self as *const List<T> as usize
}
#[inline]
unsafe fn from_usize(ptr: usize) -> Self {
&*(ptr as *const List<T>)
}

View File

@@ -1097,12 +1097,14 @@ pub struct ParamEnv<'tcx> {
unsafe impl rustc_data_structures::tagged_ptr::Tag for traits::Reveal {
const BITS: usize = 1;
#[inline]
fn into_usize(self) -> usize {
match self {
traits::Reveal::UserFacing => 0,
traits::Reveal::All => 1,
}
}
#[inline]
unsafe fn from_usize(ptr: usize) -> Self {
match ptr {
0 => traits::Reveal::UserFacing,
@@ -1200,6 +1202,7 @@ impl<'tcx> ParamEnv<'tcx> {
}
/// Returns this same environment but with no caller bounds.
#[inline]
pub fn without_caller_bounds(self) -> Self {
Self::new(List::empty(), self.reveal())
}