Skip to content

Commit 393fdc1

Browse files
committed
Auto merge of rust-lang#94021 - tmiasko:inline, r=nagisa
Inline a few trivial conversion functions
2 parents 09cb29c + ea71420 commit 393fdc1

File tree

7 files changed

+20
-0
lines changed

7 files changed

+20
-0
lines changed

compiler/rustc_infer/src/infer/type_variable.rs

+1
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ impl<'tcx> ut::UnifyKey for TyVidEqKey<'tcx> {
416416
fn index(&self) -> u32 {
417417
self.vid.as_u32()
418418
}
419+
#[inline]
419420
fn from_index(i: u32) -> Self {
420421
TyVidEqKey::from(ty::TyVid::from_u32(i))
421422
}

compiler/rustc_middle/src/infer/unify_key.rs

+4
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ impl<'tcx> From<ty::RegionVid> for RegionVidKey<'tcx> {
3232

3333
impl<'tcx> UnifyKey for RegionVidKey<'tcx> {
3434
type Value = UnifiedRegion<'tcx>;
35+
#[inline]
3536
fn index(&self) -> u32 {
3637
self.vid.as_u32()
3738
}
39+
#[inline]
3840
fn from_index(i: u32) -> Self {
3941
RegionVidKey::from(ty::RegionVid::from_u32(i))
4042
}
@@ -118,9 +120,11 @@ pub struct ConstVarValue<'tcx> {
118120

119121
impl<'tcx> UnifyKey for ty::ConstVid<'tcx> {
120122
type Value = ConstVarValue<'tcx>;
123+
#[inline]
121124
fn index(&self) -> u32 {
122125
self.index
123126
}
127+
#[inline]
124128
fn from_index(i: u32) -> Self {
125129
ty::ConstVid { index: i, phantom: PhantomData }
126130
}

compiler/rustc_middle/src/ty/subst.rs

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub enum GenericArgKind<'tcx> {
4848
}
4949

5050
impl<'tcx> GenericArgKind<'tcx> {
51+
#[inline]
5152
fn pack(self) -> GenericArg<'tcx> {
5253
let (tag, ptr) = match self {
5354
GenericArgKind::Lifetime(lt) => {
@@ -94,18 +95,21 @@ impl<'tcx> PartialOrd for GenericArg<'tcx> {
9495
}
9596

9697
impl<'tcx> From<ty::Region<'tcx>> for GenericArg<'tcx> {
98+
#[inline]
9799
fn from(r: ty::Region<'tcx>) -> GenericArg<'tcx> {
98100
GenericArgKind::Lifetime(r).pack()
99101
}
100102
}
101103

102104
impl<'tcx> From<Ty<'tcx>> for GenericArg<'tcx> {
105+
#[inline]
103106
fn from(ty: Ty<'tcx>) -> GenericArg<'tcx> {
104107
GenericArgKind::Type(ty).pack()
105108
}
106109
}
107110

108111
impl<'tcx> From<ty::Const<'tcx>> for GenericArg<'tcx> {
112+
#[inline]
109113
fn from(c: ty::Const<'tcx>) -> GenericArg<'tcx> {
110114
GenericArgKind::Const(c).pack()
111115
}

compiler/rustc_mir_transform/src/dest_prop.rs

+2
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,11 @@ impl From<Local> for UnifyLocal {
222222

223223
impl UnifyKey for UnifyLocal {
224224
type Value = ();
225+
#[inline]
225226
fn index(&self) -> u32 {
226227
self.0.as_u32()
227228
}
229+
#[inline]
228230
fn from_index(u: u32) -> Self {
229231
Self(Local::from_u32(u))
230232
}

compiler/rustc_span/src/hygiene.rs

+2
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,12 @@ impl LocalExpnId {
172172
/// The ID of the theoretical expansion that generates freshly parsed, unexpanded AST.
173173
pub const ROOT: LocalExpnId = LocalExpnId::from_u32(0);
174174

175+
#[inline]
175176
pub fn from_raw(idx: ExpnIndex) -> LocalExpnId {
176177
LocalExpnId::from_u32(idx.as_u32())
177178
}
178179

180+
#[inline]
179181
pub fn as_raw(self) -> ExpnIndex {
180182
ExpnIndex::from_u32(self.as_u32())
181183
}

compiler/rustc_target/src/spec/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1541,11 +1541,13 @@ impl Default for TargetOptions {
15411541
impl Deref for Target {
15421542
type Target = TargetOptions;
15431543

1544+
#[inline]
15441545
fn deref(&self) -> &Self::Target {
15451546
&self.options
15461547
}
15471548
}
15481549
impl DerefMut for Target {
1550+
#[inline]
15491551
fn deref_mut(&mut self) -> &mut Self::Target {
15501552
&mut self.options
15511553
}

compiler/rustc_type_ir/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,11 @@ pub enum InferTy {
400400
/// they carry no values.
401401
impl UnifyKey for TyVid {
402402
type Value = ();
403+
#[inline]
403404
fn index(&self) -> u32 {
404405
self.as_u32()
405406
}
407+
#[inline]
406408
fn from_index(i: u32) -> TyVid {
407409
TyVid::from_u32(i)
408410
}
@@ -419,6 +421,7 @@ impl UnifyKey for IntVid {
419421
fn index(&self) -> u32 {
420422
self.index
421423
}
424+
#[inline]
422425
fn from_index(i: u32) -> IntVid {
423426
IntVid { index: i }
424427
}
@@ -431,9 +434,11 @@ impl EqUnifyValue for FloatVarValue {}
431434

432435
impl UnifyKey for FloatVid {
433436
type Value = Option<FloatVarValue>;
437+
#[inline]
434438
fn index(&self) -> u32 {
435439
self.index
436440
}
441+
#[inline]
437442
fn from_index(i: u32) -> FloatVid {
438443
FloatVid { index: i }
439444
}

0 commit comments

Comments
 (0)