about summary refs log tree commit diff
path: root/compiler/rustc_data_structures
diff options
context:
space:
mode:
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2023-08-22 02:36:41 +0200
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2023-08-22 02:36:41 +0200
commite41240e45b58ea1bcf42fe5503cafec4c9dca1a8 (patch)
tree815719e8c418e8714182863ab55fa53a51f54de6 /compiler/rustc_data_structures
parentef85656a10657ba5e4f7fe2931a4ca6293138d51 (diff)
downloadrust-e41240e45b58ea1bcf42fe5503cafec4c9dca1a8.tar.gz
rust-e41240e45b58ea1bcf42fe5503cafec4c9dca1a8.zip
Fix races conditions with `SyntaxContext` decoding
Diffstat (limited to 'compiler/rustc_data_structures')
-rw-r--r--compiler/rustc_data_structures/src/sync/worker_local.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_data_structures/src/sync/worker_local.rs b/compiler/rustc_data_structures/src/sync/worker_local.rs
index 8c84daf4f16..27d687c3cfe 100644
--- a/compiler/rustc_data_structures/src/sync/worker_local.rs
+++ b/compiler/rustc_data_structures/src/sync/worker_local.rs
@@ -171,3 +171,9 @@ impl<T> Deref for WorkerLocal<T> {
         unsafe { &self.locals.get_unchecked(self.registry.id().verify()).0 }
     }
 }
+
+impl<T: Default> Default for WorkerLocal<T> {
+    fn default() -> Self {
+        WorkerLocal::new(|_| T::default())
+    }
+}