Skip to content

Commit afbe167

Browse files
committed
Avoid some tls::with calls.
These are in places where a `tcx` is easily obtained.
1 parent 18f751d commit afbe167

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
5454

5555
trace!(
5656
"eval_body_using_ecx: pushing stack frame for global: {}{}",
57-
with_no_trimmed_paths!(ty::tls::with(|tcx| tcx.def_path_str(cid.instance.def_id()))),
57+
with_no_trimmed_paths!(ecx.tcx.def_path_str(cid.instance.def_id())),
5858
cid.promoted.map_or_else(String::new, |p| format!("::promoted[{:?}]", p))
5959
);
6060

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,10 @@ impl CanonicalizeMode for CanonicalizeQueryResponse {
203203
// rust-lang/rust#57464: `impl Trait` can leak local
204204
// scopes (in manner violating typeck). Therefore, use
205205
// `delay_span_bug` to allow type error over an ICE.
206-
ty::tls::with(|tcx| {
207-
tcx.sess.delay_span_bug(
208-
rustc_span::DUMMY_SP,
209-
&format!("unexpected region in query response: `{:?}`", r),
210-
);
211-
});
206+
canonicalizer.tcx.sess.delay_span_bug(
207+
rustc_span::DUMMY_SP,
208+
&format!("unexpected region in query response: `{:?}`", r),
209+
);
212210
r
213211
}
214212
}

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ impl<'tcx, 'a> GeneratorData<'tcx, 'a> {
9898
// obligation
9999
fn get_from_await_ty<F>(
100100
&self,
101+
tcx: TyCtxt<'tcx>,
101102
visitor: AwaitsVisitor,
102103
hir: map::Map<'tcx>,
103104
ty_matches: F,
@@ -134,9 +135,7 @@ impl<'tcx, 'a> GeneratorData<'tcx, 'a> {
134135
.unwrap_or_else(|| {
135136
bug!(
136137
"node_type: no type for node {}",
137-
ty::tls::with(|tcx| tcx
138-
.hir()
139-
.node_to_string(await_expr.hir_id))
138+
tcx.hir().node_to_string(await_expr.hir_id)
140139
)
141140
})
142141
},
@@ -2351,7 +2350,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
23512350

23522351
let mut interior_or_upvar_span = None;
23532352

2354-
let from_awaited_ty = generator_data.get_from_await_ty(visitor, hir, ty_matches);
2353+
let from_awaited_ty = generator_data.get_from_await_ty(self.tcx, visitor, hir, ty_matches);
23552354
debug!(?from_awaited_ty);
23562355

23572356
// The generator interior types share the same binders

0 commit comments

Comments
 (0)