Skip to content

Commit c175e8a

Browse files
committed
Auto merge of #152160 - nnethercote:start-cutting-down-rustc_query_system, r=<try>
Start cutting down `rustc_query_system`
2 parents f889772 + d6218b6 commit c175e8a

File tree

9 files changed

+812
-845
lines changed

9 files changed

+812
-845
lines changed

compiler/rustc_middle/src/query/inner.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,33 @@
22
//! `tcx.$query(..)` and its variations.
33
44
use rustc_query_system::dep_graph::{DepKind, DepNodeKey};
5-
use rustc_query_system::query::{QueryCache, QueryMode, try_get_cached};
5+
use rustc_query_system::query::{QueryCache, QueryMode};
66
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span};
77

88
use crate::dep_graph;
99
use crate::query::erase::{self, Erasable, Erased};
1010
use crate::query::plumbing::QueryVTable;
1111
use crate::ty::TyCtxt;
1212

13+
/// Checks whether there is already a value for this key in the in-memory
14+
/// query cache, returning that value if present.
15+
///
16+
/// (Also performs some associated bookkeeping, if a value was found.)
17+
#[inline(always)]
18+
fn try_get_cached<'tcx, C>(tcx: TyCtxt<'tcx>, cache: &C, key: &C::Key) -> Option<C::Value>
19+
where
20+
C: QueryCache,
21+
{
22+
match cache.lookup(key) {
23+
Some((value, index)) => {
24+
tcx.prof.query_cache_hit(index.into());
25+
tcx.dep_graph.read_index(index);
26+
Some(value)
27+
}
28+
None => None,
29+
}
30+
}
31+
1332
/// Shared implementation of `tcx.$query(..)` and `tcx.at(span).$query(..)`
1433
/// for all queries.
1534
#[inline(always)]

compiler/rustc_query_impl/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// tidy-alphabetical-start
44
#![allow(internal_features)]
55
#![feature(adt_const_params)]
6+
#![feature(core_intrinsics)]
67
#![feature(min_specialization)]
78
#![feature(rustc_attrs)]
89
// tidy-alphabetical-end
@@ -25,7 +26,7 @@ use rustc_query_system::dep_graph::SerializedDepNodeIndex;
2526
use rustc_query_system::ich::StableHashingContext;
2627
use rustc_query_system::query::{
2728
CycleError, CycleErrorHandling, HashResult, QueryCache, QueryDispatcher, QueryMap, QueryMode,
28-
QueryState, get_query_incr, get_query_non_incr,
29+
QueryState,
2930
};
3031
use rustc_span::{ErrorGuaranteed, Span};
3132

0 commit comments

Comments
 (0)