diff options
| author | bors <bors@rust-lang.org> | 2023-08-24 17:43:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-24 17:43:02 +0000 |
| commit | b60e31b673b0d36c50f8e0a3b6f8f077221d983d (patch) | |
| tree | 60f027079679c46e265b16bbbf915d2972f6e508 /compiler/rustc_data_structures/src/sync | |
| parent | aa5dbee3ebff8703456e8be3b5fb368fc68fe0d1 (diff) | |
| parent | 246a6a6589b118c0a08e449f981bb4ae07bc089a (diff) | |
| download | rust-b60e31b673b0d36c50f8e0a3b6f8f077221d983d.tar.gz rust-b60e31b673b0d36c50f8e0a3b6f8f077221d983d.zip | |
Auto merge of #115082 - Zoxc:syntax-context-decode-race, r=cjgillot
Fix races conditions with `SyntaxContext` decoding This changes `SyntaxContext` decoding to work with concurrent decoding. The `remapped_ctxts` field now only stores `SyntaxContext` which have completed decoding, while the new `decoding` and `local_in_progress` keeps track of `SyntaxContext`s which are in process of being decoding and on which threads. This fixes 2 issues with the current implementation. It can return an `SyntaxContext` which contains dummy data if another thread starts decoding before the first one has completely finished. Multiple threads could also allocate multiple `SyntaxContext`s for the same `raw_id`.
Diffstat (limited to 'compiler/rustc_data_structures/src/sync')
| -rw-r--r-- | compiler/rustc_data_structures/src/sync/worker_local.rs | 6 |
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()) + } +} |
