diff --git a/library/proc_macro/src/bridge/mod.rs b/library/proc_macro/src/bridge/mod.rs index d1f7d84991d..f7c9df6564f 100644 --- a/library/proc_macro/src/bridge/mod.rs +++ b/library/proc_macro/src/bridge/mod.rs @@ -220,8 +220,6 @@ use rpc::{Decode, DecodeMut, Encode, Reader, Writer}; /// then passes it to the client through the function pointer in the `run` /// field of `client::Client`. The client holds its copy of the `Bridge` /// in TLS during its execution (`Bridge::{enter, with}` in `client.rs`). -// Note: Bridge is !Send and !Sync due to containg a `Closure`. If this -// ever changes, make sure to preserve the !Send and !Sync property. #[repr(C)] pub struct Bridge<'a> { /// Reusable buffer (only `clear`-ed, never shrunk), primarily @@ -233,6 +231,9 @@ pub struct Bridge<'a> { /// If 'true', always invoke the default panic hook force_show_panics: bool, + + // Prevent Send and Sync impls + _marker: marker::PhantomData<*mut ()>, } #[forbid(unsafe_code)] diff --git a/library/proc_macro/src/bridge/server.rs b/library/proc_macro/src/bridge/server.rs index 1b3ccf4c18e..2e0400d32a0 100644 --- a/library/proc_macro/src/bridge/server.rs +++ b/library/proc_macro/src/bridge/server.rs @@ -153,7 +153,12 @@ impl ExecutionStrategy for SameThread { let mut dispatch = |b| dispatcher.dispatch(b); run_client( - Bridge { cached_buffer: input, dispatch: (&mut dispatch).into(), force_show_panics }, + Bridge { + cached_buffer: input, + dispatch: (&mut dispatch).into(), + force_show_panics, + _marker: marker::PhantomData, + }, client_data, ) } @@ -189,6 +194,7 @@ impl ExecutionStrategy for CrossThread1 { cached_buffer: input, dispatch: (&mut dispatch).into(), force_show_panics, + _marker: marker::PhantomData, }, client_data, ) @@ -241,6 +247,7 @@ impl ExecutionStrategy for CrossThread2 { cached_buffer: input, dispatch: (&mut dispatch).into(), force_show_panics, + _marker: marker::PhantomData, }, client_data, );