Skip to content

Commit 2bcd0e2

Browse files
committed
Remove {get,force}_query_impl.
1 parent 449f8ef commit 2bcd0e2

File tree

1 file changed

+50
-76
lines changed

1 file changed

+50
-76
lines changed

compiler/rustc_query_system/src/query/plumbing.rs

Lines changed: 50 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -612,32 +612,6 @@ where
612612
(result, dep_node_index)
613613
}
614614

615-
#[inline(never)]
616-
fn get_query_impl<CTX, C>(
617-
tcx: CTX,
618-
state: &QueryState<CTX, C>,
619-
span: Span,
620-
key: C::Key,
621-
query: &QueryVtable<CTX, C::Key, C::Value>,
622-
) -> C::Stored
623-
where
624-
CTX: QueryContext,
625-
C: QueryCache,
626-
C::Key: Eq + Clone + crate::dep_graph::DepNodeParams<CTX>,
627-
C::Stored: Clone,
628-
{
629-
try_get_cached(
630-
tcx,
631-
state,
632-
key,
633-
|value, index| {
634-
tcx.dep_graph().read_index(index);
635-
value.clone()
636-
},
637-
|key, lookup| try_execute_query(tcx, state, span, key, lookup, query),
638-
)
639-
}
640-
641615
/// Ensure that either this query has all green inputs or been executed.
642616
/// Executing `query::ensure(D)` is considered a read of the dep-node `D`.
643617
///
@@ -677,41 +651,6 @@ where
677651
}
678652
}
679653

680-
#[inline(never)]
681-
fn force_query_impl<CTX, C>(
682-
tcx: CTX,
683-
state: &QueryState<CTX, C>,
684-
key: C::Key,
685-
span: Span,
686-
dep_node: DepNode<CTX::DepKind>,
687-
query: &QueryVtable<CTX, C::Key, C::Value>,
688-
) where
689-
C: QueryCache,
690-
C::Key: Eq + Clone + crate::dep_graph::DepNodeParams<CTX>,
691-
CTX: QueryContext,
692-
{
693-
// We may be concurrently trying both execute and force a query.
694-
// Ensure that only one of them runs the query.
695-
696-
try_get_cached(
697-
tcx,
698-
state,
699-
key,
700-
|_, _| {
701-
// Cache hit, do nothing
702-
},
703-
|key, lookup| {
704-
let job = match JobOwner::try_start(tcx, state, span, &key, lookup, query) {
705-
TryGetJob::NotYetStarted(job) => job,
706-
TryGetJob::Cycle(_) => return,
707-
#[cfg(parallel_compiler)]
708-
TryGetJob::JobCompleted(_) => return,
709-
};
710-
force_query_with_job(tcx, key, job, dep_node, query);
711-
},
712-
);
713-
}
714-
715654
pub enum QueryCaller<DK> {
716655
Ensure,
717656
Get,
@@ -733,23 +672,58 @@ where
733672
C::Stored: Clone,
734673
CTX: QueryContext,
735674
{
736-
match caller {
737-
QueryCaller::Ensure => {
738-
if ensure_query_impl(tcx, &key, query) {
739-
return None;
740-
}
741-
let _ = get_query_impl(tcx, state, span, key, query);
742-
None
743-
}
744-
QueryCaller::Get => {
745-
let ret = get_query_impl(tcx, state, span, key, query);
746-
Some(ret)
747-
}
748-
QueryCaller::Force(dep_node) => {
749-
force_query_impl(tcx, state, key, span, dep_node, query);
750-
None
675+
if let QueryCaller::Ensure = caller {
676+
if ensure_query_impl(tcx, &key, query) {
677+
return None;
751678
}
752679
}
680+
681+
try_get_cached(
682+
tcx,
683+
state,
684+
key,
685+
|value, index| {
686+
match &caller {
687+
QueryCaller::Ensure => {
688+
tcx.dep_graph().read_index(index);
689+
None
690+
}
691+
QueryCaller::Get => {
692+
tcx.dep_graph().read_index(index);
693+
Some(value.clone())
694+
}
695+
QueryCaller::Force(_) => {
696+
// Cache hit, do nothing
697+
None
698+
}
699+
}
700+
},
701+
|key, lookup| {
702+
match &caller {
703+
QueryCaller::Ensure => {
704+
try_execute_query(tcx, state, span, key, lookup, query);
705+
None
706+
}
707+
QueryCaller::Get => {
708+
let value = try_execute_query(tcx, state, span, key, lookup, query);
709+
Some(value)
710+
}
711+
QueryCaller::Force(dep_node) => {
712+
// We may be concurrently trying both execute and force a query.
713+
// Ensure that only one of them runs the query.
714+
715+
let job = match JobOwner::try_start(tcx, state, span, &key, lookup, query) {
716+
TryGetJob::NotYetStarted(job) => job,
717+
TryGetJob::Cycle(_) => return None,
718+
#[cfg(parallel_compiler)]
719+
TryGetJob::JobCompleted(_) => return None,
720+
};
721+
force_query_with_job(tcx, key, job, *dep_node, query);
722+
None
723+
}
724+
}
725+
},
726+
)
753727
}
754728

755729
#[inline(always)]

0 commit comments

Comments
 (0)