Skip to content
Browse files

Short circuit Send and Sync impls for TokenTree

  • Loading branch information...
Zoxc committed May 19, 2019
1 parent be10e62 commit 3ed05613eeadd6baf332f6d4021c1973cb37ac21
Showing with 22 additions and 0 deletions.
  1. +22 −0 src/libsyntax/
@@ -49,6 +49,28 @@ pub enum TokenTree {
Delimited(DelimSpan, DelimToken, TokenStream),

// Ensure all fields of `TokenTree` is `Send` and `Sync`.
fn _dummy()
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
unsafe impl Send for TokenTree {}
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)

0 comments on commit 3ed0561

Please sign in to comment.
You can’t perform that action at this time.