Skip to content

Commit 87374de

Browse files
committed
Miscellaneous inlining improvements
Add `#[inline]` to a few trivial non-generic methods from a perf report that otherwise wouldn't be candidates for inlining.
1 parent 3e51277 commit 87374de

File tree

8 files changed

+13
-0
lines changed

8 files changed

+13
-0
lines changed

compiler/rustc_middle/src/ty/adt.rs

+5
Original file line numberDiff line numberDiff line change
@@ -165,22 +165,27 @@ impl<'a> HashStable<StableHashingContext<'a>> for AdtDefData {
165165
pub struct AdtDef<'tcx>(pub Interned<'tcx, AdtDefData>);
166166

167167
impl<'tcx> AdtDef<'tcx> {
168+
#[inline]
168169
pub fn did(self) -> DefId {
169170
self.0.0.did
170171
}
171172

173+
#[inline]
172174
pub fn variants(self) -> &'tcx IndexVec<VariantIdx, VariantDef> {
173175
&self.0.0.variants
174176
}
175177

178+
#[inline]
176179
pub fn variant(self, idx: VariantIdx) -> &'tcx VariantDef {
177180
&self.0.0.variants[idx]
178181
}
179182

183+
#[inline]
180184
pub fn flags(self) -> AdtFlags {
181185
self.0.0.flags
182186
}
183187

188+
#[inline]
184189
pub fn repr(self) -> ReprOptions {
185190
self.0.0.repr
186191
}

compiler/rustc_middle/src/ty/structural_impls.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,7 @@ impl<'tcx> TypeVisitable<'tcx> for ty::Predicate<'tcx> {
11261126
self.outer_exclusive_binder() > binder
11271127
}
11281128

1129+
#[inline]
11291130
fn has_type_flags(&self, flags: ty::TypeFlags) -> bool {
11301131
self.flags().intersects(flags)
11311132
}

compiler/rustc_middle/src/ty/sty.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,7 @@ pub struct Region<'tcx>(pub Interned<'tcx, RegionKind<'tcx>>);
13151315
impl<'tcx> Deref for Region<'tcx> {
13161316
type Target = RegionKind<'tcx>;
13171317

1318+
#[inline]
13181319
fn deref(&self) -> &RegionKind<'tcx> {
13191320
&self.0.0
13201321
}

compiler/rustc_middle/src/ty/util.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,7 @@ impl<'tcx> Ty<'tcx> {
10421042
ty
10431043
}
10441044

1045+
#[inline]
10451046
pub fn outer_exclusive_binder(self) -> ty::DebruijnIndex {
10461047
self.0.outer_exclusive_binder
10471048
}

compiler/rustc_query_system/src/dep_graph/graph.rs

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ pub enum DepNodeColor {
5959
}
6060

6161
impl DepNodeColor {
62+
#[inline]
6263
pub fn is_green(self) -> bool {
6364
match self {
6465
DepNodeColor::Red => false,

compiler/rustc_query_system/src/query/job.rs

+2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ pub struct QueryJob {
8484

8585
impl QueryJob {
8686
/// Creates a new query job.
87+
#[inline]
8788
pub fn new(id: QueryJobId, span: Span, parent: Option<QueryJobId>) -> Self {
8889
QueryJob {
8990
id,
@@ -106,6 +107,7 @@ impl QueryJob {
106107
///
107108
/// This does nothing for single threaded rustc,
108109
/// as there are no concurrent jobs which could be waiting on us
110+
#[inline]
109111
pub fn signal_complete(self) {
110112
#[cfg(parallel_compiler)]
111113
{

compiler/rustc_query_system/src/query/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ pub struct QuerySideEffects {
8181
}
8282

8383
impl QuerySideEffects {
84+
#[inline]
8485
pub fn is_empty(&self) -> bool {
8586
let QuerySideEffects { diagnostics } = self;
8687
diagnostics.is_empty()

compiler/rustc_span/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,7 @@ impl SourceFile {
16031603
self.name.is_real()
16041604
}
16051605

1606+
#[inline]
16061607
pub fn is_imported(&self) -> bool {
16071608
self.src.is_none()
16081609
}

0 commit comments

Comments
 (0)