File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff 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+
5274impl 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 )
You can’t perform that action at this time.
0 commit comments