Simplify tls::enter_context.

This commit is contained in:
Nicholas Nethercote 2023-02-07 16:11:40 +11:00
parent ef934d9b63
commit f7b3e39502
5 changed files with 6 additions and 6 deletions

View file

@ -38,7 +38,7 @@ fn track_diagnostic(diagnostic: &mut Diagnostic, f: &mut dyn FnMut(&mut Diagnost
// Diagnostics are tracked, we can ignore the dependency.
let icx = tls::ImplicitCtxt { task_deps: TaskDepsRef::Ignore, ..icx.clone() };
return tls::enter_context(&icx, move |_| (*f)(diagnostic));
return tls::enter_context(&icx, move || (*f)(diagnostic));
}
// In any other case, invoke diagnostics anyway.

View file

@ -748,7 +748,7 @@ impl<'tcx> QueryContext<'tcx> {
F: FnOnce(TyCtxt<'tcx>) -> R,
{
let icx = ty::tls::ImplicitCtxt::new(self.gcx);
ty::tls::enter_context(&icx, |_| f(icx.tcx))
ty::tls::enter_context(&icx, || f(icx.tcx))
}
}

View file

@ -55,7 +55,7 @@ impl rustc_query_system::dep_graph::DepKind for DepKind {
ty::tls::with_context(|icx| {
let icx = ty::tls::ImplicitCtxt { task_deps, ..icx.clone() };
ty::tls::enter_context(&icx, |_| op())
ty::tls::enter_context(&icx, op)
})
}

View file

@ -110,9 +110,9 @@ unsafe fn downcast<'a, 'tcx>(context: *const ()) -> &'a ImplicitCtxt<'a, 'tcx> {
#[inline]
pub fn enter_context<'a, 'tcx, F, R>(context: &ImplicitCtxt<'a, 'tcx>, f: F) -> R
where
F: FnOnce(&ImplicitCtxt<'a, 'tcx>) -> R,
F: FnOnce() -> R,
{
tlv::with_tlv(erase(context), || f(&context))
tlv::with_tlv(erase(context), f)
}
/// Allows access to the current `ImplicitCtxt` in a closure if one is available.

View file

@ -124,7 +124,7 @@ impl QueryContext for QueryCtxt<'_> {
};
// Use the `ImplicitCtxt` while we execute the query.
tls::enter_context(&new_icx, |_| {
tls::enter_context(&new_icx, || {
rustc_data_structures::stack::ensure_sufficient_stack(compute)
})
})