Skip to content

Commit efd22c2

Browse files
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 #136731 (comment). 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`
2 parents 184c2b0 + 7d6bbe2 commit efd22c2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

compiler/rustc_middle/src/ty/context.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,11 @@ pub struct TyCtxt<'tcx> {
13271327
gcx: &'tcx GlobalCtxt<'tcx>,
13281328
}
13291329

1330+
// Explicitly implement `DynSync` and `DynSend` for `TyCtxt` to short circuit trait resolution. Its
1331+
// field are asserted to implement these traits below, so this is trivially safe, and it greatly
1332+
// speeds-up compilation of this crate and its dependents.
1333+
unsafe impl DynSend for TyCtxt<'_> {}
1334+
unsafe impl DynSync for TyCtxt<'_> {}
13301335
fn _assert_tcx_fields() {
13311336
sync::assert_dyn_sync::<&'_ GlobalCtxt<'_>>();
13321337
sync::assert_dyn_send::<&'_ GlobalCtxt<'_>>();

0 commit comments

Comments
 (0)