Skip to content

Commit c4e8f18

Browse files
committed
Remove with_related_context.
There is only one GlobalCtxt ever.
1 parent 284cb71 commit c4e8f18

File tree

2 files changed

+3
-28
lines changed

2 files changed

+3
-28
lines changed

compiler/rustc_middle/src/ty/context/tls.rs

-25
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ use rustc_data_structures::sync::{self, Lock};
66
use rustc_errors::Diagnostic;
77
#[cfg(not(parallel_compiler))]
88
use std::cell::Cell;
9-
use std::mem;
10-
use std::ptr;
119
use thin_vec::ThinVec;
1210

1311
/// This is the implicit state of rustc. It contains the current
@@ -111,29 +109,6 @@ where
111109
with_context_opt(|opt_context| f(opt_context.expect("no ImplicitCtxt stored in tls")))
112110
}
113111

114-
/// Allows access to the current `ImplicitCtxt` whose tcx field is the same as the tcx argument
115-
/// passed in. This means the closure is given an `ImplicitCtxt` with the same `'tcx` lifetime
116-
/// as the `TyCtxt` passed in.
117-
/// This will panic if you pass it a `TyCtxt` which is different from the current
118-
/// `ImplicitCtxt`'s `tcx` field.
119-
#[inline]
120-
pub fn with_related_context<'tcx, F, R>(tcx: TyCtxt<'tcx>, f: F) -> R
121-
where
122-
F: FnOnce(&ImplicitCtxt<'_, 'tcx>) -> R,
123-
{
124-
with_context(|context| {
125-
// The two gcx have different invariant lifetimes, so we need to erase them for the comparison.
126-
assert!(ptr::eq(
127-
context.tcx.gcx as *const _ as *const (),
128-
tcx.gcx as *const _ as *const ()
129-
));
130-
131-
let context: &ImplicitCtxt<'_, '_> = unsafe { mem::transmute(context) };
132-
133-
f(context)
134-
})
135-
}
136-
137112
/// Allows access to the `TyCtxt` in the current `ImplicitCtxt`.
138113
/// Panics if there is no `ImplicitCtxt` available.
139114
#[inline]

compiler/rustc_query_impl/src/plumbing.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl QueryContext for QueryCtxt<'_> {
7777

7878
#[inline]
7979
fn current_query_job(self) -> Option<QueryJobId> {
80-
tls::with_related_context(self.tcx, |icx| icx.query)
80+
tls::with_context(|icx| icx.query)
8181
}
8282

8383
fn collect_active_jobs(self) -> QueryMap {
@@ -131,9 +131,9 @@ impl QueryContext for QueryCtxt<'_> {
131131
compute: impl FnOnce() -> R,
132132
) -> R {
133133
// The `TyCtxt` stored in TLS has the same global interner lifetime
134-
// as `self`, so we use `with_related_context` to relate the 'tcx lifetimes
134+
// as `self`, so we use `with_context` to relate the 'tcx lifetimes
135135
// when accessing the `ImplicitCtxt`.
136-
tls::with_related_context(self.tcx, move |current_icx| {
136+
tls::with_context(move |current_icx| {
137137
if depth_limit && !self.recursion_limit().value_within_limit(current_icx.query_depth) {
138138
self.depth_limit_error(token);
139139
}

0 commit comments

Comments
 (0)