@@ -49,7 +49,9 @@ macro_rules! define_handles {
4949 #[ repr( C ) ]
5050 pub ( crate ) struct $oty {
5151 handle: handle:: Handle ,
52- // Prevent Send and Sync impls
52+ // Prevent Send and Sync impls. `!Send`/`!Sync` is the usual
53+ // way of doing this, but that requires unstable features.
54+ // rust-analyzer uses this code and avoids unstable features.
5355 _marker: PhantomData <* mut ( ) >,
5456 }
5557
@@ -133,7 +135,9 @@ macro_rules! define_handles {
133135 #[ derive( Copy , Clone , PartialEq , Eq , Hash ) ]
134136 pub ( crate ) struct $ity {
135137 handle: handle:: Handle ,
136- // Prevent Send and Sync impls
138+ // Prevent Send and Sync impls. `!Send`/`!Sync` is the usual
139+ // way of doing this, but that requires unstable features.
140+ // rust-analyzer uses this code and avoids unstable features.
137141 _marker: PhantomData <* mut ( ) >,
138142 }
139143
@@ -191,7 +195,7 @@ define_handles! {
191195// FIXME(eddyb) generate these impls by pattern-matching on the
192196// names of methods - also could use the presence of `fn drop`
193197// to distinguish between 'owned and 'interned, above.
194- // Alternatively, special ' modes" could be listed of types in with_api
198+ // Alternatively, special " modes" could be listed of types in with_api
195199// instead of pattern matching on methods, here and in server decl.
196200
197201impl Clone for TokenStream {
@@ -250,17 +254,17 @@ macro_rules! define_client_side {
250254 $( impl $name {
251255 $( pub ( crate ) fn $method( $( $arg: $arg_ty) ,* ) $( -> $ret_ty) * {
252256 Bridge :: with( |bridge| {
253- let mut b = bridge. cached_buffer. take( ) ;
257+ let mut buf = bridge. cached_buffer. take( ) ;
254258
255- b . clear( ) ;
256- api_tags:: Method :: $name( api_tags:: $name:: $method) . encode( & mut b , & mut ( ) ) ;
257- reverse_encode!( b ; $( $arg) ,* ) ;
259+ buf . clear( ) ;
260+ api_tags:: Method :: $name( api_tags:: $name:: $method) . encode( & mut buf , & mut ( ) ) ;
261+ reverse_encode!( buf ; $( $arg) ,* ) ;
258262
259- b = bridge. dispatch. call( b ) ;
263+ buf = bridge. dispatch. call( buf ) ;
260264
261- let r = Result :: <_, PanicMessage >:: decode( & mut & b [ ..] , & mut ( ) ) ;
265+ let r = Result :: <_, PanicMessage >:: decode( & mut & buf [ ..] , & mut ( ) ) ;
262266
263- bridge. cached_buffer = b ;
267+ bridge. cached_buffer = buf ;
264268
265269 r. unwrap_or_else( |e| panic:: resume_unwind( e. into( ) ) )
266270 } )
@@ -367,7 +371,7 @@ pub struct Client<F> {
367371 // FIXME(eddyb) use a reference to the `static COUNTERS`, instead of
368372 // a wrapper `fn` pointer, once `const fn` can reference `static`s.
369373 pub ( super ) get_handle_counters : extern "C" fn ( ) -> & ' static HandleCounters ,
370- pub ( super ) run : extern "C" fn ( Bridge < ' _ > , F ) -> Buffer < u8 > ,
374+ pub ( super ) run : extern "C" fn ( Bridge < ' _ > , F ) -> Buffer ,
371375 pub ( super ) f : F ,
372376}
373377
@@ -377,22 +381,22 @@ pub struct Client<F> {
377381fn run_client < A : for < ' a , ' s > DecodeMut < ' a , ' s , ( ) > , R : Encode < ( ) > > (
378382 mut bridge : Bridge < ' _ > ,
379383 f : impl FnOnce ( A ) -> R ,
380- ) -> Buffer < u8 > {
384+ ) -> Buffer {
381385 // The initial `cached_buffer` contains the input.
382- let mut b = bridge. cached_buffer . take ( ) ;
386+ let mut buf = bridge. cached_buffer . take ( ) ;
383387
384388 panic:: catch_unwind ( panic:: AssertUnwindSafe ( || {
385389 bridge. enter ( || {
386- let reader = & mut & b [ ..] ;
390+ let reader = & mut & buf [ ..] ;
387391 let input = A :: decode ( reader, & mut ( ) ) ;
388392
389393 // Put the `cached_buffer` back in the `Bridge`, for requests.
390- Bridge :: with ( |bridge| bridge. cached_buffer = b . take ( ) ) ;
394+ Bridge :: with ( |bridge| bridge. cached_buffer = buf . take ( ) ) ;
391395
392396 let output = f ( input) ;
393397
394398 // Take the `cached_buffer` back out, for the output value.
395- b = Bridge :: with ( |bridge| bridge. cached_buffer . take ( ) ) ;
399+ buf = Bridge :: with ( |bridge| bridge. cached_buffer . take ( ) ) ;
396400
397401 // HACK(eddyb) Separate encoding a success value (`Ok(output)`)
398402 // from encoding a panic (`Err(e: PanicMessage)`) to avoid
@@ -403,24 +407,24 @@ fn run_client<A: for<'a, 's> DecodeMut<'a, 's, ()>, R: Encode<()>>(
403407 // this is defensively trying to avoid any accidental panicking
404408 // reaching the `extern "C"` (which should `abort` but might not
405409 // at the moment, so this is also potentially preventing UB).
406- b . clear ( ) ;
407- Ok :: < _ , ( ) > ( output) . encode ( & mut b , & mut ( ) ) ;
410+ buf . clear ( ) ;
411+ Ok :: < _ , ( ) > ( output) . encode ( & mut buf , & mut ( ) ) ;
408412 } )
409413 } ) )
410414 . map_err ( PanicMessage :: from)
411415 . unwrap_or_else ( |e| {
412- b . clear ( ) ;
413- Err :: < ( ) , _ > ( e) . encode ( & mut b , & mut ( ) ) ;
416+ buf . clear ( ) ;
417+ Err :: < ( ) , _ > ( e) . encode ( & mut buf , & mut ( ) ) ;
414418 } ) ;
415- b
419+ buf
416420}
417421
418422impl Client < fn ( crate :: TokenStream ) -> crate :: TokenStream > {
419423 pub const fn expand1 ( f : fn ( crate :: TokenStream ) -> crate :: TokenStream ) -> Self {
420424 extern "C" fn run (
421425 bridge : Bridge < ' _ > ,
422426 f : impl FnOnce ( crate :: TokenStream ) -> crate :: TokenStream ,
423- ) -> Buffer < u8 > {
427+ ) -> Buffer {
424428 run_client ( bridge, |input| f ( crate :: TokenStream ( input) ) . 0 )
425429 }
426430 Client { get_handle_counters : HandleCounters :: get, run, f }
@@ -434,7 +438,7 @@ impl Client<fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream> {
434438 extern "C" fn run (
435439 bridge : Bridge < ' _ > ,
436440 f : impl FnOnce ( crate :: TokenStream , crate :: TokenStream ) -> crate :: TokenStream ,
437- ) -> Buffer < u8 > {
441+ ) -> Buffer {
438442 run_client ( bridge, |( input, input2) | {
439443 f ( crate :: TokenStream ( input) , crate :: TokenStream ( input2) ) . 0
440444 } )
0 commit comments