Skip to content

Commit 449f8ef

Browse files
committed
Move get_query_impl out of ensure_query_impl.
1 parent 060f15c commit 449f8ef

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

compiler/rustc_query_system/src/query/plumbing.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use rustc_data_structures::sharded::Sharded;
1717
use rustc_data_structures::sync::{Lock, LockGuard};
1818
use rustc_data_structures::thin_vec::ThinVec;
1919
use rustc_errors::{Diagnostic, FatalError};
20-
use rustc_span::source_map::DUMMY_SP;
2120
use rustc_span::Span;
2221
use std::collections::hash_map::Entry;
2322
use std::convert::TryFrom;
@@ -647,25 +646,19 @@ where
647646
///
648647
/// Note: The optimization is only available during incr. comp.
649648
#[inline(never)]
650-
fn ensure_query_impl<CTX, C>(
651-
tcx: CTX,
652-
state: &QueryState<CTX, C>,
653-
key: C::Key,
654-
query: &QueryVtable<CTX, C::Key, C::Value>,
655-
) where
656-
C: QueryCache,
657-
C::Key: Eq + Clone + crate::dep_graph::DepNodeParams<CTX>,
649+
fn ensure_query_impl<CTX, K, V>(tcx: CTX, key: &K, query: &QueryVtable<CTX, K, V>) -> bool
650+
where
651+
K: Eq + Clone + crate::dep_graph::DepNodeParams<CTX>,
658652
CTX: QueryContext,
659653
{
660654
if query.eval_always {
661-
let _ = get_query_impl(tcx, state, DUMMY_SP, key, query);
662-
return;
655+
return false;
663656
}
664657

665658
// Ensuring an anonymous query makes no sense
666659
assert!(!query.anon);
667660

668-
let dep_node = query.to_dep_node(tcx, &key);
661+
let dep_node = query.to_dep_node(tcx, key);
669662

670663
match tcx.dep_graph().try_mark_green_and_read(tcx, &dep_node) {
671664
None => {
@@ -675,10 +668,11 @@ fn ensure_query_impl<CTX, C>(
675668
// DepNodeIndex. We must invoke the query itself. The performance cost
676669
// this introduces should be negligible as we'll immediately hit the
677670
// in-memory cache, or another query down the line will.
678-
let _ = get_query_impl(tcx, state, DUMMY_SP, key, query);
671+
false
679672
}
680673
Some((_, dep_node_index)) => {
681674
tcx.profiler().query_cache_hit(dep_node_index.into());
675+
true
682676
}
683677
}
684678
}
@@ -741,7 +735,10 @@ where
741735
{
742736
match caller {
743737
QueryCaller::Ensure => {
744-
ensure_query_impl(tcx, state, key, query);
738+
if ensure_query_impl(tcx, &key, query) {
739+
return None;
740+
}
741+
let _ = get_query_impl(tcx, state, span, key, query);
745742
None
746743
}
747744
QueryCaller::Get => {

0 commit comments

Comments
 (0)