diff --git a/compiler/rustc_middle/src/query/plumbing.rs b/compiler/rustc_middle/src/query/plumbing.rs index 1c157f33a813b..9ac8bf40ea89e 100644 --- a/compiler/rustc_middle/src/query/plumbing.rs +++ b/compiler/rustc_middle/src/query/plumbing.rs @@ -150,13 +150,12 @@ pub fn query_ensure<'tcx, Cache>( execute_query: fn(TyCtxt<'tcx>, Span, Cache::Key, QueryMode) -> Option, query_cache: &Cache, key: Cache::Key, - check_cache: bool, ) where Cache: QueryCache, { let key = key.into_query_param(); if try_get_cached(tcx, query_cache, &key).is_none() { - execute_query(tcx, DUMMY_SP, key, QueryMode::Ensure { check_cache }); + execute_query(tcx, DUMMY_SP, key, QueryMode::Ensure); } } @@ -166,7 +165,6 @@ pub fn query_ensure_error_guaranteed<'tcx, Cache, T>( execute_query: fn(TyCtxt<'tcx>, Span, Cache::Key, QueryMode) -> Option, query_cache: &Cache, key: Cache::Key, - check_cache: bool, ) -> Result<(), ErrorGuaranteed> where Cache: QueryCache>>, @@ -176,7 +174,7 @@ where if let Some(res) = try_get_cached(tcx, query_cache, &key) { super::erase::restore(res).map(drop) } else { - execute_query(tcx, DUMMY_SP, key, QueryMode::Ensure { check_cache }) + execute_query(tcx, DUMMY_SP, key, QueryMode::Ensure) .map(super::erase::restore) .map(|res| res.map(drop)) // Either we actually executed the query, which means we got a full `Result`, @@ -393,7 +391,6 @@ macro_rules! define_callbacks { self.tcx.query_system.fns.engine.$name, &self.tcx.query_system.caches.$name, key.into_query_param(), - false, ) })* } @@ -402,13 +399,8 @@ macro_rules! define_callbacks { $($(#[$attr])* #[inline(always)] pub fn $name(self, key: query_helper_param_ty!($($K)*)) { - query_ensure( - self.tcx, - self.tcx.query_system.fns.engine.$name, - &self.tcx.query_system.caches.$name, - key.into_query_param(), - true, - ); + // Just call the query normally, and discard its result. + let _ = self.tcx.$name(key); })* } diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index 6fb5e37d2d066..7b77b1435e910 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -743,12 +743,7 @@ fn incremental_verify_ich_failed( /// /// Note: The optimization is only available during incr. comp. #[inline(never)] -fn ensure_must_run( - query: Q, - qcx: Qcx, - key: &Q::Key, - check_cache: bool, -) -> (bool, Option) +fn ensure_must_run(query: Q, qcx: Qcx, key: &Q::Key) -> (bool, Option) where Q: QueryConfig, Qcx: QueryContext, @@ -763,7 +758,7 @@ where let dep_node = query.construct_dep_node(*qcx.dep_context(), key); let dep_graph = qcx.dep_context().dep_graph(); - let serialized_dep_node_index = match dep_graph.try_mark_green(qcx, &dep_node) { + match dep_graph.try_mark_green(qcx, &dep_node) { None => { // A None return from `try_mark_green` means that this is either // a new dep node or that the dep node has already been marked red. @@ -773,26 +768,17 @@ where // in-memory cache, or another query down the line will. return (true, Some(dep_node)); } - Some((serialized_dep_node_index, dep_node_index)) => { - dep_graph.read_index(dep_node_index); - qcx.dep_context().profiler().query_cache_hit(dep_node_index.into()); - serialized_dep_node_index - } + Some(_) => {} }; // We do not need the value at all, so do not check the cache. - if !check_cache { - return (false, None); - } - - let loadable = query.loadable_from_disk(qcx, key, serialized_dep_node_index); - (!loadable, Some(dep_node)) + (false, None) } #[derive(Debug)] pub enum QueryMode { Get, - Ensure { check_cache: bool }, + Ensure, } #[inline(always)] @@ -820,19 +806,18 @@ where { debug_assert!(qcx.dep_context().dep_graph().is_fully_enabled()); - let dep_node = if let QueryMode::Ensure { check_cache } = mode { - let (must_run, dep_node) = ensure_must_run(query, qcx, &key, check_cache); - if !must_run { - return None; + match mode { + QueryMode::Ensure => { + let (must_run, _) = ensure_must_run(query, qcx, &key); + if !must_run { + return None; + } } - dep_node - } else { - None - }; + QueryMode::Get => {} + } - let (result, dep_node_index) = ensure_sufficient_stack(|| { - try_execute_query::<_, _, true>(query, qcx, span, key, dep_node) - }); + let (result, dep_node_index) = + ensure_sufficient_stack(|| try_execute_query::<_, _, true>(query, qcx, span, key, None)); if let Some(dep_node_index) = dep_node_index { qcx.dep_context().dep_graph().read_index(dep_node_index) }