Skip to content

Commit 4dbc7f9

Browse files
committed
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 #60444. r? @nikomatsakis
2 parents ab7cf71 + 3ed0561 commit 4dbc7f9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/libsyntax/tokenstream.rs

+22
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,28 @@ pub enum TokenTree {
4949
Delimited(DelimSpan, DelimToken, TokenStream),
5050
}
5151

52+
// Ensure all fields of `TokenTree` is `Send` and `Sync`.
53+
#[cfg(parallel_compiler)]
54+
fn _dummy()
55+
where
56+
Span: Send + Sync,
57+
token::Token: Send + Sync,
58+
DelimSpan: Send + Sync,
59+
DelimToken: Send + Sync,
60+
TokenStream: Send + Sync,
61+
{}
62+
63+
// These are safe since we ensure that they hold for all fields in the `_dummy` function.
64+
//
65+
// These impls are only here because the compiler takes forever to compute the Send and Sync
66+
// bounds without them.
67+
// FIXME: Remove these impls when the compiler can compute the bounds quickly again.
68+
// See https://github.com/rust-lang/rust/issues/60846
69+
#[cfg(parallel_compiler)]
70+
unsafe impl Send for TokenTree {}
71+
#[cfg(parallel_compiler)]
72+
unsafe impl Sync for TokenTree {}
73+
5274
impl TokenTree {
5375
/// Use this token tree as a matcher to parse given tts.
5476
pub fn parse(cx: &base::ExtCtxt<'_>, mtch: &[quoted::TokenTree], tts: TokenStream)

0 commit comments

Comments
 (0)