Skip to content

Commit 820e3a8

Browse files
committed
Pass tcx directly
1 parent afe4c16 commit 820e3a8

File tree

3 files changed

+26
-37
lines changed

3 files changed

+26
-37
lines changed

Diff for: compiler/rustc_middle/src/dep_graph/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,13 @@ impl rustc_query_system::dep_graph::DepKind for DepKind {
7171
}
7272

7373
impl<'tcx> DepContext for TyCtxt<'tcx> {
74-
type Implicit<'a> = TyCtxt<'a>;
7574
type DepKind = DepKind;
7675

7776
#[inline]
7877
fn with_stable_hashing_context<R>(self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R {
7978
TyCtxt::with_stable_hashing_context(self, f)
8079
}
8180

82-
#[inline]
83-
fn with_context<R>(f: impl FnOnce(TyCtxt<'_>) -> R) -> R {
84-
ty::tls::with(|tcx| f(tcx))
85-
}
86-
8781
#[inline]
8882
fn dep_graph(&self) -> &DepGraph {
8983
&self.dep_graph

Diff for: compiler/rustc_query_system/src/dep_graph/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,11 @@ use std::{fmt, panic};
2323
use self::graph::{print_markframe_trace, MarkFrame};
2424

2525
pub trait DepContext: Copy {
26-
type Implicit<'a>: DepContext;
2726
type DepKind: self::DepKind;
2827

2928
/// Create a hashing context for hashing new results.
3029
fn with_stable_hashing_context<R>(self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R;
3130

32-
/// Access the implicit context.
33-
fn with_context<R>(f: impl FnOnce(Self::Implicit<'_>) -> R) -> R;
34-
3531
/// Access the DepGraph.
3632
fn dep_graph(&self) -> &DepGraph<Self::DepKind>;
3733

Diff for: compiler/rustc_query_system/src/query/plumbing.rs

+26-27
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ pub(crate) fn incremental_verify_ich<Tcx, V: Debug>(
641641
Tcx: DepContext,
642642
{
643643
if !dep_graph_data.is_index_green(prev_index) {
644-
incremental_verify_ich_not_green::<Tcx>(prev_index)
644+
incremental_verify_ich_not_green(tcx, prev_index)
645645
}
646646

647647
let new_hash = hash_result.map_or(Fingerprint::ZERO, |f| {
@@ -651,31 +651,32 @@ pub(crate) fn incremental_verify_ich<Tcx, V: Debug>(
651651
let old_hash = dep_graph_data.prev_fingerprint_of(prev_index);
652652

653653
if new_hash != old_hash {
654-
incremental_verify_ich_failed::<Tcx>(prev_index, result);
654+
incremental_verify_ich_failed(tcx, prev_index, result);
655655
}
656656
}
657657

658658
#[cold]
659659
#[inline(never)]
660-
fn incremental_verify_ich_not_green<Tcx>(prev_index: SerializedDepNodeIndex)
660+
fn incremental_verify_ich_not_green<Tcx>(tcx: Tcx, prev_index: SerializedDepNodeIndex)
661661
where
662662
Tcx: DepContext,
663663
{
664-
Tcx::with_context(|tcx| {
665-
panic!(
666-
"fingerprint for green query instance not loaded from cache: {:?}",
667-
tcx.dep_graph().data().unwrap().prev_node_of(prev_index)
668-
)
669-
})
664+
panic!(
665+
"fingerprint for green query instance not loaded from cache: {:?}",
666+
tcx.dep_graph().data().unwrap().prev_node_of(prev_index)
667+
)
670668
}
671669

672670
// Note that this is marked #[cold] and intentionally takes `dyn Debug` for `result`,
673671
// as we want to avoid generating a bunch of different implementations for LLVM to
674672
// chew on (and filling up the final binary, too).
675673
#[cold]
676674
#[inline(never)]
677-
fn incremental_verify_ich_failed<Tcx>(prev_index: SerializedDepNodeIndex, result: &dyn Debug)
678-
where
675+
fn incremental_verify_ich_failed<Tcx>(
676+
tcx: Tcx,
677+
prev_index: SerializedDepNodeIndex,
678+
result: &dyn Debug,
679+
) where
679680
Tcx: DepContext,
680681
{
681682
// When we emit an error message and panic, we try to debug-print the `DepNode`
@@ -690,25 +691,23 @@ where
690691

691692
let old_in_panic = INSIDE_VERIFY_PANIC.with(|in_panic| in_panic.replace(true));
692693

693-
Tcx::with_context(|tcx| {
694-
if old_in_panic {
695-
tcx.sess().emit_err(crate::error::Reentrant);
694+
if old_in_panic {
695+
tcx.sess().emit_err(crate::error::Reentrant);
696+
} else {
697+
let run_cmd = if let Some(crate_name) = &tcx.sess().opts.crate_name {
698+
format!("`cargo clean -p {crate_name}` or `cargo clean`")
696699
} else {
697-
let run_cmd = if let Some(crate_name) = &tcx.sess().opts.crate_name {
698-
format!("`cargo clean -p {crate_name}` or `cargo clean`")
699-
} else {
700-
"`cargo clean`".to_string()
701-
};
700+
"`cargo clean`".to_string()
701+
};
702702

703-
let dep_node = tcx.dep_graph().data().unwrap().prev_node_of(prev_index);
703+
let dep_node = tcx.dep_graph().data().unwrap().prev_node_of(prev_index);
704704

705-
let dep_node = tcx.sess().emit_err(crate::error::IncrementCompilation {
706-
run_cmd,
707-
dep_node: format!("{dep_node:?}"),
708-
});
709-
panic!("Found unstable fingerprints for {dep_node:?}: {result:?}");
710-
}
711-
});
705+
let dep_node = tcx.sess().emit_err(crate::error::IncrementCompilation {
706+
run_cmd,
707+
dep_node: format!("{dep_node:?}"),
708+
});
709+
panic!("Found unstable fingerprints for {dep_node:?}: {result:?}");
710+
}
712711

713712
INSIDE_VERIFY_PANIC.with(|in_panic| in_panic.set(old_in_panic));
714713
}

0 commit comments

Comments
 (0)