File tree 1 file changed +5
-6
lines changed
compiler/rustc_data_structures/src/sync
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> {
106
106
registry : Registry ,
107
107
}
108
108
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
-
115
109
impl < T > WorkerLocal < T > {
116
110
/// Creates a new worker local where the `initial` closure computes the
117
111
/// value this worker local should take for each thread in the registry.
@@ -138,6 +132,11 @@ impl<T> Deref for WorkerLocal<T> {
138
132
fn deref ( & self ) -> & T {
139
133
// This is safe because `verify` will only return values less than
140
134
// `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.
141
140
unsafe { & self . locals . get_unchecked ( self . registry . id ( ) . verify ( ) ) . 0 }
142
141
}
143
142
}
You can’t perform that action at this time.
0 commit comments