Rollup merge of #138092 - lqd:revert-136731, r=SparrowLii

Re-add `DynSend` and `DynSync` impls for `TyCtxt`

They were somewhat unexpectedly removed in #136731. This PR adds them back, as requested in https://github.com/rust-lang/rust/pull/136731#issuecomment-2702504644. I've also tried to expand the comments a bit to make it less likely that they're removed again in the future.

r? `@SparrowLii`
This commit is contained in:
Michael Goulet 2025-03-06 15:40:06 -05:00 committed by GitHub
commit efd22c2236
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1327,6 +1327,11 @@ pub struct TyCtxt<'tcx> {
gcx: &'tcx GlobalCtxt<'tcx>,
}
// Explicitly implement `DynSync` and `DynSend` for `TyCtxt` to short circuit trait resolution. Its
// field are asserted to implement these traits below, so this is trivially safe, and it greatly
// speeds-up compilation of this crate and its dependents.
unsafe impl DynSend for TyCtxt<'_> {}
unsafe impl DynSync for TyCtxt<'_> {}
fn _assert_tcx_fields() {
sync::assert_dyn_sync::<&'_ GlobalCtxt<'_>>();
sync::assert_dyn_send::<&'_ GlobalCtxt<'_>>();