Skip to content

Commit 8785b70

Browse files
committed
Inline DepNodeParams methods.
1 parent df71d08 commit 8785b70

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

compiler/rustc_middle/src/dep_graph/dep_node.rs

+14
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,12 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for () {
308308
FingerprintStyle::Unit
309309
}
310310

311+
#[inline(always)]
311312
fn to_fingerprint(&self, _: TyCtxt<'tcx>) -> Fingerprint {
312313
Fingerprint::ZERO
313314
}
314315

316+
#[inline(always)]
315317
fn recover(_: TyCtxt<'tcx>, _: &DepNode) -> Option<Self> {
316318
Some(())
317319
}
@@ -323,14 +325,17 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for DefId {
323325
FingerprintStyle::DefPathHash
324326
}
325327

328+
#[inline(always)]
326329
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
327330
tcx.def_path_hash(*self).0
328331
}
329332

333+
#[inline(always)]
330334
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
331335
tcx.def_path_str(*self)
332336
}
333337

338+
#[inline(always)]
334339
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
335340
dep_node.extract_def_id(tcx)
336341
}
@@ -342,14 +347,17 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for LocalDefId {
342347
FingerprintStyle::DefPathHash
343348
}
344349

350+
#[inline(always)]
345351
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
346352
self.to_def_id().to_fingerprint(tcx)
347353
}
348354

355+
#[inline(always)]
349356
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
350357
self.to_def_id().to_debug_str(tcx)
351358
}
352359

360+
#[inline(always)]
353361
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
354362
dep_node.extract_def_id(tcx).map(|id| id.expect_local())
355363
}
@@ -361,15 +369,18 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for CrateNum {
361369
FingerprintStyle::DefPathHash
362370
}
363371

372+
#[inline(always)]
364373
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
365374
let def_id = DefId { krate: *self, index: CRATE_DEF_INDEX };
366375
def_id.to_fingerprint(tcx)
367376
}
368377

378+
#[inline(always)]
369379
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
370380
tcx.crate_name(*self).to_string()
371381
}
372382

383+
#[inline(always)]
373384
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
374385
dep_node.extract_def_id(tcx).map(|id| id.krate)
375386
}
@@ -384,6 +395,7 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for (DefId, DefId) {
384395
// We actually would not need to specialize the implementation of this
385396
// method but it's faster to combine the hashes than to instantiate a full
386397
// hashing context and stable-hashing state.
398+
#[inline(always)]
387399
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
388400
let (def_id_0, def_id_1) = *self;
389401

@@ -393,6 +405,7 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for (DefId, DefId) {
393405
def_path_hash_0.0.combine(def_path_hash_1.0)
394406
}
395407

408+
#[inline(always)]
396409
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
397410
let (def_id_0, def_id_1) = *self;
398411

@@ -409,6 +422,7 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for HirId {
409422
// We actually would not need to specialize the implementation of this
410423
// method but it's faster to combine the hashes than to instantiate a full
411424
// hashing context and stable-hashing state.
425+
#[inline(always)]
412426
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
413427
let HirId { owner, local_id } = *self;
414428

compiler/rustc_query_system/src/dep_graph/dep_node.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,12 @@ impl<Ctxt: DepContext, T> DepNodeParams<Ctxt> for T
124124
where
125125
T: for<'a> HashStable<StableHashingContext<'a>> + fmt::Debug,
126126
{
127-
#[inline]
127+
#[inline(always)]
128128
default fn fingerprint_style() -> FingerprintStyle {
129129
FingerprintStyle::Opaque
130130
}
131131

132+
#[inline(always)]
132133
default fn to_fingerprint(&self, tcx: Ctxt) -> Fingerprint {
133134
let mut hcx = tcx.create_stable_hashing_context();
134135
let mut hasher = StableHasher::new();
@@ -138,10 +139,12 @@ where
138139
hasher.finish()
139140
}
140141

142+
#[inline(always)]
141143
default fn to_debug_str(&self, _: Ctxt) -> String {
142144
format!("{:?}", *self)
143145
}
144146

147+
#[inline(always)]
145148
default fn recover(_: Ctxt, _: &DepNode<Ctxt::DepKind>) -> Option<Self> {
146149
None
147150
}

0 commit comments

Comments
 (0)