Skip to content

Commit 3fa69c9

Browse files
committed
Make Span and Symbol implement Send and Sync
1 parent f53d4af commit 3fa69c9

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/libsyntax_pos/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,12 @@ impl SpanData {
184184
}
185185
}
186186

187-
// The interner in thread-local, so `Span` shouldn't move between threads.
187+
// The interner is pointed to by a thread local value which is only set on the main thread
188+
// with parallelization is disabled. So we don't allow Span to transfer between threads
189+
// to avoid panics and other errors, even though it would be memory safe to do so.
190+
#[cfg(not(parallel_queries))]
188191
impl !Send for Span {}
192+
#[cfg(not(parallel_queries))]
189193
impl !Sync for Span {}
190194

191195
impl PartialOrd for Span {

src/libsyntax_pos/symbol.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,12 @@ impl Decodable for Ident {
8383
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
8484
pub struct Symbol(u32);
8585

86-
// The interner in thread-local, so `Symbol` shouldn't move between threads.
86+
// The interner is pointed to by a thread local value which is only set on the main thread
87+
// with parallelization is disabled. So we don't allow Symbol to transfer between threads
88+
// to avoid panics and other errors, even though it would be memory safe to do so.
89+
#[cfg(not(parallel_queries))]
8790
impl !Send for Symbol { }
91+
#[cfg(not(parallel_queries))]
8892
impl !Sync for Symbol { }
8993

9094
impl Symbol {

0 commit comments

Comments
 (0)