diff options
Diffstat (limited to 'crates/proc_macro_srv/src/proc_macro/bridge/server.rs')
-rw-r--r-- | crates/proc_macro_srv/src/proc_macro/bridge/server.rs | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/crates/proc_macro_srv/src/proc_macro/bridge/server.rs b/crates/proc_macro_srv/src/proc_macro/bridge/server.rs index 3acb239af..88fbdc078 100644 --- a/crates/proc_macro_srv/src/proc_macro/bridge/server.rs +++ b/crates/proc_macro_srv/src/proc_macro/bridge/server.rs | |||
@@ -138,6 +138,7 @@ pub trait ExecutionStrategy { | |||
138 | input: Buffer<u8>, | 138 | input: Buffer<u8>, |
139 | run_client: extern "C" fn(Bridge<'_>, D) -> Buffer<u8>, | 139 | run_client: extern "C" fn(Bridge<'_>, D) -> Buffer<u8>, |
140 | client_data: D, | 140 | client_data: D, |
141 | force_show_panics: bool, | ||
141 | ) -> Buffer<u8>; | 142 | ) -> Buffer<u8>; |
142 | } | 143 | } |
143 | 144 | ||
@@ -150,10 +151,14 @@ impl ExecutionStrategy for SameThread { | |||
150 | input: Buffer<u8>, | 151 | input: Buffer<u8>, |
151 | run_client: extern "C" fn(Bridge<'_>, D) -> Buffer<u8>, | 152 | run_client: extern "C" fn(Bridge<'_>, D) -> Buffer<u8>, |
152 | client_data: D, | 153 | client_data: D, |
154 | force_show_panics: bool, | ||
153 | ) -> Buffer<u8> { | 155 | ) -> Buffer<u8> { |
154 | let mut dispatch = |b| dispatcher.dispatch(b); | 156 | let mut dispatch = |b| dispatcher.dispatch(b); |
155 | 157 | ||
156 | run_client(Bridge { cached_buffer: input, dispatch: (&mut dispatch).into() }, client_data) | 158 | run_client( |
159 | Bridge { cached_buffer: input, dispatch: (&mut dispatch).into(), force_show_panics }, | ||
160 | client_data, | ||
161 | ) | ||
157 | } | 162 | } |
158 | } | 163 | } |
159 | 164 | ||
@@ -169,6 +174,7 @@ impl ExecutionStrategy for CrossThread1 { | |||
169 | input: Buffer<u8>, | 174 | input: Buffer<u8>, |
170 | run_client: extern "C" fn(Bridge<'_>, D) -> Buffer<u8>, | 175 | run_client: extern "C" fn(Bridge<'_>, D) -> Buffer<u8>, |
171 | client_data: D, | 176 | client_data: D, |
177 | force_show_panics: bool, | ||
172 | ) -> Buffer<u8> { | 178 | ) -> Buffer<u8> { |
173 | use std::sync::mpsc::channel; | 179 | use std::sync::mpsc::channel; |
174 | 180 | ||
@@ -182,7 +188,11 @@ impl ExecutionStrategy for CrossThread1 { | |||
182 | }; | 188 | }; |
183 | 189 | ||
184 | run_client( | 190 | run_client( |
185 | Bridge { cached_buffer: input, dispatch: (&mut dispatch).into() }, | 191 | Bridge { |
192 | cached_buffer: input, | ||
193 | dispatch: (&mut dispatch).into(), | ||
194 | force_show_panics, | ||
195 | }, | ||
186 | client_data, | 196 | client_data, |
187 | ) | 197 | ) |
188 | }); | 198 | }); |
@@ -204,6 +214,7 @@ impl ExecutionStrategy for CrossThread2 { | |||
204 | input: Buffer<u8>, | 214 | input: Buffer<u8>, |
205 | run_client: extern "C" fn(Bridge<'_>, D) -> Buffer<u8>, | 215 | run_client: extern "C" fn(Bridge<'_>, D) -> Buffer<u8>, |
206 | client_data: D, | 216 | client_data: D, |
217 | force_show_panics: bool, | ||
207 | ) -> Buffer<u8> { | 218 | ) -> Buffer<u8> { |
208 | use std::sync::{Arc, Mutex}; | 219 | use std::sync::{Arc, Mutex}; |
209 | 220 | ||
@@ -229,7 +240,11 @@ impl ExecutionStrategy for CrossThread2 { | |||
229 | }; | 240 | }; |
230 | 241 | ||
231 | let r = run_client( | 242 | let r = run_client( |
232 | Bridge { cached_buffer: input, dispatch: (&mut dispatch).into() }, | 243 | Bridge { |
244 | cached_buffer: input, | ||
245 | dispatch: (&mut dispatch).into(), | ||
246 | force_show_panics, | ||
247 | }, | ||
233 | client_data, | 248 | client_data, |
234 | ); | 249 | ); |
235 | 250 | ||
@@ -268,6 +283,7 @@ fn run_server< | |||
268 | input: I, | 283 | input: I, |
269 | run_client: extern "C" fn(Bridge<'_>, D) -> Buffer<u8>, | 284 | run_client: extern "C" fn(Bridge<'_>, D) -> Buffer<u8>, |
270 | client_data: D, | 285 | client_data: D, |
286 | force_show_panics: bool, | ||
271 | ) -> Result<O, PanicMessage> { | 287 | ) -> Result<O, PanicMessage> { |
272 | let mut dispatcher = | 288 | let mut dispatcher = |
273 | Dispatcher { handle_store: HandleStore::new(handle_counters), server: MarkedTypes(server) }; | 289 | Dispatcher { handle_store: HandleStore::new(handle_counters), server: MarkedTypes(server) }; |
@@ -275,7 +291,13 @@ fn run_server< | |||
275 | let mut b = Buffer::new(); | 291 | let mut b = Buffer::new(); |
276 | input.encode(&mut b, &mut dispatcher.handle_store); | 292 | input.encode(&mut b, &mut dispatcher.handle_store); |
277 | 293 | ||
278 | b = strategy.run_bridge_and_client(&mut dispatcher, b, run_client, client_data); | 294 | b = strategy.run_bridge_and_client( |
295 | &mut dispatcher, | ||
296 | b, | ||
297 | run_client, | ||
298 | client_data, | ||
299 | force_show_panics, | ||
300 | ); | ||
279 | 301 | ||
280 | Result::decode(&mut &b[..], &mut dispatcher.handle_store) | 302 | Result::decode(&mut &b[..], &mut dispatcher.handle_store) |
281 | } | 303 | } |
@@ -286,6 +308,7 @@ impl client::Client<fn(crate::TokenStream) -> crate::TokenStream> { | |||
286 | strategy: &impl ExecutionStrategy, | 308 | strategy: &impl ExecutionStrategy, |
287 | server: S, | 309 | server: S, |
288 | input: S::TokenStream, | 310 | input: S::TokenStream, |
311 | force_show_panics: bool, | ||
289 | ) -> Result<S::TokenStream, PanicMessage> { | 312 | ) -> Result<S::TokenStream, PanicMessage> { |
290 | let client::Client { get_handle_counters, run, f } = *self; | 313 | let client::Client { get_handle_counters, run, f } = *self; |
291 | run_server( | 314 | run_server( |
@@ -295,6 +318,7 @@ impl client::Client<fn(crate::TokenStream) -> crate::TokenStream> { | |||
295 | <MarkedTypes<S> as Types>::TokenStream::mark(input), | 318 | <MarkedTypes<S> as Types>::TokenStream::mark(input), |
296 | run, | 319 | run, |
297 | f, | 320 | f, |
321 | force_show_panics, | ||
298 | ) | 322 | ) |
299 | .map(<MarkedTypes<S> as Types>::TokenStream::unmark) | 323 | .map(<MarkedTypes<S> as Types>::TokenStream::unmark) |
300 | } | 324 | } |
@@ -307,6 +331,7 @@ impl client::Client<fn(crate::TokenStream, crate::TokenStream) -> crate::TokenSt | |||
307 | server: S, | 331 | server: S, |
308 | input: S::TokenStream, | 332 | input: S::TokenStream, |
309 | input2: S::TokenStream, | 333 | input2: S::TokenStream, |
334 | force_show_panics: bool, | ||
310 | ) -> Result<S::TokenStream, PanicMessage> { | 335 | ) -> Result<S::TokenStream, PanicMessage> { |
311 | let client::Client { get_handle_counters, run, f } = *self; | 336 | let client::Client { get_handle_counters, run, f } = *self; |
312 | run_server( | 337 | run_server( |
@@ -319,6 +344,7 @@ impl client::Client<fn(crate::TokenStream, crate::TokenStream) -> crate::TokenSt | |||
319 | ), | 344 | ), |
320 | run, | 345 | run, |
321 | f, | 346 | f, |
347 | force_show_panics, | ||
322 | ) | 348 | ) |
323 | .map(<MarkedTypes<S> as Types>::TokenStream::unmark) | 349 | .map(<MarkedTypes<S> as Types>::TokenStream::unmark) |
324 | } | 350 | } |