mirror of
https://github.com/rust-lang/rust
synced 2024-10-16 21:43:43 +00:00
Auto merge of #94021 - tmiasko:inline, r=nagisa
Inline a few trivial conversion functions
This commit is contained in:
commit
393fdc1048
|
@ -416,6 +416,7 @@ impl<'tcx> ut::UnifyKey for TyVidEqKey<'tcx> {
|
||||||
fn index(&self) -> u32 {
|
fn index(&self) -> u32 {
|
||||||
self.vid.as_u32()
|
self.vid.as_u32()
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn from_index(i: u32) -> Self {
|
fn from_index(i: u32) -> Self {
|
||||||
TyVidEqKey::from(ty::TyVid::from_u32(i))
|
TyVidEqKey::from(ty::TyVid::from_u32(i))
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,11 @@ fn from(vid: ty::RegionVid) -> Self {
|
||||||
|
|
||||||
impl<'tcx> UnifyKey for RegionVidKey<'tcx> {
|
impl<'tcx> UnifyKey for RegionVidKey<'tcx> {
|
||||||
type Value = UnifiedRegion<'tcx>;
|
type Value = UnifiedRegion<'tcx>;
|
||||||
|
#[inline]
|
||||||
fn index(&self) -> u32 {
|
fn index(&self) -> u32 {
|
||||||
self.vid.as_u32()
|
self.vid.as_u32()
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn from_index(i: u32) -> Self {
|
fn from_index(i: u32) -> Self {
|
||||||
RegionVidKey::from(ty::RegionVid::from_u32(i))
|
RegionVidKey::from(ty::RegionVid::from_u32(i))
|
||||||
}
|
}
|
||||||
|
@ -118,9 +120,11 @@ pub struct ConstVarValue<'tcx> {
|
||||||
|
|
||||||
impl<'tcx> UnifyKey for ty::ConstVid<'tcx> {
|
impl<'tcx> UnifyKey for ty::ConstVid<'tcx> {
|
||||||
type Value = ConstVarValue<'tcx>;
|
type Value = ConstVarValue<'tcx>;
|
||||||
|
#[inline]
|
||||||
fn index(&self) -> u32 {
|
fn index(&self) -> u32 {
|
||||||
self.index
|
self.index
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn from_index(i: u32) -> Self {
|
fn from_index(i: u32) -> Self {
|
||||||
ty::ConstVid { index: i, phantom: PhantomData }
|
ty::ConstVid { index: i, phantom: PhantomData }
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ pub enum GenericArgKind<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> GenericArgKind<'tcx> {
|
impl<'tcx> GenericArgKind<'tcx> {
|
||||||
|
#[inline]
|
||||||
fn pack(self) -> GenericArg<'tcx> {
|
fn pack(self) -> GenericArg<'tcx> {
|
||||||
let (tag, ptr) = match self {
|
let (tag, ptr) = match self {
|
||||||
GenericArgKind::Lifetime(lt) => {
|
GenericArgKind::Lifetime(lt) => {
|
||||||
|
@ -94,18 +95,21 @@ fn partial_cmp(&self, other: &GenericArg<'_>) -> Option<Ordering> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> From<ty::Region<'tcx>> for GenericArg<'tcx> {
|
impl<'tcx> From<ty::Region<'tcx>> for GenericArg<'tcx> {
|
||||||
|
#[inline]
|
||||||
fn from(r: ty::Region<'tcx>) -> GenericArg<'tcx> {
|
fn from(r: ty::Region<'tcx>) -> GenericArg<'tcx> {
|
||||||
GenericArgKind::Lifetime(r).pack()
|
GenericArgKind::Lifetime(r).pack()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> From<Ty<'tcx>> for GenericArg<'tcx> {
|
impl<'tcx> From<Ty<'tcx>> for GenericArg<'tcx> {
|
||||||
|
#[inline]
|
||||||
fn from(ty: Ty<'tcx>) -> GenericArg<'tcx> {
|
fn from(ty: Ty<'tcx>) -> GenericArg<'tcx> {
|
||||||
GenericArgKind::Type(ty).pack()
|
GenericArgKind::Type(ty).pack()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> From<ty::Const<'tcx>> for GenericArg<'tcx> {
|
impl<'tcx> From<ty::Const<'tcx>> for GenericArg<'tcx> {
|
||||||
|
#[inline]
|
||||||
fn from(c: ty::Const<'tcx>) -> GenericArg<'tcx> {
|
fn from(c: ty::Const<'tcx>) -> GenericArg<'tcx> {
|
||||||
GenericArgKind::Const(c).pack()
|
GenericArgKind::Const(c).pack()
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,9 +222,11 @@ fn from(l: Local) -> Self {
|
||||||
|
|
||||||
impl UnifyKey for UnifyLocal {
|
impl UnifyKey for UnifyLocal {
|
||||||
type Value = ();
|
type Value = ();
|
||||||
|
#[inline]
|
||||||
fn index(&self) -> u32 {
|
fn index(&self) -> u32 {
|
||||||
self.0.as_u32()
|
self.0.as_u32()
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn from_index(u: u32) -> Self {
|
fn from_index(u: u32) -> Self {
|
||||||
Self(Local::from_u32(u))
|
Self(Local::from_u32(u))
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,10 +172,12 @@ impl LocalExpnId {
|
||||||
/// The ID of the theoretical expansion that generates freshly parsed, unexpanded AST.
|
/// The ID of the theoretical expansion that generates freshly parsed, unexpanded AST.
|
||||||
pub const ROOT: LocalExpnId = LocalExpnId::from_u32(0);
|
pub const ROOT: LocalExpnId = LocalExpnId::from_u32(0);
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn from_raw(idx: ExpnIndex) -> LocalExpnId {
|
pub fn from_raw(idx: ExpnIndex) -> LocalExpnId {
|
||||||
LocalExpnId::from_u32(idx.as_u32())
|
LocalExpnId::from_u32(idx.as_u32())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn as_raw(self) -> ExpnIndex {
|
pub fn as_raw(self) -> ExpnIndex {
|
||||||
ExpnIndex::from_u32(self.as_u32())
|
ExpnIndex::from_u32(self.as_u32())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1541,11 +1541,13 @@ fn default() -> TargetOptions {
|
||||||
impl Deref for Target {
|
impl Deref for Target {
|
||||||
type Target = TargetOptions;
|
type Target = TargetOptions;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.options
|
&self.options
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl DerefMut for Target {
|
impl DerefMut for Target {
|
||||||
|
#[inline]
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
&mut self.options
|
&mut self.options
|
||||||
}
|
}
|
||||||
|
|
|
@ -400,9 +400,11 @@ pub enum InferTy {
|
||||||
/// they carry no values.
|
/// they carry no values.
|
||||||
impl UnifyKey for TyVid {
|
impl UnifyKey for TyVid {
|
||||||
type Value = ();
|
type Value = ();
|
||||||
|
#[inline]
|
||||||
fn index(&self) -> u32 {
|
fn index(&self) -> u32 {
|
||||||
self.as_u32()
|
self.as_u32()
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn from_index(i: u32) -> TyVid {
|
fn from_index(i: u32) -> TyVid {
|
||||||
TyVid::from_u32(i)
|
TyVid::from_u32(i)
|
||||||
}
|
}
|
||||||
|
@ -419,6 +421,7 @@ impl UnifyKey for IntVid {
|
||||||
fn index(&self) -> u32 {
|
fn index(&self) -> u32 {
|
||||||
self.index
|
self.index
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn from_index(i: u32) -> IntVid {
|
fn from_index(i: u32) -> IntVid {
|
||||||
IntVid { index: i }
|
IntVid { index: i }
|
||||||
}
|
}
|
||||||
|
@ -431,9 +434,11 @@ impl EqUnifyValue for FloatVarValue {}
|
||||||
|
|
||||||
impl UnifyKey for FloatVid {
|
impl UnifyKey for FloatVid {
|
||||||
type Value = Option<FloatVarValue>;
|
type Value = Option<FloatVarValue>;
|
||||||
|
#[inline]
|
||||||
fn index(&self) -> u32 {
|
fn index(&self) -> u32 {
|
||||||
self.index
|
self.index
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn from_index(i: u32) -> FloatVid {
|
fn from_index(i: u32) -> FloatVid {
|
||||||
FloatVid { index: i }
|
FloatVid { index: i }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue