Skip to content

Commit

Permalink
Inline GenericArg conversion functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiasko committed Feb 15, 2022
1 parent cd37638 commit d046777
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/rustc_middle/src/ty/subst.rs
Expand Up @@ -48,6 +48,7 @@ pub enum GenericArgKind<'tcx> {
}

impl<'tcx> GenericArgKind<'tcx> {
#[inline]
fn pack(self) -> GenericArg<'tcx> {
let (tag, ptr) = match self {
GenericArgKind::Lifetime(lt) => {
Expand Down Expand Up @@ -94,18 +95,21 @@ impl<'tcx> PartialOrd for GenericArg<'tcx> {
}

impl<'tcx> From<ty::Region<'tcx>> for GenericArg<'tcx> {
#[inline]
fn from(r: ty::Region<'tcx>) -> GenericArg<'tcx> {
GenericArgKind::Lifetime(r).pack()
}
}

impl<'tcx> From<Ty<'tcx>> for GenericArg<'tcx> {
#[inline]
fn from(ty: Ty<'tcx>) -> GenericArg<'tcx> {
GenericArgKind::Type(ty).pack()
}
}

impl<'tcx> From<ty::Const<'tcx>> for GenericArg<'tcx> {
#[inline]
fn from(c: ty::Const<'tcx>) -> GenericArg<'tcx> {
GenericArgKind::Const(c).pack()
}
Expand Down

0 comments on commit d046777

Please sign in to comment.