File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed
compiler/rustc_data_structures/src/sync Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -106,12 +106,6 @@ pub struct WorkerLocal<T> {
106106 registry : Registry ,
107107}
108108
109- // This is safe because the `deref` call will return a reference to a `T` unique to each thread
110- // or it will panic for threads without an associated local. So there isn't a need for `T` to do
111- // it's own synchronization. The `verify` method on `RegistryId` has an issue where the id
112- // can be reused, but `WorkerLocal` has a reference to `Registry` which will prevent any reuse.
113- unsafe impl < T : Send > Sync for WorkerLocal < T > { }
114-
115109impl < T > WorkerLocal < T > {
116110 /// Creates a new worker local where the `initial` closure computes the
117111 /// value this worker local should take for each thread in the registry.
@@ -138,6 +132,11 @@ impl<T> Deref for WorkerLocal<T> {
138132 fn deref ( & self ) -> & T {
139133 // This is safe because `verify` will only return values less than
140134 // `self.registry.thread_limit` which is the size of the `self.locals` array.
135+
136+ // The `deref` call will return a reference to a `T` unique to each thread
137+ // or it will panic for threads without an associated local. So there isn't a need for `T` to do
138+ // it's own synchronization. The `verify` method on `RegistryId` has an issue where the id
139+ // can be reused, but `WorkerLocal` has a reference to `Registry` which will prevent any reuse.
141140 unsafe { & self . locals . get_unchecked ( self . registry . id ( ) . verify ( ) ) . 0 }
142141 }
143142}
You can’t perform that action at this time.
0 commit comments