about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2023-03-25 03:13:05 +0100
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2023-03-25 03:13:05 +0100
commit820e3a8d6aec53d8f5f451e43cd1ef87bd29dc0a (patch)
treed9929e0402908250e28e5fdc625b314afea9386e /compiler
parentafe4c16b294312b7aeb920e9a988a3eaca580d3b (diff)
downloadrust-820e3a8d6aec53d8f5f451e43cd1ef87bd29dc0a.tar.gz
rust-820e3a8d6aec53d8f5f451e43cd1ef87bd29dc0a.zip
Pass `tcx` directly
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_middle/src/dep_graph/mod.rs6
-rw-r--r--compiler/rustc_query_system/src/dep_graph/mod.rs4
-rw-r--r--compiler/rustc_query_system/src/query/plumbing.rs53
3 files changed, 26 insertions, 37 deletions
diff --git a/compiler/rustc_middle/src/dep_graph/mod.rs b/compiler/rustc_middle/src/dep_graph/mod.rs
index 6ecfda4a1bf..84510fe218c 100644
--- a/compiler/rustc_middle/src/dep_graph/mod.rs
+++ b/compiler/rustc_middle/src/dep_graph/mod.rs
@@ -71,7 +71,6 @@ impl rustc_query_system::dep_graph::DepKind for DepKind {
 }
 
 impl<'tcx> DepContext for TyCtxt<'tcx> {
-    type Implicit<'a> = TyCtxt<'a>;
     type DepKind = DepKind;
 
     #[inline]
@@ -80,11 +79,6 @@ impl<'tcx> DepContext for TyCtxt<'tcx> {
     }
 
     #[inline]
-    fn with_context<R>(f: impl FnOnce(TyCtxt<'_>) -> R) -> R {
-        ty::tls::with(|tcx| f(tcx))
-    }
-
-    #[inline]
     fn dep_graph(&self) -> &DepGraph {
         &self.dep_graph
     }
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<R>(self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R;
 
-    /// Access the implicit context.
-    fn with_context<R>(f: impl FnOnce(Self::Implicit<'_>) -> R) -> R;
-
     /// Access the DepGraph.
     fn dep_graph(&self) -> &DepGraph<Self::DepKind>;
 
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, V: Debug>(
     Tcx: DepContext,
 {
     if !dep_graph_data.is_index_green(prev_index) {
-        incremental_verify_ich_not_green::<Tcx>(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<Tcx, V: Debug>(
     let old_hash = dep_graph_data.prev_fingerprint_of(prev_index);
 
     if new_hash != old_hash {
-        incremental_verify_ich_failed::<Tcx>(prev_index, result);
+        incremental_verify_ich_failed(tcx, prev_index, result);
     }
 }
 
 #[cold]
 #[inline(never)]
-fn incremental_verify_ich_not_green<Tcx>(prev_index: SerializedDepNodeIndex)
+fn incremental_verify_ich_not_green<Tcx>(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<Tcx>(prev_index: SerializedDepNodeIndex, result: &dyn Debug)
-where
+fn incremental_verify_ich_failed<Tcx>(
+    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));
 }