File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,28 @@ pub enum TokenTree {
49
49
Delimited ( DelimSpan , DelimToken , TokenStream ) ,
50
50
}
51
51
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
+
52
74
impl TokenTree {
53
75
/// Use this token tree as a matcher to parse given tts.
54
76
pub fn parse ( cx : & base:: ExtCtxt < ' _ > , mtch : & [ quoted:: TokenTree ] , tts : TokenStream )
You can’t perform that action at this time.
0 commit comments