Skip to content

Commit 2eb5de7

Browse files
committed
Add inline annotations to View
1 parent 98f302c commit 2eb5de7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/librustc/ty/view.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub struct View<'tcx, T> {
2222
impl<T> Copy for View<'_, T> {}
2323

2424
impl<T> Clone for View<'_, T> {
25+
#[inline]
2526
fn clone(&self) -> Self {
2627
View { ty: self.ty, _marker: PhantomData }
2728
}
@@ -49,6 +50,8 @@ where
4950
T: TyDeref<'tcx>,
5051
{
5152
type Target = T;
53+
54+
#[inline]
5255
fn deref(&self) -> &Self::Target {
5356
match T::ty_deref(self.ty) {
5457
Some(t) => t,
@@ -62,13 +65,15 @@ impl<'tcx, T> View<'tcx, T>
6265
where
6366
T: TyDeref<'tcx>,
6467
{
68+
#[inline]
6569
pub fn new(ty: Ty<'tcx>) -> Option<Self> {
6670
T::ty_deref(ty)?;
6771
Some(View { ty, _marker: PhantomData })
6872
}
6973
}
7074

7175
impl<'tcx, T> View<'tcx, T> {
76+
#[inline]
7277
pub fn as_ty(&self) -> Ty<'tcx> {
7378
self.ty
7479
}
@@ -83,6 +88,7 @@ pub unsafe trait TyDeref<'tcx>: Sized + 'tcx {
8388
macro_rules! impl_ty_deref {
8489
($ty: ty, $variant: ident) => {
8590
unsafe impl<'tcx> TyDeref<'tcx> for $ty {
91+
#[inline]
8692
fn ty_deref(ty: Ty<'tcx>) -> Option<&'tcx Self> {
8793
match &ty.kind {
8894
ty::$variant(p) => Some(p),
@@ -129,6 +135,7 @@ pub enum ViewKind<'tcx> {
129135
}
130136

131137
impl<'tcx> From<Ty<'tcx>> for ViewKind<'tcx> {
138+
#[inline]
132139
fn from(ty: Ty<'tcx>) -> Self {
133140
match ty.kind {
134141
ty::RawPtr(tm) => Self::RawPtr(tm),

0 commit comments

Comments
 (0)