about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-05-27 09:49:18 +0000
committerbors <bors@rust-lang.org>2019-05-27 09:49:18 +0000
commit4dbc7f96d6438b93c9274675b276cfe934164704 (patch)
tree56f7319cbbcdb54a4639d54079b6093a8736d395
parentab7cf71d4c6dd1696cb0eb52ad172bce296578cc (diff)
parent3ed05613eeadd6baf332f6d4021c1973cb37ac21 (diff)
downloadrust-4dbc7f96d6438b93c9274675b276cfe934164704.tar.gz
rust-4dbc7f96d6438b93c9274675b276cfe934164704.zip
Auto merge of #60967 - Zoxc:fix-syntax-sync, r=michaelwoerister
Short circuit Send and Sync impls for TokenTree

Workaround to make the parallel compiler build after https://github.com/rust-lang/rust/pull/60444.

r? @nikomatsakis
-rw-r--r--src/libsyntax/tokenstream.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs
index 79efc6bf689..397fb45513c 100644
--- a/src/libsyntax/tokenstream.rs
+++ b/src/libsyntax/tokenstream.rs
@@ -49,6 +49,28 @@ pub enum TokenTree {
     Delimited(DelimSpan, DelimToken, TokenStream),
 }
 
+// Ensure all fields of `TokenTree` is `Send` and `Sync`.
+#[cfg(parallel_compiler)]
+fn _dummy()
+where
+    Span: Send + Sync,
+    token::Token: Send + Sync,
+    DelimSpan: Send + Sync,
+    DelimToken: Send + Sync,
+    TokenStream: Send + Sync,
+{}
+
+// These are safe since we ensure that they hold for all fields in the `_dummy` function.
+//
+// These impls are only here because the compiler takes forever to compute the Send and Sync
+// bounds without them.
+// FIXME: Remove these impls when the compiler can compute the bounds quickly again.
+// See https://github.com/rust-lang/rust/issues/60846
+#[cfg(parallel_compiler)]
+unsafe impl Send for TokenTree {}
+#[cfg(parallel_compiler)]
+unsafe impl Sync for TokenTree {}
+
 impl TokenTree {
     /// Use this token tree as a matcher to parse given tts.
     pub fn parse(cx: &base::ExtCtxt<'_>, mtch: &[quoted::TokenTree], tts: TokenStream)