diff options
| author | Michael Goulet <michael@errs.io> | 2025-03-06 15:40:06 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-06 15:40:06 -0500 |
| commit | efd22c2236f94198652a5baeb00cd1090f14efac (patch) | |
| tree | 3b84ff8d8b30eaea1a9ddced97521e1be992f31f | |
| parent | 184c2b0e258a4c647d221b812ff5c0f3b5cbea1d (diff) | |
| parent | 7d6bbe2df788d9c23aef1384bc1c8b240253ae7b (diff) | |
| download | rust-efd22c2236f94198652a5baeb00cd1090f14efac.tar.gz rust-efd22c2236f94198652a5baeb00cd1090f14efac.zip | |
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`
| -rw-r--r-- | compiler/rustc_middle/src/ty/context.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index d0aa2b8cbda..4013f7b2c85 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -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<'_>>(); |
