Skip to content

Commit

Permalink
Auto merge of #60967 - Zoxc:fix-syntax-sync, r=michaelwoerister
Browse files Browse the repository at this point in the history
Short circuit Send and Sync impls for TokenTree

Workaround to make the parallel compiler build after #60444.

r? @nikomatsakis
  • Loading branch information
bors committed May 27, 2019
2 parents ab7cf71 + 3ed0561 commit 4dbc7f9
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/libsyntax/tokenstream.rs
Expand Up @@ -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)
Expand Down

0 comments on commit 4dbc7f9

Please sign in to comment.