From 820e3a8d6aec53d8f5f451e43cd1ef87bd29dc0a Mon Sep 17 00:00:00 2001 From: John Kåre Alsaker Date: Sat, 25 Mar 2023 03:13:05 +0100 Subject: Pass `tcx` directly --- compiler/rustc_query_system/src/dep_graph/mod.rs | 4 -- compiler/rustc_query_system/src/query/plumbing.rs | 53 +++++++++++------------ 2 files changed, 26 insertions(+), 31 deletions(-) (limited to 'compiler/rustc_query_system') diff --git a/compiler/rustc_query_system/src/dep_graph/mod.rs b/compiler/rustc_query_system/src/dep_graph/mod.rs index 246ec994e57..40e7131987f 100644 --- a/compiler/rustc_query_system/src/dep_graph/mod.rs +++ b/compiler/rustc_query_system/src/dep_graph/mod.rs @@ -23,15 +23,11 @@ use std::{fmt, panic}; use self::graph::{print_markframe_trace, MarkFrame}; pub trait DepContext: Copy { - type Implicit<'a>: DepContext; type DepKind: self::DepKind; /// Create a hashing context for hashing new results. fn with_stable_hashing_context(self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R; - /// Access the implicit context. - fn with_context(f: impl FnOnce(Self::Implicit<'_>) -> R) -> R; - /// Access the DepGraph. fn dep_graph(&self) -> &DepGraph; diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index 8465696d301..186417e862a 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -641,7 +641,7 @@ pub(crate) fn incremental_verify_ich( Tcx: DepContext, { if !dep_graph_data.is_index_green(prev_index) { - incremental_verify_ich_not_green::(prev_index) + incremental_verify_ich_not_green(tcx, prev_index) } let new_hash = hash_result.map_or(Fingerprint::ZERO, |f| { @@ -651,22 +651,20 @@ pub(crate) fn incremental_verify_ich( let old_hash = dep_graph_data.prev_fingerprint_of(prev_index); if new_hash != old_hash { - incremental_verify_ich_failed::(prev_index, result); + incremental_verify_ich_failed(tcx, prev_index, result); } } #[cold] #[inline(never)] -fn incremental_verify_ich_not_green(prev_index: SerializedDepNodeIndex) +fn incremental_verify_ich_not_green(tcx: Tcx, prev_index: SerializedDepNodeIndex) where Tcx: DepContext, { - Tcx::with_context(|tcx| { - panic!( - "fingerprint for green query instance not loaded from cache: {:?}", - tcx.dep_graph().data().unwrap().prev_node_of(prev_index) - ) - }) + panic!( + "fingerprint for green query instance not loaded from cache: {:?}", + tcx.dep_graph().data().unwrap().prev_node_of(prev_index) + ) } // Note that this is marked #[cold] and intentionally takes `dyn Debug` for `result`, @@ -674,8 +672,11 @@ where // chew on (and filling up the final binary, too). #[cold] #[inline(never)] -fn incremental_verify_ich_failed(prev_index: SerializedDepNodeIndex, result: &dyn Debug) -where +fn incremental_verify_ich_failed( + tcx: Tcx, + prev_index: SerializedDepNodeIndex, + result: &dyn Debug, +) where Tcx: DepContext, { // When we emit an error message and panic, we try to debug-print the `DepNode` @@ -690,25 +691,23 @@ where let old_in_panic = INSIDE_VERIFY_PANIC.with(|in_panic| in_panic.replace(true)); - Tcx::with_context(|tcx| { - if old_in_panic { - tcx.sess().emit_err(crate::error::Reentrant); + if old_in_panic { + tcx.sess().emit_err(crate::error::Reentrant); + } else { + let run_cmd = if let Some(crate_name) = &tcx.sess().opts.crate_name { + format!("`cargo clean -p {crate_name}` or `cargo clean`") } else { - let run_cmd = if let Some(crate_name) = &tcx.sess().opts.crate_name { - format!("`cargo clean -p {crate_name}` or `cargo clean`") - } else { - "`cargo clean`".to_string() - }; + "`cargo clean`".to_string() + }; - let dep_node = tcx.dep_graph().data().unwrap().prev_node_of(prev_index); + let dep_node = tcx.dep_graph().data().unwrap().prev_node_of(prev_index); - let dep_node = tcx.sess().emit_err(crate::error::IncrementCompilation { - run_cmd, - dep_node: format!("{dep_node:?}"), - }); - panic!("Found unstable fingerprints for {dep_node:?}: {result:?}"); - } - }); + let dep_node = tcx.sess().emit_err(crate::error::IncrementCompilation { + run_cmd, + dep_node: format!("{dep_node:?}"), + }); + panic!("Found unstable fingerprints for {dep_node:?}: {result:?}"); + } INSIDE_VERIFY_PANIC.with(|in_panic| in_panic.set(old_in_panic)); } -- cgit 1.4.1-3-g733a5