Pass DepContext and QueryContext by value when practical

This commit is contained in:
John Kåre Alsaker 2023-02-14 00:18:46 +01:00
parent 9bb6e60d1f
commit b3a4fe7d4e
4 changed files with 26 additions and 26 deletions

View file

@ -23,7 +23,7 @@ pub trait DepContext: Copy {
type DepKind: self::DepKind;
/// Create a hashing context for hashing new results.
fn with_stable_hashing_context<R>(&self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R;
fn with_stable_hashing_context<R>(self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R;
/// Access the DepGraph.
fn dep_graph(&self) -> &DepGraph<Self::DepKind>;
@ -37,7 +37,7 @@ pub trait DepContext: Copy {
fn dep_kind_info(&self, dep_node: Self::DepKind) -> &DepKindStruct<Self>;
#[inline(always)]
fn fingerprint_style(&self, kind: Self::DepKind) -> FingerprintStyle {
fn fingerprint_style(self, kind: Self::DepKind) -> FingerprintStyle {
let data = self.dep_kind_info(kind);
if data.is_anon {
return FingerprintStyle::Opaque;
@ -47,7 +47,7 @@ pub trait DepContext: Copy {
#[inline(always)]
/// Return whether this kind always require evaluation.
fn is_eval_always(&self, kind: Self::DepKind) -> bool {
fn is_eval_always(self, kind: Self::DepKind) -> bool {
self.dep_kind_info(kind).is_eval_always
}

View file

@ -101,22 +101,22 @@ impl QuerySideEffects {
}
pub trait QueryContext: HasDepContext {
fn next_job_id(&self) -> QueryJobId;
fn next_job_id(self) -> QueryJobId;
/// Get the query information from the TLS context.
fn current_query_job(&self) -> Option<QueryJobId>;
fn current_query_job(self) -> Option<QueryJobId>;
fn try_collect_active_jobs(&self) -> Option<QueryMap<Self::DepKind>>;
fn try_collect_active_jobs(self) -> Option<QueryMap<Self::DepKind>>;
/// Load side effects associated to the node in the previous session.
fn load_side_effects(&self, prev_dep_node_index: SerializedDepNodeIndex) -> QuerySideEffects;
fn load_side_effects(self, prev_dep_node_index: SerializedDepNodeIndex) -> QuerySideEffects;
/// Register diagnostics for the given node, for use in next session.
fn store_side_effects(&self, dep_node_index: DepNodeIndex, side_effects: QuerySideEffects);
fn store_side_effects(self, dep_node_index: DepNodeIndex, side_effects: QuerySideEffects);
/// Register diagnostics for the given node, for use in next session.
fn store_side_effects_for_anon_node(
&self,
self,
dep_node_index: DepNodeIndex,
side_effects: QuerySideEffects,
);
@ -125,12 +125,12 @@ pub trait QueryContext: HasDepContext {
/// new query job while it executes. It returns the diagnostics
/// captured during execution and the actual result.
fn start_query<R>(
&self,
self,
token: QueryJobId,
depth_limit: bool,
diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
compute: impl FnOnce() -> R,
) -> R;
fn depth_limit_error(&self, job: QueryJobId);
fn depth_limit_error(self, job: QueryJobId);
}