Avoid some tls::with calls.

These are in places where a `tcx` is easily obtained.
This commit is contained in:
Nicholas Nethercote
2023-02-09 10:51:29 +11:00
parent 18f751df6a
commit afbe167fbb
3 changed files with 8 additions and 11 deletions
@@ -54,7 +54,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
trace!(
"eval_body_using_ecx: pushing stack frame for global: {}{}",
with_no_trimmed_paths!(ty::tls::with(|tcx| tcx.def_path_str(cid.instance.def_id()))),
with_no_trimmed_paths!(ecx.tcx.def_path_str(cid.instance.def_id())),
cid.promoted.map_or_else(String::new, |p| format!("::promoted[{:?}]", p))
);
@@ -203,12 +203,10 @@ fn canonicalize_free_region<'tcx>(
// rust-lang/rust#57464: `impl Trait` can leak local
// scopes (in manner violating typeck). Therefore, use
// `delay_span_bug` to allow type error over an ICE.
ty::tls::with(|tcx| {
tcx.sess.delay_span_bug(
rustc_span::DUMMY_SP,
&format!("unexpected region in query response: `{:?}`", r),
);
});
canonicalizer.tcx.sess.delay_span_bug(
rustc_span::DUMMY_SP,
&format!("unexpected region in query response: `{:?}`", r),
);
r
}
}
@@ -98,6 +98,7 @@ fn try_get_upvar_span<F>(
// obligation
fn get_from_await_ty<F>(
&self,
tcx: TyCtxt<'tcx>,
visitor: AwaitsVisitor,
hir: map::Map<'tcx>,
ty_matches: F,
@@ -134,9 +135,7 @@ fn get_from_await_ty<F>(
.unwrap_or_else(|| {
bug!(
"node_type: no type for node {}",
ty::tls::with(|tcx| tcx
.hir()
.node_to_string(await_expr.hir_id))
tcx.hir().node_to_string(await_expr.hir_id)
)
})
},
@@ -2351,7 +2350,7 @@ fn maybe_note_obligation_cause_for_async_await(
let mut interior_or_upvar_span = None;
let from_awaited_ty = generator_data.get_from_await_ty(visitor, hir, ty_matches);
let from_awaited_ty = generator_data.get_from_await_ty(self.tcx, visitor, hir, ty_matches);
debug!(?from_awaited_ty);
// The generator interior types share the same binders