Skip to content

Commit 0240690

Browse files
committed
compiler/rustc_data_structures/src/sync/worker_local.rs: delete "unsafe impl Sync"
1 parent 51f49d8 commit 0240690

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Diff for: compiler/rustc_data_structures/src/sync/worker_local.rs

+5-6
Original file line numberDiff line numberDiff 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-
115109
impl<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
}

0 commit comments

Comments
 (0)